GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.Middlewares;
  11. using OASystem.API.OAMethodLib;
  12. using OASystem.API.OAMethodLib.APNs;
  13. using OASystem.API.OAMethodLib.DeepSeekAPI;
  14. using OASystem.API.OAMethodLib.File;
  15. using OASystem.API.OAMethodLib.Hub.HubClients;
  16. using OASystem.API.OAMethodLib.Hub.Hubs;
  17. using OASystem.API.OAMethodLib.JuHeAPI;
  18. using OASystem.API.OAMethodLib.KiMiApi;
  19. using OASystem.API.OAMethodLib.Logging;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.CRM;
  31. using OASystem.Domain.ViewModels.Financial;
  32. using OASystem.Domain.ViewModels.Groups;
  33. using OASystem.Domain.ViewModels.OCR;
  34. using OASystem.Infrastructure.Repositories.CRM;
  35. using OASystem.Infrastructure.Repositories.Financial;
  36. using OASystem.Infrastructure.Repositories.Groups;
  37. using Quartz.Logging;
  38. using Quartz.Util;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.ComponentModel.DataAnnotations;
  42. using System.Data;
  43. using System.Diagnostics;
  44. using System.Globalization;
  45. using System.IO;
  46. using System.IO.Compression;
  47. using System.Text.Json;
  48. using System.Text.RegularExpressions;
  49. using System.Web;
  50. using static OASystem.API.OAMethodLib.JWTHelper;
  51. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  52. using Bookmark = Aspose.Words.Bookmark;
  53. using Cell = Aspose.Words.Tables.Cell;
  54. using Table = Aspose.Words.Tables.Table;
  55. namespace OASystem.API.Controllers
  56. {
  57. /// <summary>
  58. /// 团组相关
  59. /// </summary>
  60. //[Authorize]
  61. [Route("api/[controller]/[action]")]
  62. public class GroupsController : ControllerBase
  63. {
  64. private readonly ILogger<GroupsController> _logger;
  65. private readonly ITextFileLogger _eec_textLogger;
  66. private readonly IGroupTextFileLogger _groupTextLogger;
  67. private readonly GrpScheduleRepository _grpScheduleRep;
  68. private readonly IMapper _mapper;
  69. private readonly DelegationInfoRepository _groupRepository;
  70. private readonly TaskAssignmentRepository _taskAssignmentRep;
  71. private readonly AirTicketResRepository _airTicketResRep;
  72. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  73. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  74. private readonly DelegationEnDataRepository _delegationEnDataRep;
  75. private readonly DelegationVisaRepository _delegationVisaRep;
  76. private readonly VisaPriceRepository _visaPriceRep;
  77. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  78. private readonly HotelPriceRepository _hotelPriceRep;
  79. private readonly CustomersRepository _customersRep;
  80. private readonly MessageRepository _message;
  81. private readonly SqlSugarClient _sqlSugar;
  82. private readonly TourClientListRepository _tourClientListRep;
  83. private readonly TeamRateRepository _teamRateRep;
  84. #region 成本相关
  85. private readonly CheckBoxsRepository _checkBoxs;
  86. private readonly GroupCostRepository _GroupCostRepository;
  87. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  88. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  89. #endregion
  90. private readonly SetDataRepository _setDataRep;
  91. private string url;
  92. private string path;
  93. private readonly EnterExitCostRepository _enterExitCostRep;
  94. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  95. private readonly UsersRepository _usersRep;
  96. private readonly IJuHeApiService _juHeApi;
  97. private readonly InvertedListRepository _invertedListRep;
  98. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  99. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  100. private readonly ThreeCodeRepository _threeCodeRepository;
  101. private readonly HotelInquiryRepository _hotelInquiryRep;
  102. private readonly FeeAuditRepository _feeAuditRep;
  103. private readonly VisaCommissionRepository _visaCommissionRep;
  104. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  105. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  106. private readonly List<CurrencyInfo> _currencyInit;
  107. private readonly List<int> _portTypeData;
  108. private readonly TableOperationRecordRepository _tableorRep;
  109. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  110. private readonly RestaurantRepository _restaurantRep;
  111. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  112. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  113. private readonly IDeepSeekService _deepSeekService;
  114. /// <summary>
  115. /// 构造函数
  116. /// </summary>
  117. /// <param name="logger"></param>
  118. /// <param name="eec_textLogger"></param>
  119. /// <param name="groupTextLogger"></param>
  120. /// <param name="mapper"></param>
  121. /// <param name="hubContext"></param>
  122. /// <param name="sqlSugar"></param>
  123. /// <param name="grpScheduleRep"></param>
  124. /// <param name="groupRepository"></param>
  125. /// <param name="taskAssignmentRep"></param>
  126. /// <param name="airTicketResRep"></param>
  127. /// <param name="decreasePaymentsRep"></param>
  128. /// <param name="InvitationOfficialActivitiesRep"></param>
  129. /// <param name="delegationEnDataRep"></param>
  130. /// <param name="enterExitCostRep"></param>
  131. /// <param name="delegationVisaRep"></param>
  132. /// <param name="message"></param>
  133. /// <param name="visaPriceRep"></param>
  134. /// <param name="carTouristGuideGroundRep"></param>
  135. /// <param name="checkBoxs"></param>
  136. /// <param name="GroupCostRepository"></param>
  137. /// <param name="CostTypeHotelNumberRepository"></param>
  138. /// <param name="GroupCostParameterRepository"></param>
  139. /// <param name="hotelPriceRep"></param>
  140. /// <param name="customersRep"></param>
  141. /// <param name="setDataRep"></param>
  142. /// <param name="tourClientListRep"></param>
  143. /// <param name="teamRateRep"></param>
  144. /// <param name="usersRep"></param>
  145. /// <param name="juHeApi"></param>
  146. /// <param name="invertedListRep"></param>
  147. /// <param name="visaFeeInfoRep"></param>
  148. /// <param name="ticketBlackCodeRep"></param>
  149. /// <param name="hotelInquiryRep"></param>
  150. /// <param name="threeCodeRepository"></param>
  151. /// <param name="feeAuditRep"></param>
  152. /// <param name="visaCommissionRep"></param>
  153. /// <param name="ffrRep"></param>
  154. /// <param name="opinionaireRep"></param>
  155. /// <param name="tableorRep"></param>
  156. /// <param name="enterExitCostDraftRep"></param>
  157. /// <param name="restaurantRep"></param>
  158. /// <param name="enterExitCostQuoteRep"></param>
  159. /// <param name="grpOrderPreInfoRep"></param>
  160. public GroupsController(
  161. ILogger<GroupsController> logger,
  162. ITextFileLogger eec_textLogger,
  163. IGroupTextFileLogger groupTextLogger,
  164. IMapper mapper,
  165. IHubContext<ChatHub, IChatClient> hubContext,
  166. SqlSugarClient sqlSugar,
  167. GrpScheduleRepository grpScheduleRep,
  168. DelegationInfoRepository groupRepository,
  169. TaskAssignmentRepository taskAssignmentRep,
  170. AirTicketResRepository airTicketResRep,
  171. DecreasePaymentsRepository decreasePaymentsRep,
  172. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  173. DelegationEnDataRepository delegationEnDataRep,
  174. EnterExitCostRepository enterExitCostRep,
  175. DelegationVisaRepository delegationVisaRep,
  176. MessageRepository message,
  177. VisaPriceRepository visaPriceRep,
  178. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  179. CheckBoxsRepository checkBoxs,
  180. GroupCostRepository GroupCostRepository,
  181. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  182. GroupCostParameterRepository GroupCostParameterRepository,
  183. HotelPriceRepository hotelPriceRep,
  184. CustomersRepository customersRep,
  185. SetDataRepository setDataRep,
  186. TourClientListRepository tourClientListRep,
  187. TeamRateRepository teamRateRep,
  188. UsersRepository usersRep,
  189. IJuHeApiService juHeApi,
  190. InvertedListRepository invertedListRep,
  191. VisaFeeInfoRepository visaFeeInfoRep,
  192. TicketBlackCodeRepository ticketBlackCodeRep,
  193. HotelInquiryRepository hotelInquiryRep,
  194. ThreeCodeRepository threeCodeRepository,
  195. FeeAuditRepository feeAuditRep,
  196. VisaCommissionRepository visaCommissionRep,
  197. ForeignReceivablesRepository ffrRep,
  198. OpinionaireRepository opinionaireRep,
  199. TableOperationRecordRepository tableorRep,
  200. EnterExitCostDraftRepository enterExitCostDraftRep,
  201. RestaurantRepository restaurantRep,
  202. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  203. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  204. IDeepSeekService deepSeekService
  205. )
  206. {
  207. _logger = logger;
  208. _eec_textLogger = eec_textLogger;
  209. _groupTextLogger = groupTextLogger;
  210. _mapper = mapper;
  211. _grpScheduleRep = grpScheduleRep;
  212. _groupRepository = groupRepository;
  213. _taskAssignmentRep = taskAssignmentRep;
  214. _airTicketResRep = airTicketResRep;
  215. _sqlSugar = sqlSugar;
  216. url = AppSettingsHelper.Get("ExcelBaseUrl");
  217. path = AppSettingsHelper.Get("ExcelBasePath");
  218. if (!System.IO.Directory.Exists(path))
  219. {
  220. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  221. }
  222. _decreasePaymentsRep = decreasePaymentsRep;
  223. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  224. _delegationEnDataRep = delegationEnDataRep;
  225. _enterExitCostRep = enterExitCostRep;
  226. _delegationVisaRep = delegationVisaRep;
  227. _message = message;
  228. _visaPriceRep = visaPriceRep;
  229. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  230. _checkBoxs = checkBoxs;
  231. _GroupCostRepository = GroupCostRepository;
  232. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  233. _GroupCostParameterRepository = GroupCostParameterRepository;
  234. _hotelPriceRep = hotelPriceRep;
  235. _customersRep = customersRep;
  236. _setDataRep = setDataRep;
  237. _tourClientListRep = tourClientListRep;
  238. _teamRateRep = teamRateRep;
  239. _hubContext = hubContext;
  240. _usersRep = usersRep;
  241. _juHeApi = juHeApi;
  242. _invertedListRep = invertedListRep;
  243. _visaFeeInfoRep = visaFeeInfoRep;
  244. _ticketBlackCodeRep = ticketBlackCodeRep;
  245. _hotelInquiryRep = hotelInquiryRep;
  246. _threeCodeRepository = threeCodeRepository;
  247. _feeAuditRep = feeAuditRep;
  248. _visaCommissionRep = visaCommissionRep;
  249. _ffrRep = ffrRep;
  250. _opinionaireRep = opinionaireRep;
  251. _currencyInit = new List<CurrencyInfo>()
  252. {
  253. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  254. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  255. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  256. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  257. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  258. };
  259. _portTypeData = new List<int>() { 2, 3 };
  260. _tableorRep = tableorRep;
  261. _enterExitCostDraftRep = enterExitCostDraftRep;
  262. _restaurantRep = restaurantRep;
  263. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  264. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  265. _deepSeekService = deepSeekService;
  266. }
  267. #region 流程管控
  268. /// <summary>
  269. /// 获取团组流程管控信息
  270. /// </summary>
  271. /// <param name="_jsonDto">查询参数</param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  276. {
  277. if (string.IsNullOrEmpty(_jsonDto.Paras))
  278. {
  279. return Ok(JsonView(false, "参数为空"));
  280. }
  281. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  282. if (_ScheduleDto != null)
  283. {
  284. if (_ScheduleDto.SearchType == 2)//获取列表
  285. {
  286. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  287. return Ok(JsonView(_grpScheduleViewList));
  288. }
  289. else//获取对象
  290. {
  291. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  292. if (_grpScheduleView != null)
  293. {
  294. return Ok(JsonView(_grpScheduleView));
  295. }
  296. }
  297. }
  298. else
  299. {
  300. return Ok(JsonView(false, "参数反序列化失败"));
  301. }
  302. return Ok(JsonView(false, "暂无数据!"));
  303. }
  304. /// <summary>
  305. /// 修改团组流程管控详细表数据
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  312. {
  313. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  314. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  315. .SetColumns(it => it.Duty == _detail.Duty)
  316. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  317. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  318. .SetColumns(it => it.JobContent == _detail.JobContent)
  319. .SetColumns(it => it.Remark == _detail.Remark)
  320. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  321. .Where(s => s.Id == dto.Id)
  322. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "保存成功!"));
  327. }
  328. return Ok(JsonView(false, "保存失败!"));
  329. }
  330. /// <summary>
  331. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. _detail.IsDel = 1;
  341. _detail.DeleteUserId = dto.Duty;
  342. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  343. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  344. .SetColumns(it => it.IsDel == _detail.IsDel)
  345. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  346. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  347. .Where(it => it.Id == dto.Id)
  348. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  349. //.WhereColumns(s => s.Id == dto.Id)
  350. .ExecuteCommandAsync();
  351. if (result > 0)
  352. {
  353. return Ok(JsonView(true, "删除成功!"));
  354. }
  355. return Ok(JsonView(false, "删除失败!"));
  356. }
  357. /// <summary>
  358. /// 增加团组流程管控详细表数据
  359. /// </summary>
  360. /// <param name="dto"></param>
  361. /// <returns></returns>
  362. [HttpPost]
  363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  364. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  365. {
  366. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  367. if (DateTime.Now < _detail.ExpectBeginDt)
  368. {
  369. _detail.StepStatus = 0;
  370. }
  371. else
  372. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  373. _detail.StepStatus = 1;
  374. }
  375. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  376. if (result > 0)
  377. {
  378. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  379. return Ok(JsonView(true, "添加成功!", _result));
  380. }
  381. return Ok(JsonView(false, "添加失败!"));
  382. }
  383. #endregion
  384. #region 团组前期信息
  385. /// <summary>
  386. /// 团组前期信息H5-URL(员工对应地址)
  387. /// </summary>
  388. /// <param name="name">用户名称</param>
  389. /// <returns></returns>
  390. [HttpGet]
  391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  392. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  393. {
  394. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  395. .Where(x => x.IsDel == 0)
  396. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  397. .OrderBy(x => x.Id)
  398. .Select(x => new
  399. {
  400. name = x.CnName,
  401. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  402. })
  403. .ToListAsync();
  404. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  405. }
  406. /// <summary>
  407. /// 团组前期信息 List
  408. /// </summary>
  409. /// <returns></returns>
  410. [HttpPost]
  411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  412. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  413. {
  414. var search = dto.Search;
  415. int[] nameTempIds = new int[] { 1, 12, 28 },
  416. countryTempIds = new int[] { 2, 13, 29 },
  417. daysTempIds = new int[] { 4, 15, 31 },
  418. ppNumTempIds = new int[] { 6 };
  419. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  420. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  421. .Where((opi, u) => opi.IsDel == 0)
  422. .OrderByDescending((opi, u) => opi.CreateTime)
  423. .Select((opi, u) => new GroupOrderPreInfoListView()
  424. {
  425. Id = opi.Id,
  426. Name = opi.Name,
  427. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  428. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  429. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  430. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  431. Operator = u.CnName,
  432. OperationTime = opi.CreateTime
  433. })
  434. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  435. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  436. .ToListAsync();
  437. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  438. int total = list.Count;
  439. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  440. var listPageData1 = listPageData
  441. .Skip((dto.PageIndex - 1) * dto.PageSize)
  442. .Take(dto.PageSize)
  443. .ToList();
  444. var infoIds = listPageData1.Select(x => x.Id).ToList();
  445. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  446. .Where(x => x.IsDel == 0 && x.STid == 109)
  447. .ToArrayAsync();
  448. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  449. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  450. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  451. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  452. .ToListAsync();
  453. foreach (var item in listPageData1)
  454. {
  455. var typeDatas1 = typeDatas.Select(x => new
  456. {
  457. x.Id,
  458. x.Name,
  459. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  460. }).ToArray();
  461. item.VersionDetails = typeDatas1;
  462. }
  463. return Ok(JsonView(listPageData1, listPageData1.Count));
  464. }
  465. /// <summary>
  466. /// 团组前期信息 Init
  467. /// </summary>
  468. /// <returns></returns>
  469. [HttpGet("{userId}")]
  470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  471. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  472. {
  473. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  474. }
  475. /// <summary>
  476. /// 国家数据源
  477. /// </summary>
  478. /// <param name="pageIndex">当前页码</param>
  479. /// <param name="pageSize">每页条数</param>
  480. /// <param name="search">查询条件</param>
  481. /// <returns></returns>
  482. [HttpGet]
  483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  484. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  485. {
  486. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  487. if (pageIndex == 0 && pageSize == 0)
  488. {
  489. //所有数据
  490. return Ok(JsonView(countrys, countrys.Count));
  491. }
  492. //分页
  493. int skip = (pageIndex - 1) * pageSize;
  494. int take = pageSize;
  495. if (!string.IsNullOrEmpty(search))
  496. {
  497. IEnumerable<char> charSequence = search.Select(c => c);
  498. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  499. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  500. return Ok(JsonView(pageData, pageResult1.Count));
  501. }
  502. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  503. return Ok(JsonView(pageResult2, countrys.Count));
  504. }
  505. /// <summary>
  506. /// 城市数据源
  507. /// </summary>
  508. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  509. /// <param name="pageIndex">当前页码</param>
  510. /// <param name="pageSize">每页条数</param>
  511. /// <param name="search">查询条件</param>
  512. /// <returns></returns>
  513. [HttpGet("{countryLabel}")]
  514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  515. public async Task<IActionResult> CityByCountry(
  516. string countryLabel,
  517. [FromQuery] int pageIndex,
  518. [FromQuery] int pageSize,
  519. [FromQuery] string search)
  520. {
  521. countryLabel = HttpUtility.UrlDecode(countryLabel);
  522. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  523. var citys = Array.Empty<string?>();
  524. if (countryList.Any())
  525. {
  526. var cityDatas = await _sqlSugar
  527. .Queryable<Grp_NationalTravelFee>()
  528. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  529. .ToArrayAsync();
  530. foreach (var item in cityDatas)
  531. {
  532. if (item.City.Contains("城市"))
  533. {
  534. item.City = item.Country + "-所有城市";
  535. }
  536. }
  537. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  538. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  539. }
  540. if (pageIndex == 0 && pageSize == 0)
  541. {
  542. //所有数据
  543. return Ok(JsonView(citys, citys?.Length ?? 0));
  544. }
  545. //分页
  546. int skip = (pageIndex - 1) * pageSize;
  547. int take = pageSize;
  548. if (!string.IsNullOrEmpty(search))
  549. {
  550. IEnumerable<char> charSequence = search.Select(c => c);
  551. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  552. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  553. return Ok(JsonView(pageData, pageResult1.Count));
  554. }
  555. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  556. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  557. }
  558. /// <summary>
  559. /// 团组前期信息 Info
  560. /// </summary>
  561. /// <param name="dto">Id</param>
  562. /// <returns></returns>
  563. [HttpGet("{Id}/{TempId}")]
  564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  565. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  566. {
  567. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  568. }
  569. /// <summary>
  570. /// 团组前期信息 移动端 Info
  571. /// </summary>
  572. /// <param name="dto">Id</param>
  573. /// <returns></returns>
  574. [HttpGet("{Id}/{TempId}")]
  575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  576. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  577. {
  578. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  579. }
  580. /// <summary>
  581. /// 团组前期信息 Save
  582. /// </summary>
  583. /// <param name="dto">Id</param>
  584. /// <returns></returns>
  585. [HttpPost]
  586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  587. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  588. {
  589. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  590. }
  591. /// <summary>
  592. /// 团组前期信息 Del
  593. /// </summary>
  594. /// <param name="dto">Id</param>
  595. /// <returns></returns>
  596. [HttpPost]
  597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  598. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  599. {
  600. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  601. }
  602. /// <summary>
  603. /// 团组前期信息 文件下载
  604. /// </summary>
  605. /// <param name="dto">Id</param>
  606. /// <returns></returns>
  607. [HttpGet("{Id}/{TempId}")]
  608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  609. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  610. {
  611. int id = dto.Id, tempId = dto.TempId;
  612. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  613. var data = view.Data as GrpOrderPreInfoView;
  614. #region Excel
  615. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  616. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  617. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  618. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  619. var fileNamePrefix = string.Empty;
  620. if (tempId == 1405)
  621. {
  622. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  623. fileNamePrefix = $"{data.Name}_无商邀版";
  624. }
  625. else if (tempId == 1406)
  626. {
  627. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  628. fileNamePrefix = $"{data.Name}_有商邀版";
  629. }
  630. else
  631. {
  632. //tempId == 1404 默认下载
  633. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  634. fileNamePrefix = $"{data.Name}_单接送机";
  635. }
  636. foreach (var item in data.Items)
  637. {
  638. var obj = item.NewValue;
  639. if (obj == null) item.OriginVal = "";
  640. else if (obj.Equals("有") || obj.Equals("无"))
  641. {
  642. item.OriginVal = obj.ToString();
  643. }
  644. else if (obj is object[] objArray)
  645. {
  646. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  647. item.OriginVal = string.Join("、", stringArray);
  648. }
  649. else if (obj is string[] stringArray)
  650. {
  651. item.OriginVal = string.Join("、", stringArray);
  652. }
  653. else if (obj.Equals("-"))
  654. {
  655. item.OriginVal = "";
  656. }
  657. }
  658. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  659. fileName = CommonFun.ValidFileName(fileName);
  660. //载入模板
  661. var designer = new WorkbookDesigner
  662. {
  663. Workbook = new Workbook(tempPath)
  664. };
  665. if (tempId == 1406)
  666. {
  667. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  668. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  669. for (int i = 1; i <= view2.Length; i++)
  670. {
  671. view2[i - 1].Index = i;
  672. }
  673. designer.SetDataSource("View1", view1);
  674. designer.SetDataSource("View2", view2);
  675. }
  676. else
  677. {
  678. designer.SetDataSource("View", data.Items);
  679. }
  680. designer.Process();
  681. if (!Directory.Exists(savePath))
  682. {
  683. Directory.CreateDirectory(savePath);
  684. }
  685. string serverPath = $"{savePath}{fileName}";
  686. designer.Workbook.Save(serverPath);
  687. string rst = $"{servicePath}{ftpPath}{fileName}";
  688. #endregion
  689. return Ok(JsonView(new { url = rst }));
  690. }
  691. #endregion
  692. #region 团组基本信息
  693. /// <summary>
  694. /// 接团信息列表
  695. /// </summary>
  696. /// <param name="dto">团组列表请求dto</param>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  701. {
  702. var groupData = await _groupRepository.GetGroupList(dto);
  703. if (groupData.Code != 0)
  704. {
  705. return Ok(JsonView(false, groupData.Msg));
  706. }
  707. return Ok(JsonView(groupData.Data));
  708. }
  709. /// <summary>
  710. /// 分页查询团组列表
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  717. {
  718. var watch = new Stopwatch();
  719. watch.Start();
  720. RefAsync<int> total = 0;
  721. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  722. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  723. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  724. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  725. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  726. .Distinct()
  727. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  728. watch.Stop();
  729. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  730. }
  731. /// <summary>
  732. /// 接团信息列表 Page Init
  733. /// </summary>
  734. /// <returns></returns>
  735. [HttpPost]
  736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  737. public async Task<IActionResult> PostGroupPageListInit()
  738. {
  739. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  740. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  741. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  742. var _view = new
  743. {
  744. depData = depDatas,
  745. rankData = rankDatas
  746. };
  747. return Ok(JsonView(true, "查询成功!", _view));
  748. }
  749. /// <summary>
  750. /// 接团信息列表 Page
  751. /// </summary>
  752. /// <param name="dto">团组列表请求dto</param>
  753. /// <returns></returns>
  754. [HttpPost]
  755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  756. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  757. {
  758. #region 参数验证
  759. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  760. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  761. #region 页面操作权限验证
  762. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  764. #endregion
  765. #endregion
  766. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  767. {
  768. string sqlWhere = string.Empty;
  769. if (dto.IsSure == 0) //未完成
  770. {
  771. sqlWhere += string.Format(@" And IsSure = 0");
  772. }
  773. else if (dto.IsSure == 1) //已完成
  774. {
  775. sqlWhere += string.Format(@" And IsSure = 1");
  776. }
  777. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  778. {
  779. string tj = dto.SearchCriteria;
  780. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  781. tj, tj, tj, tj, tj);
  782. }
  783. if (int.TryParse(dto.Rank, out int rankId))
  784. {
  785. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  786. }
  787. string sqlWhere1 = string.Empty;
  788. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  789. {
  790. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  791. }
  792. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  793. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  794. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  795. JietuanOperator,IsSure,CreateTime,IsBid,Step
  796. From (
  797. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  798. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  799. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  800. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  801. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  802. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  803. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  804. From Grp_DelegationInfo gdi
  805. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  806. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  807. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  808. Where gdi.IsDel = 0 {0}
  809. ) temp {1}", sqlWhere, sqlWhere1);
  810. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  811. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  812. //处理 团组模块实际操作人
  813. _DelegationList.ForEach(async x =>
  814. {
  815. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  816. var operatorNames = new StringBuilder();
  817. //operatorNames.AppendLine("各模块实际操作人:");
  818. if (operators.Any())
  819. {
  820. operators.ForEach(y =>
  821. {
  822. string label = string.Empty;
  823. if (y.OperationUsers.Any())
  824. {
  825. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  826. label = string.Join('、', users);
  827. }
  828. else label = "暂未指定";
  829. operatorNames.AppendLine($"{y.CTableName}:{label}");
  830. operatorNames.AppendLine();
  831. });
  832. }
  833. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  834. });
  835. var _view = new
  836. {
  837. PageFuncAuth = pageFunAuthView,
  838. Data = _DelegationList
  839. };
  840. return Ok(JsonView(true, "查询成功!", _view, total));
  841. }
  842. else
  843. {
  844. return Ok(JsonView(false, "查询失败"));
  845. }
  846. }
  847. /// <summary>
  848. /// 团组列表
  849. /// </summary>
  850. /// <returns></returns>
  851. [HttpPost]
  852. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  853. {
  854. #region 参数验证
  855. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  856. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  857. #region 页面操作权限验证
  858. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  859. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  860. #endregion
  861. #endregion
  862. if (dto.PortType != 1 && dto.PortType != 2)
  863. {
  864. return Ok(JsonView(false, "查询失败!"));
  865. }
  866. string orderbyStr = "order by gdi.CreateTime Desc";
  867. string sqlWhere = string.Empty;
  868. if (dto.IsSure == 0) //未完成
  869. {
  870. sqlWhere += string.Format(@" And IsSure = 0");
  871. }
  872. else if (dto.IsSure == 1) //已完成
  873. {
  874. sqlWhere += string.Format(@" And IsSure = 1");
  875. }
  876. //团组类型
  877. if (dto.TeamDid > 0)
  878. {
  879. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  880. }
  881. //团组名称
  882. if (!string.IsNullOrEmpty(dto.TeamName))
  883. {
  884. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  885. }
  886. //客户名称
  887. if (!string.IsNullOrEmpty(dto.ClientName))
  888. {
  889. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  890. }
  891. //客户单位
  892. if (!string.IsNullOrEmpty(dto.ClientUnit))
  893. {
  894. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  895. }
  896. //出访时间
  897. if (!string.IsNullOrEmpty(dto.visitDataTime))
  898. {
  899. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  900. orderbyStr = "order by gdi.VisitDate";
  901. }
  902. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  903. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  904. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  905. JietuanOperator,IsSure,CreateTime
  906. From (
  907. Select row_number() over({0}) as Row_Number,
  908. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  909. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  910. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  911. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  912. From Grp_DelegationInfo gdi
  913. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  914. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  915. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  916. Where gdi.IsDel = 0 {1}
  917. ) temp ", orderbyStr, sqlWhere);
  918. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  919. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  920. #region 处理所属部门
  921. /*
  922. * 1.sq 和 gyy 等显示 市场部
  923. * 2.王鸽和主管及张总还有管理员号统一国交部
  924. * 2-1. 4 管理员 ,21 张海麟
  925. */
  926. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  927. var userIds1 = new List<int>() { 4, 21 };
  928. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  929. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  930. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  931. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  932. .ToList();
  933. foreach (var item in _DelegationList)
  934. {
  935. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  936. }
  937. #endregion
  938. var _view = new
  939. {
  940. PageFuncAuth = pageFunAuthView,
  941. Data = _DelegationList
  942. };
  943. return Ok(JsonView(true, "查询成功!", _view, total));
  944. }
  945. /// <summary>
  946. /// 接团信息详情
  947. /// </summary>
  948. /// <param name="dto">团组info请求dto</param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  953. {
  954. var groupData = await _groupRepository.GetGroupInfo(dto);
  955. if (groupData.Code != 0)
  956. {
  957. return Ok(JsonView(false, groupData.Msg));
  958. }
  959. return Ok(JsonView(groupData.Data));
  960. }
  961. /// <summary>
  962. /// 接团信息 编辑添加
  963. /// 基础信息数据源
  964. /// </summary>
  965. /// <param name="dto"></param>
  966. /// <returns></returns>
  967. [HttpPost]
  968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  969. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  970. {
  971. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  972. if (groupData.Code != 0)
  973. {
  974. return Ok(JsonView(false, groupData.Msg));
  975. }
  976. return Ok(JsonView(groupData.Data));
  977. }
  978. /// <summary>
  979. /// 成本修改团组信息
  980. /// </summary>
  981. /// <param name="dto"></param>
  982. /// <returns></returns>
  983. [HttpPost]
  984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  985. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  986. {
  987. var jw = JsonView(false, "操作失败");
  988. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  989. if (di == null)
  990. {
  991. jw.Msg = "参数有误!";
  992. return Ok(jw);
  993. }
  994. #region 添加出访起止时间
  995. var startTime = new DateTime();
  996. var endTime = new DateTime();
  997. if (DateTime.TryParse(dto.VisitDate, out startTime))
  998. {
  999. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1000. }
  1001. else
  1002. {
  1003. jw.Msg = "参数有误!";
  1004. return Ok(jw);
  1005. }
  1006. #endregion
  1007. di.VisitDate = startTime;
  1008. di.VisitPNumber = dto.VisitPNumber;
  1009. di.VisitDays = dto.VisitDays;
  1010. di.VisitStartDate = startTime;
  1011. di.VisitEndDate = endTime;
  1012. var count = _sqlSugar.Updateable(di)
  1013. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1014. .ExecuteCommand();
  1015. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1016. }
  1017. /// <summary>
  1018. /// 接团信息 编辑添加
  1019. /// 省份-城市 基础信息数据源
  1020. /// </summary>
  1021. /// <param name="dto"></param>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1026. {
  1027. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1028. string search = dto.Search;
  1029. var data = await _groupRepository.CityBasicSource();
  1030. int total = data.Length;
  1031. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1032. .Skip((pageIndex - 1) * pageSize)
  1033. .Take(pageSize)
  1034. .ToArray();
  1035. return Ok(JsonView(data, total));
  1036. }
  1037. /// <summary>
  1038. /// 接团信息 操作(增改)
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1045. {
  1046. // 创建 Stopwatch 实例
  1047. Stopwatch stopwatch = Stopwatch.StartNew();
  1048. decimal ffrPrice = 0.00M;
  1049. DateTime? visitDt = null;
  1050. if (dto.Status == 2)
  1051. {
  1052. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1053. if (groupInfo != null)
  1054. {
  1055. ffrPrice = groupInfo.PaymentMoney;
  1056. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1057. }
  1058. }
  1059. var groupData = await _groupRepository.GroupOperation(dto);
  1060. if (groupData.Code != 0)
  1061. {
  1062. return Ok(JsonView(false, groupData.Msg));
  1063. }
  1064. int diId = 0;
  1065. try
  1066. {
  1067. //添加时 默认加入团组汇率
  1068. if (dto.Status == 1) //添加
  1069. {
  1070. diId = groupData.Data;
  1071. //添加默认币种
  1072. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1073. //默认分配权限
  1074. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1075. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1076. var _managerIds = new List<int>() { 22, 32, 21 };
  1077. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1078. if (userIds.Count > 0)
  1079. {
  1080. userIds.Add(208);
  1081. //创建团组管控
  1082. GroupStepForDelegation.CreateWorkStep(diId);
  1083. //发送消息
  1084. string groupName = dto.TeamName;
  1085. string createGroupUser = string.Empty;
  1086. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1087. if (userInfo != null) createGroupUser = userInfo.CnName;
  1088. string title = $"系统通知";
  1089. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1090. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1091. }
  1092. //默认创建倒推表
  1093. await _invertedListRep._Create(dto.UserId, diId);
  1094. }
  1095. else if (dto.Status == 2)
  1096. {
  1097. diId = dto.Id;
  1098. }
  1099. #region 签证人员团组时间通知
  1100. #region 计算出访起止时间
  1101. var startTime = new DateTime();
  1102. var endTime = new DateTime();
  1103. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1104. {
  1105. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1106. }
  1107. #endregion
  1108. #endregion
  1109. #region 团组操作默认添加/修改收款账单
  1110. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1111. {
  1112. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1113. .Where(x => x.IsDel == 0 &&
  1114. x.Diid == diId &&
  1115. x.Remark.Equals("预付款")
  1116. )
  1117. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1118. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1119. .FirstAsync();
  1120. ffrInfo = new Fin_ForeignReceivables()
  1121. {
  1122. Diid = diId,
  1123. PriceName = dto.ClientUnit,
  1124. Price = dto.PaymentMoney,
  1125. Count = 1,
  1126. Unit = $"元",
  1127. ItemSumPrice = dto.PaymentMoney,
  1128. Rate = 1.0000M,
  1129. Currency = 836,
  1130. AddingWay = 0,
  1131. CreateUserId = dto.UserId,
  1132. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1133. Remark = $"预付款"
  1134. };
  1135. if (ffrInfo == null) //Add
  1136. {
  1137. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1138. }
  1139. else //修改
  1140. {
  1141. await _sqlSugar.Updateable(ffrInfo)
  1142. .UpdateColumns(x => new
  1143. {
  1144. x.PriceName,
  1145. x.Price,
  1146. x.ItemSumPrice,
  1147. x.CreateTime,
  1148. x.CreateUserId
  1149. })
  1150. .WhereColumns(x => x.Id)
  1151. .ExecuteCommandAsync();
  1152. }
  1153. }
  1154. #endregion
  1155. if (diId > 0)
  1156. {
  1157. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1158. }
  1159. // 停止计时
  1160. stopwatch.Stop();
  1161. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1162. }
  1163. catch (Exception ex)
  1164. {
  1165. // 停止计时
  1166. stopwatch.Stop();
  1167. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1168. Logs(ex.Message);
  1169. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1170. }
  1171. // 停止计时
  1172. stopwatch.Stop();
  1173. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1174. }
  1175. /// <summary>
  1176. /// 接团流程操作(增改)
  1177. /// 安卓端使用 建团时添加客户名单
  1178. /// </summary>
  1179. /// <param name="dto"></param>
  1180. /// <returns></returns>
  1181. [HttpPost]
  1182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1183. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1184. {
  1185. #region 参数验证
  1186. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1187. #region 页面操作权限验证
  1188. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1189. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1190. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1191. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1192. #endregion
  1193. #endregion
  1194. try
  1195. {
  1196. //_sqlSugar.BeginTran();
  1197. decimal ffrPrice = 0.00M;
  1198. DateTime? visitDt = null;
  1199. if (dto.Status == 2)
  1200. {
  1201. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1202. if (groupInfo != null)
  1203. {
  1204. ffrPrice = groupInfo.PaymentMoney;
  1205. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1206. }
  1207. }
  1208. var _dto = new GroupOperationDto();
  1209. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1210. var groupData = await _groupRepository.GroupOperation(_dto);
  1211. if (groupData.Code != 0)
  1212. {
  1213. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1214. }
  1215. int diId = 0;
  1216. //添加时 默认加入团组汇率
  1217. if (dto.Status == 1) //添加
  1218. {
  1219. diId = groupData.Data;
  1220. //添加默认币种
  1221. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1222. //默认分配权限
  1223. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1224. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1225. var _managerIds = new List<int>() { 21, 22, 32 };
  1226. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1227. if (userIds.Count > 0)
  1228. {
  1229. userIds.Add(208);
  1230. //创建团组管控
  1231. GroupStepForDelegation.CreateWorkStep(diId);
  1232. //发送消息
  1233. string groupName = dto.TeamName;
  1234. string createGroupUser = string.Empty;
  1235. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1236. if (userInfo != null) createGroupUser = userInfo.CnName;
  1237. string title = $"系统通知";
  1238. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1239. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1240. }
  1241. #region 应用推送
  1242. try
  1243. {
  1244. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1245. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1246. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1247. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1248. {
  1249. var userList = new List<string>() { users.QiyeChatUserId };
  1250. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1251. }
  1252. }
  1253. catch (Exception ex)
  1254. {
  1255. }
  1256. #endregion
  1257. //默认创建倒推表
  1258. await _invertedListRep._Create(dto.UserId, diId);
  1259. }
  1260. if (dto.Status == 2)
  1261. {
  1262. diId = dto.Id;
  1263. if (diId == 0)
  1264. {
  1265. //_sqlSugar.RollbackTran();
  1266. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1267. }
  1268. }
  1269. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1270. if (viewData.Code != 0)
  1271. {
  1272. //_sqlSugar.RollbackTran();
  1273. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1274. }
  1275. #region 团组操作默认添加/修改收款账单
  1276. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1277. {
  1278. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1279. .Where(x => x.IsDel == 0 &&
  1280. x.Diid == diId &&
  1281. x.Remark.Equals("预付款")
  1282. )
  1283. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1284. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1285. .FirstAsync();
  1286. ffrInfo = new Fin_ForeignReceivables()
  1287. {
  1288. Diid = diId,
  1289. PriceName = dto.ClientUnit,
  1290. Price = dto.PaymentMoney,
  1291. Count = 1,
  1292. Unit = $"元",
  1293. ItemSumPrice = dto.PaymentMoney,
  1294. Rate = 1.0000M,
  1295. Currency = 836,
  1296. AddingWay = 0,
  1297. CreateUserId = dto.UserId,
  1298. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1299. Remark = $"预付款"
  1300. };
  1301. if (ffrInfo == null) //Add
  1302. {
  1303. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1304. }
  1305. else //修改
  1306. {
  1307. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1308. .UpdateColumns(x => new
  1309. {
  1310. x.PriceName,
  1311. x.Price,
  1312. x.ItemSumPrice,
  1313. x.CreateTime,
  1314. x.CreateUserId
  1315. })
  1316. .WhereColumns(x => x.Id)
  1317. .ExecuteCommandAsync();
  1318. }
  1319. }
  1320. #endregion
  1321. #region 签证人员团组时间通知
  1322. #region 计算出访起止时间
  1323. var startTime = new DateTime();
  1324. var endTime = new DateTime();
  1325. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1326. {
  1327. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1328. }
  1329. #endregion
  1330. if (diId > 0)
  1331. {
  1332. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1333. }
  1334. #endregion
  1335. //_sqlSugar.CommitTran();
  1336. return Ok(JsonView(true, "添加成功"));
  1337. }
  1338. catch (Exception ex)
  1339. {
  1340. _sqlSugar.RollbackTran();
  1341. return Ok(JsonView(false, ex.Message));
  1342. }
  1343. }
  1344. /// <summary>
  1345. /// 接团流程操作(增改)
  1346. /// 安卓端使用 建团时添加客户名单
  1347. /// </summary>
  1348. /// <param name="dto"></param>
  1349. /// <returns></returns>
  1350. [HttpPost]
  1351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1352. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1353. {
  1354. #region 参数验证
  1355. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1356. #region 页面操作权限验证
  1357. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1358. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1359. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1360. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1361. #endregion
  1362. #endregion
  1363. _sqlSugar.BeginTran();
  1364. decimal ffrPrice = 0.00M;
  1365. DateTime? visitDt = null;
  1366. if (dto.Status == 2)
  1367. {
  1368. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1369. if (groupInfo != null)
  1370. {
  1371. ffrPrice = groupInfo.PaymentMoney;
  1372. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1373. }
  1374. }
  1375. var _dto = new GroupOperationDto();
  1376. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1377. var groupData = await _groupRepository.GroupOperation(_dto);
  1378. if (groupData.Code != 0)
  1379. {
  1380. _sqlSugar.RollbackTran();
  1381. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1382. }
  1383. try
  1384. {
  1385. int diId = 0;
  1386. //添加时 默认加入团组汇率
  1387. if (dto.Status == 1) //添加
  1388. {
  1389. diId = groupData.Data;
  1390. //添加默认币种
  1391. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1392. //默认分配权限
  1393. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1394. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1395. var _managerIds = new List<int>() { 21, 22, 32 };
  1396. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1397. if (userIds.Count > 0)
  1398. {
  1399. userIds.Add(208);
  1400. //创建团组管控
  1401. GroupStepForDelegation.CreateWorkStep(diId);
  1402. //发送消息
  1403. string groupName = dto.TeamName;
  1404. string createGroupUser = string.Empty;
  1405. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1406. if (userInfo != null) createGroupUser = userInfo.CnName;
  1407. string title = $"系统通知";
  1408. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1409. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1410. }
  1411. #region 应用推送
  1412. try
  1413. {
  1414. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1415. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1416. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1417. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1418. {
  1419. var userList = new List<string>() { users.QiyeChatUserId };
  1420. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1421. }
  1422. }
  1423. catch (Exception ex)
  1424. {
  1425. _sqlSugar.CommitTran();
  1426. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1427. }
  1428. #endregion
  1429. //默认创建倒推表
  1430. await _invertedListRep._Create(dto.UserId, diId);
  1431. }
  1432. else if (dto.Status == 2)
  1433. {
  1434. diId = dto.Id;
  1435. if (diId == 0)
  1436. {
  1437. _sqlSugar.RollbackTran();
  1438. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1439. }
  1440. }
  1441. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1442. if (viewData.Code != 0)
  1443. {
  1444. _sqlSugar.RollbackTran();
  1445. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1446. }
  1447. #region 团组操作默认添加/修改收款账单
  1448. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1449. {
  1450. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1451. .Where(x => x.IsDel == 0 &&
  1452. x.Diid == diId &&
  1453. x.Remark.Equals("预付款")
  1454. )
  1455. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1456. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1457. .FirstAsync();
  1458. ffrInfo = new Fin_ForeignReceivables()
  1459. {
  1460. Diid = diId,
  1461. PriceName = dto.ClientUnit,
  1462. Price = dto.PaymentMoney,
  1463. Count = 1,
  1464. Unit = $"元",
  1465. ItemSumPrice = dto.PaymentMoney,
  1466. Rate = 1.0000M,
  1467. Currency = 836,
  1468. AddingWay = 0,
  1469. CreateUserId = dto.UserId,
  1470. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1471. Remark = $"预付款"
  1472. };
  1473. if (ffrInfo == null) //Add
  1474. {
  1475. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1476. }
  1477. else //修改
  1478. {
  1479. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1480. .UpdateColumns(x => new
  1481. {
  1482. x.PriceName,
  1483. x.Price,
  1484. x.ItemSumPrice,
  1485. x.CreateTime,
  1486. x.CreateUserId
  1487. })
  1488. .WhereColumns(x => x.Id)
  1489. .ExecuteCommandAsync();
  1490. }
  1491. }
  1492. #endregion
  1493. #region 签证人员团组时间通知
  1494. #region 计算出访起止时间
  1495. var startTime = new DateTime();
  1496. var endTime = new DateTime();
  1497. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1498. {
  1499. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1500. }
  1501. #endregion
  1502. if (diId > 0)
  1503. {
  1504. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1505. }
  1506. #endregion
  1507. _sqlSugar.CommitTran();
  1508. return Ok(JsonView(true));
  1509. }
  1510. catch (Exception ex)
  1511. {
  1512. _sqlSugar.RollbackTran();
  1513. return Ok(JsonView(false, ex.Message));
  1514. }
  1515. }
  1516. /// <summary>
  1517. /// 接团信息 操作(删除)
  1518. /// </summary>
  1519. /// <param name="dto"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1524. {
  1525. var diId = dto.Id;
  1526. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1527. #region 删除 验证
  1528. /*
  1529. * 1、收款账单数据:0 条
  1530. * 2、收款退还数据:0 条
  1531. * 3、机票费用数据:0 条
  1532. * 4、签证费用数据:0 条
  1533. * 5、保险费用数据:0 条
  1534. * 6、酒店费用数据:0 条
  1535. * 7、公务出访数据:1 条
  1536. * 8、邀请公务活动费用数据:1 条
  1537. * 9、OP费用数据:5 条
  1538. * 10、其他费用数据:0 条
  1539. * 11、团组日付报销费用数据:0 条
  1540. *
  1541. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1542. */
  1543. //收款账单
  1544. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1545. //收款退还
  1546. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1547. //机票费用
  1548. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1549. //签证费用
  1550. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1551. //保险费用
  1552. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1553. //酒店费用
  1554. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1555. //公务出访
  1556. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1557. //邀请公务活动费用
  1558. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1559. //OP费用
  1560. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1561. //其他费用
  1562. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1563. //团组日付报销费用
  1564. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1565. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1566. if (feeCount > 0)
  1567. {
  1568. var delMsgTips = new StringBuilder();
  1569. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1570. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1571. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1572. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1573. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1574. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1575. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1576. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1577. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1578. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1579. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1580. delMsgTips.AppendLine($"");
  1581. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1582. return Ok(JsonView(false, delMsgTips.ToString()));
  1583. }
  1584. #endregion
  1585. var groupData = await _groupRepository.GroupDel(dto);
  1586. if (groupData.Code != 0)
  1587. {
  1588. return Ok(JsonView(false, groupData.Msg));
  1589. }
  1590. return Ok(JsonView(true));
  1591. }
  1592. /// <summary>
  1593. /// 获取团组销售报价号
  1594. /// 团组添加时 使用
  1595. /// </summary>
  1596. /// <returns></returns>
  1597. [HttpPost]
  1598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1599. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1600. {
  1601. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1602. if (groupData.Code != 0)
  1603. {
  1604. return Ok(JsonView(false, groupData.Msg));
  1605. }
  1606. object salesQuoteNo = new
  1607. {
  1608. SalesQuoteNo = groupData.Data
  1609. };
  1610. return Ok(JsonView(salesQuoteNo));
  1611. }
  1612. /// <summary>
  1613. /// 设置确认出团
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1620. {
  1621. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1622. if (groupData.Code != 0)
  1623. {
  1624. return Ok(JsonView(false, groupData.Msg));
  1625. }
  1626. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1627. #region OA消息推送
  1628. try
  1629. {
  1630. string groupName = groupInfo.TeamName;
  1631. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1632. string title = $"系统通知";
  1633. string content = $"团组[{groupName}]已确认出团!";
  1634. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1635. }
  1636. catch (Exception ex)
  1637. {
  1638. }
  1639. #endregion
  1640. #region 应用推送
  1641. try
  1642. {
  1643. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1644. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1645. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1646. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1647. {
  1648. var userList = new List<string>() { users.QiyeChatUserId };
  1649. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1650. }
  1651. }
  1652. catch (Exception ex)
  1653. {
  1654. }
  1655. #endregion
  1656. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1657. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1658. }
  1659. /// <summary>
  1660. /// 获取团组名称data And 签证国别Data
  1661. /// </summary>
  1662. /// <param name="dto"></param>
  1663. /// <returns></returns>
  1664. [HttpPost]
  1665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1666. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1667. {
  1668. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1669. if (groupData.Code != 0)
  1670. {
  1671. return Ok(JsonView(false, groupData.Msg));
  1672. }
  1673. return Ok(JsonView(groupData.Data));
  1674. }
  1675. /// <summary>
  1676. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1677. /// </summary>
  1678. /// <returns></returns>
  1679. [HttpPost]
  1680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1681. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1682. {
  1683. try
  1684. {
  1685. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1686. if (groupData.Code != 0)
  1687. {
  1688. return Ok(JsonView(false, groupData.Msg));
  1689. }
  1690. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1691. }
  1692. catch (Exception ex)
  1693. {
  1694. return Ok(JsonView(false, ex.Message));
  1695. throw;
  1696. }
  1697. }
  1698. /// <summary>
  1699. /// 团组清单 Excel
  1700. /// </summary>
  1701. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1702. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1703. /// <returns></returns>
  1704. [HttpGet]
  1705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1706. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1707. {
  1708. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1709. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1710. if (!beginBool && !endBool)
  1711. {
  1712. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1713. }
  1714. string sql = string.Format(@"
  1715. SELECT
  1716. ROW_NUMBER,
  1717. Id,
  1718. SalesQuoteNo,
  1719. TourCode,
  1720. TeamTypeId,
  1721. TeamType,
  1722. TeamLevId,
  1723. TeamLev,
  1724. TeamName,
  1725. ClientName,
  1726. ClientUnit,
  1727. VisitDate,
  1728. VisitDays,
  1729. VisitPNumber,
  1730. JietuanOperatorId,
  1731. JietuanOperator,
  1732. IsSure,
  1733. CreateUserName,
  1734. IsBid
  1735. FROM
  1736. (
  1737. SELECT
  1738. ROW_NUMBER() OVER(
  1739. ORDER BY
  1740. gdi.VisitDate Desc
  1741. ) AS ROW_NUMBER,
  1742. gdi.Id,
  1743. SalesQuoteNo,
  1744. TourCode,
  1745. ssd.Id TeamTypeId,
  1746. ssd.Name TeamType,
  1747. ssd1.Id TeamLevId,
  1748. ssd1.Name TeamLev,
  1749. TeamName,
  1750. ClientName,
  1751. ClientUnit,
  1752. VisitDate,
  1753. VisitDays,
  1754. VisitPNumber,
  1755. JietuanOperator JietuanOperatorId,
  1756. su.CnName JietuanOperator,
  1757. IsSure,
  1758. gdi.CreateTime,
  1759. su1.CnName As CreateUserName,
  1760. gdi.IsBid
  1761. FROM
  1762. Grp_DelegationInfo gdi
  1763. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1764. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1765. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1766. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1767. WHERE
  1768. gdi.IsDel = 0
  1769. AND gdi.IsBid = 0
  1770. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1771. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1772. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1773. #region 处理所属部门
  1774. /*
  1775. * 1.sq 和 gyy 等显示 市场部
  1776. * 2.王鸽和主管及张总还有管理员号统一国交部
  1777. * 2-1. 4 管理员 ,21 张海麟
  1778. */
  1779. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1780. var userIds1 = new List<int>() { 4, 21 };
  1781. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1782. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1783. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1784. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1785. .ToListAsync();
  1786. var droupIds = groupList.Select(it => it.Id).ToList();
  1787. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1788. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1789. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1790. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1791. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1792. {
  1793. DiId = tcl.DiId,
  1794. LastName = dc.LastName,
  1795. FirstName = dc.FirstName,
  1796. Sex = dc.Sex,
  1797. Birthday = dc.BirthDay,
  1798. Company = cc.CompanyFullName,
  1799. Job = dc.Job,
  1800. CreateTime = tcl.CreateTime,
  1801. })
  1802. .ToList();
  1803. foreach (var item in groupList)
  1804. {
  1805. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1806. string groupFirstName = "";
  1807. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1808. if (currDatas.Any())
  1809. {
  1810. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1811. }
  1812. item.GroupFirst = groupFirstName;
  1813. }
  1814. #endregion
  1815. #region Excel
  1816. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1817. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1818. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1819. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1820. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  1821. //载入模板
  1822. var designer = new WorkbookDesigner
  1823. {
  1824. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  1825. };
  1826. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1827. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1828. dt.TableName = "GroupList";
  1829. designer.SetDataSource(dt);
  1830. designer.Process();
  1831. if (!Directory.Exists(savePath))
  1832. {
  1833. Directory.CreateDirectory(savePath);
  1834. }
  1835. string serverPath = $"{savePath}{fileName}";
  1836. designer.Workbook.Save(serverPath);
  1837. string rst = $"{servicePath}{ftpPath}{fileName}";
  1838. #endregion
  1839. return Ok(JsonView(true, "操作成功!", rst));
  1840. }
  1841. /// <summary>
  1842. /// 团组合同下载(1.付款80% 2.付全款)
  1843. /// </summary>
  1844. /// <param name="dto"></param>
  1845. /// <returns></returns>
  1846. /// <exception cref="Exception"></exception>
  1847. [HttpPost]
  1848. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1849. {
  1850. var jw = JsonView(false);
  1851. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1852. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1853. if (di == null)
  1854. {
  1855. jw.Msg = "团组Id有误!";
  1856. return Ok(jw);
  1857. }
  1858. #region 权限校验
  1859. var allDownFile = new List<int>() { 21 };
  1860. try
  1861. {
  1862. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1863. .First(x => x.Id == 1418 && x.IsDel == 0);
  1864. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1865. }
  1866. catch (Exception)
  1867. { }
  1868. var guojiaoDownFile = new List<int>() { 330, 383 };
  1869. var shichangDownFile = new List<int>() { 95 };
  1870. if (allDownFile.Contains(dto.UserId))
  1871. {
  1872. }
  1873. else if (guojiaoDownFile.Contains(dto.UserId))
  1874. {
  1875. var guojiaobuDi = new List<int>() { 4, 21 };
  1876. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1877. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1878. .Where((d, u) => u.Id == di.JietuanOperator)
  1879. .Select((d, u) => d.DepName)
  1880. .First();
  1881. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1882. {
  1883. jw.Msg = "暂无下载权限!";
  1884. return Ok(jw);
  1885. }
  1886. }
  1887. else if (shichangDownFile.Contains(dto.UserId))
  1888. {
  1889. var dic = new Dictionary<int, int[]>()
  1890. {
  1891. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1892. };
  1893. try
  1894. {
  1895. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1896. if (sqSetting != null)
  1897. {
  1898. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1899. foreach (var item in result.Keys)
  1900. {
  1901. if (dic.ContainsKey(item))
  1902. {
  1903. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1904. Array.Copy(dic[item], dilatation, dic[item].Length);
  1905. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1906. dic[item] = dilatation;
  1907. }
  1908. else
  1909. {
  1910. dic.Add(item, result[item]);
  1911. }
  1912. }
  1913. }
  1914. if (!dic[95].Contains(di.CreateUserId))
  1915. {
  1916. jw.Msg = "暂无下载权限!";
  1917. return Ok(jw);
  1918. }
  1919. }
  1920. catch (Exception)
  1921. { }
  1922. }
  1923. else if (dto.UserId == di.CreateUserId)
  1924. {
  1925. }
  1926. else
  1927. {
  1928. jw.Msg = "暂无下载权限!";
  1929. return Ok(jw);
  1930. }
  1931. #endregion
  1932. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1933. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1934. .ToListAsync();
  1935. if (!blackCodeList.Any())
  1936. {
  1937. jw.Msg = "该团无机票行程代码!";
  1938. return Ok(jw);
  1939. }
  1940. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1941. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1942. if (groupEnterExitCost == null)
  1943. {
  1944. jw.Msg = "暂无三公费用信息!";
  1945. return Ok(jw);
  1946. }
  1947. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1948. rateList ??= new List<CurrencyInfo>();
  1949. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1950. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1951. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1952. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1953. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1954. .Select((x, a, b) => new
  1955. {
  1956. x.Index,
  1957. itemName = a.Name,
  1958. CurrencyStr = b.Name,
  1959. x.Cost,
  1960. x.SubTotal,
  1961. x.Remark
  1962. })
  1963. .OrderBy((x) => x.Index)
  1964. .ToList();
  1965. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1966. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1967. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1968. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1969. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1970. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1971. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1972. decimal subJJC = 0.00M,
  1973. subGWC = 0.00M,
  1974. subTDC = 0.00M;
  1975. //经济舱
  1976. if (groupEnterExitCost.SumJJC == 1)
  1977. {
  1978. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1979. }
  1980. //公务舱
  1981. if (groupEnterExitCost.SumGWC == 1)
  1982. {
  1983. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1984. }
  1985. //头等舱
  1986. if (groupEnterExitCost.SumTDC == 1)
  1987. {
  1988. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1989. }
  1990. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1991. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1992. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1993. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1994. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1995. .Select((x, s, dc, cc) => new GroupClints
  1996. {
  1997. Id = x.Id,
  1998. Name = s.Name,
  1999. IsAccompany = x.IsAccompany,
  2000. CompanyFullName = cc.CompanyFullName
  2001. })
  2002. .ToListAsync();
  2003. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2004. //获取舱位人数
  2005. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2006. .GroupBy(x => x.Name)
  2007. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2008. .ToList();
  2009. string cityPath = string.Empty;
  2010. string startCity = string.Empty;
  2011. string endCity = string.Empty;
  2012. foreach (var item in blackCodeList)
  2013. {
  2014. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2015. cityPath += city + "\r\n";
  2016. if (item.Equals(blackCodeList.First()))
  2017. {
  2018. var sp = city.Split('-');
  2019. startCity = sp[0];
  2020. endCity = sp[^1];
  2021. }
  2022. }
  2023. var bookMarkDic = new Dictionary<string, string>
  2024. {
  2025. { "ClientUnit", di.ClientUnit },
  2026. { "VisitCountry", di.VisitCountry },
  2027. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2028. { "VisitPNumber", di.VisitPNumber.ToString() },
  2029. { "CityPath", cityPath },
  2030. { "StartCity", startCity },
  2031. { "EndCity", endCity },
  2032. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2033. };
  2034. Document doc = null;
  2035. var percentage = 0.8M;
  2036. var fileNameadd = "预付";
  2037. if (dto.FileType == 1)
  2038. {
  2039. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2040. }
  2041. else if (dto.FileType == 2)
  2042. {
  2043. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2044. percentage = 1;
  2045. fileNameadd = "全款";
  2046. }
  2047. else
  2048. {
  2049. throw new Exception("FileType有误!");
  2050. }
  2051. var builder = new DocumentBuilder(doc);
  2052. decimal totalPrice = 0.00M;
  2053. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2054. if (firstTable != null)
  2055. {
  2056. // 遍历表格的行和单元格
  2057. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2058. {
  2059. for (int i = 0; i < row.Cells.Count; i++)
  2060. {
  2061. var cell = row.Cells[i];
  2062. // 读取单元格内容
  2063. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2064. if (cellTextFirst.Contains("舱位"))
  2065. {
  2066. break;
  2067. }
  2068. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2069. {
  2070. if (i == 2)
  2071. {
  2072. if (cellTextFirst == "经济舱")
  2073. {
  2074. // 设置单元格内容
  2075. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2076. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2077. }
  2078. else
  2079. {
  2080. // 设置单元格内容
  2081. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2082. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2083. }
  2084. }
  2085. if (i == 3)
  2086. {
  2087. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2088. if (count != null)
  2089. {
  2090. // 设置单元格内容
  2091. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2092. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2093. }
  2094. }
  2095. if (i == 4)
  2096. {
  2097. var rowPrice = 0.00M;
  2098. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2099. count ??= 0;
  2100. if (cellTextFirst == "经济舱")
  2101. {
  2102. rowPrice = subJJC * (int)count;
  2103. }
  2104. else
  2105. {
  2106. rowPrice = subGWC * (int)count;
  2107. }
  2108. totalPrice += rowPrice;
  2109. // 设置单元格内容
  2110. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2111. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2112. }
  2113. }
  2114. }
  2115. }
  2116. }
  2117. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2118. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2119. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2120. //--合同表格部分
  2121. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2122. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2123. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2124. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2125. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2126. bookMarkDic.Add("CityPath1", cityPath);
  2127. bookMarkDic.Add("CityPath2", cityPath);
  2128. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2129. if (contractTable != null)
  2130. {
  2131. //数据源
  2132. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2133. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2134. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2135. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2136. .Select((it, y, s) => new
  2137. {
  2138. it.Cost,
  2139. it.SubTotal,
  2140. it.Type,
  2141. y.Id,
  2142. y.City,
  2143. s.Name,
  2144. CurrencyCodeCn = s.Remark
  2145. })
  2146. .ToList()
  2147. .Select(x => new
  2148. {
  2149. CurrencyCode = x.Name,
  2150. CityId = x.Id,
  2151. x.City,
  2152. di.VisitPNumber,
  2153. x.Type,
  2154. x.Cost,
  2155. x.SubTotal,
  2156. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2157. x.CurrencyCodeCn,
  2158. });
  2159. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2160. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2161. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2162. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2163. var tableSettings = new List<tableSetting>()
  2164. {
  2165. new(){ Index = 1 , Property = "City"},
  2166. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2167. new(){ Index = 3 , Property = "Cost"},
  2168. new(){ Index = 4 , Property = "VisitPNumber"},
  2169. //new tableSetting{ Index = 5 , Property = ""},
  2170. //new tableSetting{ Index = 6 , Property = ""},
  2171. new(){ Index = 7 , Property = "Rate"},
  2172. //new tableSetting{ Index = 8 , Property = ""},
  2173. };
  2174. //1.住宿费
  2175. int cloneRow = 8;
  2176. int startDayPrice = 8; //写入index
  2177. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2178. foreach (var dac in dac1)
  2179. {
  2180. var first = dac.First();
  2181. var dayCount = dac.Count();
  2182. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2183. for (int i = 1; i < row.Cells.Count; i++)
  2184. {
  2185. var cell = row.Cells[i];
  2186. var findProperty = tableSettings.Find(x => x.Index == i);
  2187. if (findProperty != null)
  2188. {
  2189. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2190. // 设置单元格内容
  2191. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2192. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2193. }
  2194. else
  2195. {
  2196. switch (i)
  2197. {
  2198. case 5:
  2199. cell.FirstParagraph.Runs.Clear();
  2200. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2201. break;
  2202. case 6:
  2203. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2204. cell.FirstParagraph.Runs.Clear();
  2205. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2206. break;
  2207. case 8:
  2208. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2209. cell.FirstParagraph.Runs.Clear();
  2210. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2211. ZSPriceSum += xiaojiRMB;
  2212. break;
  2213. default:
  2214. break;
  2215. }
  2216. }
  2217. }
  2218. startDayPrice++;
  2219. if (!dac1.Last().Equals(dac))
  2220. {
  2221. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2222. // 将克隆的行追加到原行后面
  2223. contractTable.Rows.Insert(startDayPrice, newRow);
  2224. }
  2225. else
  2226. {
  2227. cloneRow += dac1.Count + 1;
  2228. startDayPrice = cloneRow;
  2229. }
  2230. }
  2231. //2.伙食费
  2232. foreach (var dac in dac2)
  2233. {
  2234. var first = dac.First();
  2235. var dayCount = dac.Count();
  2236. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2237. for (int i = 1; i < row.Cells.Count; i++)
  2238. {
  2239. var cell = row.Cells[i];
  2240. var findProperty = tableSettings.Find(x => x.Index == i);
  2241. if (findProperty != null)
  2242. {
  2243. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2244. // 设置单元格内容
  2245. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2246. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2247. }
  2248. else
  2249. {
  2250. switch (i)
  2251. {
  2252. case 5:
  2253. cell.FirstParagraph.Runs.Clear();
  2254. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2255. break;
  2256. case 6:
  2257. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2258. cell.FirstParagraph.Runs.Clear();
  2259. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2260. break;
  2261. case 8:
  2262. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2263. cell.FirstParagraph.Runs.Clear();
  2264. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2265. HSPriceSum += xiaojiRMB;
  2266. break;
  2267. default:
  2268. break;
  2269. }
  2270. }
  2271. }
  2272. startDayPrice++;
  2273. if (!dac2.Last().Equals(dac))
  2274. {
  2275. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2276. // 将克隆的行追加到原行后面
  2277. contractTable.Rows.Insert(startDayPrice, newRow);
  2278. }
  2279. else
  2280. {
  2281. cloneRow += dac2.Count + 1;
  2282. startDayPrice = cloneRow;
  2283. }
  2284. }
  2285. //3.公杂费
  2286. foreach (var dac in dac3)
  2287. {
  2288. var first = dac.First();
  2289. var dayCount = dac.Count();
  2290. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2291. for (int i = 1; i < row.Cells.Count; i++)
  2292. {
  2293. var cell = row.Cells[i];
  2294. var findProperty = tableSettings.Find(x => x.Index == i);
  2295. if (findProperty != null)
  2296. {
  2297. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2298. // 设置单元格内容
  2299. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2300. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2301. }
  2302. else
  2303. {
  2304. switch (i)
  2305. {
  2306. case 5:
  2307. cell.FirstParagraph.Runs.Clear();
  2308. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2309. break;
  2310. case 6:
  2311. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2312. cell.FirstParagraph.Runs.Clear();
  2313. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2314. break;
  2315. case 8:
  2316. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2317. cell.FirstParagraph.Runs.Clear();
  2318. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2319. GZPriceSum += xiaojiRMB;
  2320. break;
  2321. default:
  2322. break;
  2323. }
  2324. }
  2325. }
  2326. startDayPrice++;
  2327. if (!dac3.Last().Equals(dac))
  2328. {
  2329. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2330. // 将克隆的行追加到原行后面
  2331. contractTable.Rows.Insert(startDayPrice, newRow);
  2332. }
  2333. else
  2334. {
  2335. cloneRow += dac3.Count + 1;
  2336. startDayPrice = cloneRow;
  2337. }
  2338. }
  2339. //合并单元格
  2340. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2341. {
  2342. var currentRow = contractTable.Rows[i];
  2343. var nextRow = contractTable.Rows[i + 1];
  2344. // 获取当前行和下一行的第一个单元格
  2345. Cell currentCell = currentRow.Cells[0];
  2346. Cell nextCell = nextRow.Cells[0];
  2347. // 检查单元格内容是否一致(去除尾部的换行符)
  2348. string currentText = currentCell.GetText().Trim();
  2349. string nextText = nextCell.GetText().Trim();
  2350. if (currentText == nextText)
  2351. {
  2352. // 如果当前单元格已经被合并,找到合并的起始单元格
  2353. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2354. {
  2355. // 找到合并的起始单元格
  2356. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2357. // 将下一行的单元格设置为合并的后续单元格
  2358. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2359. }
  2360. else
  2361. {
  2362. // 如果当前单元格是合并的起始单元格
  2363. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2364. // 将下一行的单元格设置为合并的后续单元格
  2365. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2366. }
  2367. }
  2368. else
  2369. {
  2370. // 如果内容不一致,重置当前单元格的合并属性
  2371. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2372. {
  2373. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2374. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2375. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2376. }
  2377. else
  2378. {
  2379. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2380. }
  2381. }
  2382. }
  2383. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2384. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2385. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2386. }
  2387. foreach (var bookmarkName in bookMarkDic.Keys)
  2388. {
  2389. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2390. if (bookmark != null)
  2391. {
  2392. if (bookmarkName == "ClientUnit")
  2393. {
  2394. // 移动到书签位置
  2395. builder.MoveTo(bookmark.BookmarkStart);
  2396. // 设置字体样式为下划线
  2397. builder.Font.Underline = Aspose.Words.Underline.Single;
  2398. // 插入书签值
  2399. builder.Write(bookMarkDic[bookmarkName]);
  2400. // 清除字体格式,避免影响后续文本
  2401. builder.Font.ClearFormatting();
  2402. }
  2403. else
  2404. {
  2405. builder.MoveToBookmark(bookmarkName);
  2406. builder.Write(bookMarkDic[bookmarkName]);
  2407. }
  2408. }
  2409. }
  2410. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2411. doc.Save(savePaht);
  2412. jw.Msg = "生成成功!";
  2413. jw.Code = 200;
  2414. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2415. return Ok(jw);
  2416. }
  2417. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2418. {
  2419. int index = rowIndex;
  2420. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2421. {
  2422. index--;
  2423. }
  2424. return index;
  2425. }
  2426. /// <summary>
  2427. /// 报批完成企微通知
  2428. /// </summary>
  2429. /// <param name="dto"></param>
  2430. /// <returns></returns>
  2431. [HttpPost]
  2432. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2433. {
  2434. int currUserId = dto.currUserId;
  2435. int diid = dto.diid;
  2436. var jw = JsonView(true);
  2437. var users = new List<string>();
  2438. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2439. .First(x => x.Id == 1460);
  2440. try
  2441. {
  2442. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2443. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2444. //添加分配人员
  2445. // 79 车/导游地接
  2446. // 80 签证
  2447. // 81 邀请/公务活动
  2448. var setdataids = new List<int>() { 79, 81 };
  2449. // 27 商邀
  2450. // 28 OP
  2451. var jobSetdataids = new List<int>() { 27, 28 };
  2452. var q = _sqlSugar.Queryable<Grp_GroupsTaskAssignment, Sys_Users>(
  2453. (ccta, su) => new JoinQueryInfos(
  2454. JoinType.Left, ccta.UId == su.Id && su.IsDel == 0))
  2455. .Where((ccta, su) =>
  2456. ccta.IsDel == 0 &&
  2457. ccta.DIId == dto.diid &&
  2458. jobSetdataids.Contains(su.JobPostId) &&
  2459. setdataids.Contains(ccta.CTId))
  2460. .Select((ccta, su) => new
  2461. {
  2462. userid = su.Id,
  2463. su.JobPostId,
  2464. ccta.CTId,
  2465. ccta.DIId,
  2466. su.CnName,
  2467. });
  2468. var qtb = q.ToDataTable();
  2469. foreach (var groupModule in groupModuleOperators)
  2470. {
  2471. if (setdataids.Contains(groupModule.CTableId) && !groupModule.OperationUsers.Any())
  2472. {
  2473. var qtbUsers = qtb.AsEnumerable().
  2474. Where(x => x.Field<int>("CTId") == groupModule.CTableId).
  2475. Select(x => x.Field<int>("userid")).ToList();
  2476. groupModule.OperationUsers = qtbUsers.Select(x => new GeneralMethod.GroupOperationUserInfo()
  2477. {
  2478. UserId = x,
  2479. UserName = qtb.AsEnumerable().FirstOrDefault(y => y.Field<int>("userid") == x)?.Field<string>("CnName") ?? ""
  2480. }).ToList();
  2481. }
  2482. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2483. }
  2484. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2485. //消息通知成功 更改团组step、记录日志
  2486. if (res)
  2487. {
  2488. var groupStep = 0; //0-新建 1-企微消息通知
  2489. //更改团组step
  2490. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2491. .SetColumns(x => new Grp_DelegationInfo()
  2492. {
  2493. Step = 2
  2494. })
  2495. .Where(x => x.Id == diid && x.IsDel == 0)
  2496. .ExecuteCommandAsync();
  2497. if (updStatus > 0) groupStep = 2;
  2498. string groupStepLabel = groupStep switch
  2499. {
  2500. 1 => "新建",
  2501. 2 => "企微消息通知(报批)",
  2502. _ => "未设置"
  2503. };
  2504. //记录日志
  2505. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2506. .Where(x => x.Id == diid && x.IsDel == 0)
  2507. .Select(x => x.TeamName)
  2508. .First() ?? "-";
  2509. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2510. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2511. .Select(x => x.CnName)
  2512. .First() ?? "-";
  2513. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2514. }
  2515. }
  2516. catch (Exception ex)
  2517. {
  2518. return Ok(JsonView(false, ex.Message));
  2519. }
  2520. return Ok(jw);
  2521. }
  2522. #endregion
  2523. #region 团组&签证
  2524. #region 团组&签证 New
  2525. /// <summary>
  2526. /// 团组&签证 New
  2527. /// DeepSeek API:测试API连通性
  2528. /// </summary>
  2529. /// <param name="file">请求dto</param>
  2530. /// <returns></returns>
  2531. [HttpPost]
  2532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2533. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2534. {
  2535. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2536. }
  2537. /// <summary>
  2538. /// 团组&签证 New
  2539. /// DeepSeek API:检查可用端点
  2540. /// </summary>
  2541. /// <param name="file">请求dto</param>
  2542. /// <returns></returns>
  2543. [HttpPost]
  2544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2545. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2546. {
  2547. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2548. }
  2549. /// <summary>
  2550. /// 团组&签证 New
  2551. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2552. /// </summary>
  2553. /// <param name="file">请求dto</param>
  2554. /// <returns></returns>
  2555. [HttpPost]
  2556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2557. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2558. {
  2559. //文件验证
  2560. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2561. //var visaFiles = new VisaUploadFileTypeView();
  2562. var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2563. if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2564. //服务器存储文件
  2565. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2566. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2567. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2568. using (var stream = new FileStream(filePath, FileMode.Create))
  2569. {
  2570. await visaFile.CopyToAsync(stream);
  2571. }
  2572. //日志记录-上传文件
  2573. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2574. IFormFile localFile = null;
  2575. //获取项目中的cs文件
  2576. try
  2577. {
  2578. _logger.LogInformation("读取并上传项目文件请求");
  2579. // 1. 读取项目文件
  2580. var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2581. if (readResponse.SuccessCount == 0)
  2582. {
  2583. return Ok(JsonView(false, "读取项目文件失败"));
  2584. }
  2585. localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2586. }
  2587. catch (Exception ex)
  2588. {
  2589. _logger.LogError(ex, "读取项目文件失败");
  2590. return Ok(JsonView(false, "读取项目文件失败"));
  2591. }
  2592. if (localFile == null)
  2593. {
  2594. return Ok(JsonView(false, "读取项目文件失败"));
  2595. }
  2596. var fileReq = new DeepSeekFileUploadRequest()
  2597. {
  2598. Files = new List<IFormFile> { localFile, visaFile },
  2599. };
  2600. var filesResult = new List<FileUploadResult>();
  2601. #region 上传文件到DeepSeekAPI
  2602. try
  2603. {
  2604. _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2605. filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2606. // 需要等待处理完成
  2607. if (fileReq.WaitForProcessing)
  2608. {
  2609. foreach (var result in filesResult)
  2610. {
  2611. if (result.Success)
  2612. {
  2613. try
  2614. {
  2615. var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2616. result.Status = processedFile.Status;
  2617. }
  2618. catch (Exception ex)
  2619. {
  2620. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2621. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2622. }
  2623. }
  2624. }
  2625. }
  2626. }
  2627. catch (Exception ex)
  2628. {
  2629. _logger.LogError(ex, "DeepSeek API文件上传失败");
  2630. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2631. }
  2632. #endregion
  2633. if (filesResult == null || filesResult.Count < 1)
  2634. {
  2635. return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2636. }
  2637. //
  2638. try
  2639. {
  2640. var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2641. _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2642. string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2643. var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2644. return Ok(response);
  2645. }
  2646. catch (Exception ex)
  2647. {
  2648. _logger.LogError(ex, "使用文件聊天失败");
  2649. return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2650. }
  2651. //加载文件OpCarTouristGuideGroundContent
  2652. ////kimi AI 识别文档返回json结果
  2653. //int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2654. //var KiMiApi = new KiMiApiClient();
  2655. //var files = new List<IFormFile>() { file };
  2656. //var seedConter = await KiMiApi.UploadFilesAsync(files);
  2657. //if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2658. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2659. //var messages = new List<SeedMessages>
  2660. //{
  2661. // new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2662. // new() { Role = KimiRole.user, Content = seedMessage }
  2663. //};
  2664. //messages.InsertRange(1, seedConter);
  2665. string jsonString = string.Empty;
  2666. //bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2667. //while (!isJson)
  2668. //{
  2669. // kimiAI_API_Index++;
  2670. // var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2671. // var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2672. // jsonString += kimiApiResult_JObject["content"].ToString();
  2673. // string startStr = "```json", endStr = "```";
  2674. // // 判断并清除开头部分
  2675. // if (jsonString.StartsWith(startStr))
  2676. // {
  2677. // jsonString = jsonString.Replace(startStr, "");
  2678. // }
  2679. // // 判断并清除结尾部分
  2680. // if (jsonString.EndsWith(endStr))
  2681. // {
  2682. // jsonString = jsonString.Replace(endStr, "");
  2683. // }
  2684. // //验证json格式是否正确
  2685. // try
  2686. // {
  2687. // JsonDocument.Parse(jsonString);
  2688. // isJson = true; // 如果解析成功,则是json格式
  2689. // }
  2690. // catch (Exception)
  2691. // {
  2692. // //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2693. // messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2694. // }
  2695. //}
  2696. //var clientInfo = new Crm_DeleClient(); //客户资料表
  2697. //var clientFamily = new Crm_VisaCustomerFamily(); //客户家庭表
  2698. //var clientCompany = new Crm_CustomerCompany(); //客户公司表
  2699. //var clientCert = new Crm_CustomerCert(); //客户证件表
  2700. //var clientSchool = new Crm_VisaCustomerSchool(); //客户学历表
  2701. ////按照表格类型分别进行参数处理
  2702. //switch (fileTypeId)
  2703. //{
  2704. // //澳新签证个人申请表
  2705. // case 1:
  2706. // _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2707. // VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2708. // break;
  2709. // default:
  2710. // break;
  2711. //}
  2712. return Ok(JsonView(true, jsonString));
  2713. }
  2714. private int GetSuccessCount(List<FileUploadResult> results)
  2715. {
  2716. var count = 0;
  2717. foreach (var result in results)
  2718. {
  2719. if (result.Success) count++;
  2720. }
  2721. return count;
  2722. }
  2723. #endregion
  2724. /// <summary>
  2725. /// 根据团组Id获取签证客户信息List
  2726. /// </summary>
  2727. /// <param name="dto">请求dto</param>
  2728. /// <returns></returns>
  2729. [HttpPost]
  2730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2731. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2732. {
  2733. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2734. if (groupData.Code != 0)
  2735. {
  2736. return Ok(JsonView(false, groupData.Msg));
  2737. }
  2738. return Ok(JsonView(groupData.Data));
  2739. }
  2740. /// <summary>
  2741. /// IOS获取团组签证拍照上传进度01(团组列表)
  2742. /// </summary>
  2743. /// <param name="dto">请求dto</param>
  2744. /// <returns></returns>
  2745. [HttpPost]
  2746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2747. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2748. {
  2749. if (dto == null)
  2750. {
  2751. return Ok(JsonView(false, "参数为空"));
  2752. }
  2753. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2754. return Ok(JsonView(visaList));
  2755. }
  2756. /// <summary>
  2757. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2758. /// </summary>
  2759. /// <returns></returns>
  2760. [HttpPost]
  2761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2762. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2763. {
  2764. if (dto == null)
  2765. {
  2766. return Ok(JsonView(false, "请求错误:"));
  2767. }
  2768. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2769. return Ok(JsonView(list));
  2770. }
  2771. /// <summary>
  2772. /// IOS获取团组签证拍照上传进度03(相册)
  2773. /// </summary>
  2774. /// <returns></returns>
  2775. [HttpPost]
  2776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2777. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2778. {
  2779. if (dto == null)
  2780. {
  2781. return Ok(JsonView(false, "请求错误:"));
  2782. }
  2783. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2784. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2785. list.ForEach(s => s.url = url);
  2786. return Ok(JsonView(list));
  2787. }
  2788. /// <summary>
  2789. /// IOS获取团组签证拍照上传进度04(图片上传)
  2790. /// </summary>
  2791. /// <param name="dto"></param>
  2792. /// <returns></returns>
  2793. [HttpPost]
  2794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2795. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2796. {
  2797. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2798. //if (!string.IsNullOrEmpty(result))
  2799. //{
  2800. //}
  2801. //else {
  2802. // return Ok(JsonView(false, "上传失败"));
  2803. //}
  2804. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2805. int sucNum = 0;
  2806. try
  2807. {
  2808. foreach (var item in dto.base64DataList)
  2809. {
  2810. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2811. string result = DecodeBase64ToImage(item, imageName);
  2812. if (!string.IsNullOrEmpty(result))
  2813. {
  2814. var pic = new Grp_VisaProgressCustomerPicture
  2815. {
  2816. CreateUserId = dto.CreateUserId,
  2817. PicName = imageName,
  2818. PicPath = result,
  2819. VisaProgressCustomerId = dto.visaProgressCustomerId
  2820. };
  2821. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2822. if (insertResult > 0)
  2823. {
  2824. sucNum++;
  2825. }
  2826. }
  2827. }
  2828. }
  2829. catch (Exception ex)
  2830. {
  2831. return Ok(JsonView(false, ex.Message));
  2832. }
  2833. string msg = string.Format(@"成功上传{0}张", sucNum);
  2834. return Ok(JsonView(true, msg));
  2835. }
  2836. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2837. {
  2838. string filename = "";//声明一个string类型的相对路径
  2839. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2840. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2841. try//会有异常抛出,try,catch一下
  2842. {
  2843. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2844. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2845. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2846. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2847. //文件名称
  2848. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2849. //上传的文件的路径
  2850. string filePath = "";
  2851. if (!Directory.Exists(fileDir))
  2852. {
  2853. Directory.CreateDirectory(fileDir);
  2854. }
  2855. //上传的文件的路径
  2856. filePath = fileDir + filename;
  2857. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2858. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2859. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2860. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2861. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2862. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2863. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2864. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2865. bitmap.Dispose();
  2866. }
  2867. catch (Exception e)
  2868. {
  2869. string massage = e.Message;
  2870. Logs("IOS图片上传Error:" + massage);
  2871. //filename = e.Message;
  2872. }
  2873. return filename;//返回相对路径
  2874. }
  2875. /// <summary>
  2876. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2877. /// </summary>
  2878. /// <param name="dto"></param>
  2879. /// <returns></returns>
  2880. [HttpPost]
  2881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2882. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2883. {
  2884. if (dto == null)
  2885. {
  2886. return Ok(JsonView(false, "请求错误:"));
  2887. }
  2888. string msg = "参数错误";
  2889. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2890. {
  2891. try
  2892. {
  2893. //_delegationVisaRep.BeginTran();
  2894. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2895. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2896. .Where(s => s.Id == dto.visaProgressCustomerId)
  2897. .ExecuteCommandAsync();
  2898. if (updCount > 0 && dto.publishCode == 1)
  2899. {
  2900. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2901. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2902. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2903. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2904. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2905. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2906. if (groupData == null)
  2907. {
  2908. _delegationVisaRep.RollbackTran();
  2909. }
  2910. string title = string.Format(@"[签证进度更新]");
  2911. string content = string.Format(@"测试文本");
  2912. bool rst = await _message.AddMsg(new MessageDto()
  2913. {
  2914. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2915. IssuerId = dto.publisher,
  2916. Title = title,
  2917. Content = content,
  2918. ReleaseTime = DateTime.Now,
  2919. UIdList = new List<int> {
  2920. 234
  2921. }
  2922. });
  2923. if (rst)
  2924. {
  2925. return Ok(JsonView(true, "发送通知成功"));
  2926. }
  2927. }
  2928. //_delegationVisaRep.CommitTran();
  2929. }
  2930. catch (Exception)
  2931. {
  2932. //_delegationVisaRep.RollbackTran();
  2933. }
  2934. }
  2935. return Ok(JsonView(true, msg));
  2936. }
  2937. #endregion
  2938. #region 团组任务分配
  2939. /// <summary>
  2940. /// 团组任务分配初始化
  2941. /// </summary>
  2942. /// <returns></returns>
  2943. [HttpPost]
  2944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2945. public async Task<IActionResult> GetTaskAssignmen()
  2946. {
  2947. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2948. if (groupData.Code != 0)
  2949. {
  2950. return Ok(JsonView(false, groupData.Msg));
  2951. }
  2952. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2953. }
  2954. /// <summary>
  2955. /// 团组任务分配查询
  2956. /// </summary>
  2957. /// <param name="dto"></param>
  2958. /// <returns></returns>
  2959. [HttpPost]
  2960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2961. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2962. {
  2963. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2964. if (groupData.Code != 0)
  2965. {
  2966. return Ok(JsonView(false, groupData.Msg));
  2967. }
  2968. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2969. }
  2970. /// <summary>
  2971. /// 团组任务分配操作
  2972. /// </summary>
  2973. /// <param name="dto"></param>
  2974. /// <returns></returns>
  2975. [HttpPost]
  2976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2977. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2978. {
  2979. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2980. if (groupData.Code != 0)
  2981. {
  2982. return Ok(JsonView(false, groupData.Msg));
  2983. }
  2984. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2985. }
  2986. /// <summary>
  2987. /// 团组任务分配
  2988. /// 批量分配
  2989. /// 查询团组
  2990. /// </summary>
  2991. /// <param name="dto"></param>
  2992. /// <returns></returns>
  2993. [HttpPost]
  2994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2995. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2996. {
  2997. //参数验证
  2998. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2999. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3000. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3001. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3002. }
  3003. /// <summary>
  3004. /// 团组任务分配
  3005. /// 批量分配
  3006. /// </summary>
  3007. /// <param name="dto"></param>
  3008. /// <returns></returns>
  3009. [HttpPost]
  3010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3011. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3012. {
  3013. //参数验证
  3014. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3015. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3016. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3017. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3018. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3019. }
  3020. #endregion
  3021. #region 团组费用审核
  3022. /// <summary>
  3023. /// 费用审核
  3024. /// 团组列表 Page
  3025. /// </summary>
  3026. /// <param name="_dto">团组列表请求dto</param>
  3027. /// <returns></returns>
  3028. [HttpPost]
  3029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3030. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3031. {
  3032. #region 参数验证
  3033. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3034. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3035. #region 页面操作权限验证
  3036. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3037. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3038. #endregion
  3039. #endregion
  3040. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3041. {
  3042. string sqlWhere = string.Empty;
  3043. if (_dto.IsSure == 0) //未完成
  3044. {
  3045. sqlWhere += string.Format(@" And IsSure = 0");
  3046. }
  3047. else if (_dto.IsSure == 1) //已完成
  3048. {
  3049. sqlWhere += string.Format(@" And IsSure = 1");
  3050. }
  3051. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3052. {
  3053. string tj = _dto.SearchCriteria;
  3054. 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}%')",
  3055. tj, tj, tj, tj, tj);
  3056. }
  3057. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3058. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3059. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3060. From (
  3061. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3062. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3063. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3064. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3065. From Grp_DelegationInfo gdi
  3066. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3067. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3068. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3069. Where gdi.IsDel = 0 {0}
  3070. ) temp ", sqlWhere);
  3071. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3072. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3073. var _view = new
  3074. {
  3075. PageFuncAuth = pageFunAuthView,
  3076. Data = _DelegationList
  3077. };
  3078. return Ok(JsonView(true, "查询成功!", _view, total));
  3079. }
  3080. else
  3081. {
  3082. return Ok(JsonView(false, "查询失败"));
  3083. }
  3084. }
  3085. /// <summary>
  3086. /// 获取团组费用审核
  3087. /// </summary>
  3088. /// <param name="_dto"></param>
  3089. /// <returns></returns>
  3090. [HttpPost]
  3091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3092. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3093. {
  3094. try
  3095. {
  3096. #region 参数验证
  3097. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3098. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3099. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3100. #region 页面操作权限验证
  3101. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3102. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3103. #endregion
  3104. #endregion
  3105. var _view = new Grp_CreditCardPaymentView();
  3106. var clientNameList = GetSimplClientList(_dto.DiId);
  3107. #region 费用清单
  3108. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3109. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3110. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3111. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3112. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3113. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3114. /*
  3115. * 76://酒店预订
  3116. */
  3117. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3118. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3119. /*
  3120. * 79://车/导游地接
  3121. */
  3122. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3123. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3124. /*
  3125. * 80: //签证
  3126. */
  3127. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3128. /*
  3129. *81: //邀请/公务活动
  3130. */
  3131. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3132. /*
  3133. * 82: //团组客户保险
  3134. */
  3135. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3136. /*
  3137. * Lable = 85 机票预订
  3138. */
  3139. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3140. /*
  3141. * 85 机票预定
  3142. */
  3143. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3144. /*
  3145. * 98 其他款项
  3146. */
  3147. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3148. /*
  3149. * 285:收款退还
  3150. */
  3151. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3152. /*
  3153. * 1015: //超支费用
  3154. */
  3155. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3156. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3157. /*
  3158. * 币种信息
  3159. */
  3160. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3161. /*
  3162. * 车/导游地接 费用类型
  3163. */
  3164. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3165. /*
  3166. * 车/导游地接 费用类型
  3167. */
  3168. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3169. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3170. /*
  3171. * 用户信息
  3172. */
  3173. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3174. /*
  3175. * 费用模块
  3176. */
  3177. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3178. string priceModule = string.Empty;
  3179. if (sdPriceName != null)
  3180. {
  3181. priceModule = sdPriceName.Name;
  3182. }
  3183. /*
  3184. * 成本信息
  3185. */
  3186. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3187. decimal _groupRate = 0.0000M;
  3188. string _groupCurrencyCode = "-";
  3189. if (groupCost != null)
  3190. {
  3191. _groupRate = groupCost.Rate;
  3192. if (int.TryParse(groupCost.Currency, out int _currency))
  3193. {
  3194. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3195. }
  3196. else _groupCurrencyCode = groupCost.Currency;
  3197. }
  3198. string costContentSql = $"Select * From Grp_GroupCost";
  3199. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3200. //处理日期为空的天数
  3201. for (int i = 0; i < groupCostDetails.Count; i++)
  3202. if (i != 0)
  3203. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3204. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3205. /*
  3206. * 处理详情数据
  3207. */
  3208. foreach (var entity in entityList)
  3209. {
  3210. var _detail = new Grp_CreditCardPaymentDetailView
  3211. {
  3212. Id = entity.Id,
  3213. PriceName = priceModule,
  3214. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  3215. };
  3216. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3217. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  3218. //处理金额
  3219. if (entity.CTable == 1015)
  3220. {
  3221. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  3222. if (czInfo != null)
  3223. {
  3224. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  3225. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  3226. }
  3227. }
  3228. /*
  3229. * 应付款金额
  3230. */
  3231. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  3232. string PaymentCurrency_WaitPay = "Unknown";
  3233. string hotelCurrncyCode = "Unknown";
  3234. string hotelCurrncyName = "Unknown";
  3235. if (sdPaymentCurrency_WaitPay != null)
  3236. {
  3237. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  3238. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  3239. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  3240. if (hotelCurrncyCode.Equals("CNY"))
  3241. {
  3242. entity.DayRate = 1.0000M;
  3243. }
  3244. }
  3245. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3246. /*
  3247. * 此次付款金额
  3248. */
  3249. decimal CurrPayStr = 0.00M,
  3250. OriginalCurrPay = 0.00M;
  3251. if (entity.PayPercentage == 0)
  3252. {
  3253. if (entity.PayThenMoney != 0)
  3254. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  3255. }
  3256. else
  3257. {
  3258. if (entity.PayMoney != 0)
  3259. {
  3260. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  3261. }
  3262. }
  3263. //if (_dto.Label == 79)
  3264. //{
  3265. // string original = string.Empty;
  3266. // if (hotelCurrncyCode.Equals("CNY"))
  3267. // {
  3268. // OriginalCurrPay = CurrPayStr;
  3269. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3270. // }
  3271. // else
  3272. // {
  3273. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3274. // //760 EUR(7600.00 CNY)
  3275. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  3276. // }
  3277. //}
  3278. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3279. string original = string.Empty;
  3280. if (hotelCurrncyCode.Equals("CNY"))
  3281. {
  3282. OriginalCurrPay = CurrPayStr;
  3283. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  3284. }
  3285. else
  3286. {
  3287. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  3288. //760 EUR(7600.00 CNY)
  3289. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  3290. }
  3291. /*
  3292. * 剩余尾款
  3293. */
  3294. decimal BalanceStr = 0;
  3295. if (CurrPayStr != 0)
  3296. {
  3297. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  3298. BalanceStr = 0;
  3299. else
  3300. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  3301. }
  3302. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  3303. /*
  3304. * Bus名称
  3305. */
  3306. _detail.BusName = "待增加";
  3307. /*
  3308. *费用所属
  3309. */
  3310. switch (entity.CTable)
  3311. {
  3312. case 76://酒店预订
  3313. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3314. if (hotelReservations != null)
  3315. {
  3316. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  3317. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  3318. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  3319. string roomFeeStr = "", roomFeestr1 = "";
  3320. //是否比较房型价格
  3321. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  3322. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  3323. roomFeeStr += $"<br/>";
  3324. var roomTotal = 0.00M;
  3325. if (hotelReservations.SingleRoomPrice > 0)
  3326. {
  3327. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  3328. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3329. //__isSingle = true;
  3330. roomTotal += fee;
  3331. }
  3332. if (hotelReservations.DoubleRoomPrice > 0)
  3333. {
  3334. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  3335. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3336. // __isDouble = true;
  3337. roomTotal += fee;
  3338. }
  3339. if (hotelReservations.SuiteRoomPrice > 0)
  3340. {
  3341. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3342. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3343. //__isSuite = true;
  3344. roomTotal += fee;
  3345. }
  3346. if (hotelReservations.OtherRoomPrice > 0)
  3347. {
  3348. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3349. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3350. //__isOther = true;
  3351. roomTotal += fee;
  3352. }
  3353. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3354. else roomFeeStr += " 0.00 * 0";
  3355. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3356. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3357. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3358. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3359. /*
  3360. * 费用类型
  3361. * 1:房费
  3362. * 2:早餐
  3363. * 3:地税
  3364. * 4:城市税
  3365. * </summary>
  3366. */
  3367. //地税
  3368. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3369. if (governmentRentData != null)
  3370. {
  3371. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3372. governmentRentFee = governmentRentData.Price;
  3373. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3374. if (governmentRentCurrData != null)
  3375. {
  3376. governmentRentCode = governmentRentCurrData.Name;
  3377. governmentRentName = $"({governmentRentCurrData.Remark})";
  3378. }
  3379. }
  3380. //城市税
  3381. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3382. if (cityTaxData != null)
  3383. {
  3384. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3385. cityTaxFee = cityTaxData.Price;
  3386. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3387. if (cityTaxCurrData != null)
  3388. {
  3389. cityTaxCode = cityTaxCurrData.Name;
  3390. cityTaxName = $"({cityTaxCurrData.Remark})";
  3391. }
  3392. }
  3393. //酒店早餐
  3394. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3395. if (breakfastData != null)
  3396. {
  3397. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3398. breakfastFee = breakfastData.Price;
  3399. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3400. if (breakfastCurrData != null)
  3401. {
  3402. breakfastCode = breakfastCurrData.Name;
  3403. breakfastName = $"({breakfastCurrData.Remark})";
  3404. }
  3405. }
  3406. //房间费用
  3407. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3408. if (roomData != null)
  3409. {
  3410. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3411. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3412. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3413. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3414. roomFee = roomData.Price;
  3415. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3416. if (roomCurrData != null)
  3417. {
  3418. roomCode = roomCurrData.Name;
  3419. roomName = $"({roomCurrData.Remark})";
  3420. }
  3421. }
  3422. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3423. string hotelCostStr = "";
  3424. decimal hotelCsotTotal = 0.00M;
  3425. if (groupCost != null)
  3426. {
  3427. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3428. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3429. }
  3430. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3431. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3432. string hotelCost_day = "";
  3433. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3434. foreach (var item in hotelCostDetails1)
  3435. {
  3436. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3437. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3438. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3439. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3440. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3441. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3442. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3443. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3444. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3445. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3446. hotelCost_day += @$"<br/>";
  3447. }
  3448. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3449. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3450. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3451. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3452. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3453. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3454. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3455. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3456. $"房间说明: {hotelReservations.Remark} <br/>" +
  3457. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3458. $"{hotelBreakfastStr}" +
  3459. $"{hotelGovernmentRentStr}" +
  3460. $"{hotelCityTaxStr}";
  3461. _detail.PriceNameContent = hotelReservations.HotelName;
  3462. }
  3463. break;
  3464. case 79://车/导游地接
  3465. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3466. if (touristGuideGroundReservations != null)
  3467. {
  3468. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3469. {
  3470. _detail.BusName = touristGuideGroundReservations.BusName;
  3471. }
  3472. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3473. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3474. //if (isInt)
  3475. //{
  3476. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3477. // if (cityInfo != null)
  3478. // {
  3479. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3480. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3481. // if (carFeeItem != null)
  3482. // {
  3483. // nameContent += $@"({carFeeItem.Name})";
  3484. // }
  3485. // _detail.PriceNameContent = nameContent;
  3486. // }
  3487. //}
  3488. //else
  3489. //{
  3490. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3491. //}
  3492. var touristGuideGroundReservationsContents =
  3493. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3494. var opContent_sb = new StringBuilder();
  3495. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3496. opContent_sb.AppendLine(contetTitle);
  3497. foreach (var item in touristGuideGroundReservationsContents)
  3498. {
  3499. string typeName = "Unknown";
  3500. string carCurrencyCode = "Unknown";
  3501. string carCurrencyName = "Unknown";
  3502. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3503. if (carTypeData != null) typeName = carTypeData.Name;
  3504. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3505. if (currencyData != null)
  3506. {
  3507. carCurrencyCode = currencyData.Name;
  3508. carCurrencyName = currencyData.Remark;
  3509. }
  3510. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3511. bool IsCurrencyAgreement = false;
  3512. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3513. string opCostStr = string.Empty;
  3514. decimal opCostTypePrice = 0.00M;
  3515. #region 处理成本各项费用
  3516. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3517. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3518. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3519. costOPFeeCNY = 0.00M, //团组成本 op费用
  3520. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3521. if (opCost.Count > 0)
  3522. {
  3523. switch (item.SId)
  3524. {
  3525. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3526. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3527. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3528. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3529. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3530. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3531. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3532. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3533. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3534. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3535. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3536. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3537. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3538. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3539. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3540. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3541. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3542. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3543. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3544. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3545. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3546. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3547. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3548. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3549. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3550. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3551. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3552. }
  3553. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3554. costOPFeeCNY = opCostTypePrice * _groupRate;
  3555. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3556. }
  3557. #endregion
  3558. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3559. aduitOPFeeCNY = item.Price * entity.DayRate;
  3560. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3561. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3562. $"{opTypeStr} {opCostStr}<br/>" +
  3563. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3564. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3565. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3566. {
  3567. if (IsCurrencyAgreement)
  3568. {
  3569. if (item.Price > opCostTypePrice)
  3570. {
  3571. opContent_sb.Append("<span style='color:red;'>");
  3572. opContent_sb.Append(opContent);
  3573. opContent_sb.Append("</span>");
  3574. opContent_sb.AppendLine();
  3575. }
  3576. else
  3577. {
  3578. opContent_sb.Append(opContent);
  3579. opContent_sb.AppendLine();
  3580. }
  3581. }
  3582. else
  3583. {
  3584. //验证是否超成本 按付款比例计算
  3585. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3586. {
  3587. opContent_sb.Append("<span style='color:red;'>");
  3588. opContent_sb.Append(opContent);
  3589. opContent_sb.Append("</span>");
  3590. opContent_sb.AppendLine();
  3591. }
  3592. else
  3593. {
  3594. opContent_sb.Append(opContent);
  3595. opContent_sb.AppendLine();
  3596. }
  3597. }
  3598. }
  3599. else
  3600. {
  3601. opContent_sb.Append(opContent);
  3602. opContent_sb.AppendLine();
  3603. }
  3604. }
  3605. _detail.PriceMsgContent = opContent_sb.ToString();
  3606. }
  3607. break;
  3608. case 80: //签证
  3609. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3610. if (visaInfo != null)
  3611. {
  3612. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  3613. _detail.PriceNameContent = visaInfo.VisaDescription;
  3614. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3615. }
  3616. break;
  3617. case 81: //邀请/公务活动
  3618. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3619. if (_ioa != null)
  3620. {
  3621. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3622. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3623. sendCurrName = "Unknown", //快递费用币种 Name
  3624. sendCurrCode = "Unknown", //快递费用币种 Code
  3625. eventsCurrName = "Unknown", //公务活动费币种 Name
  3626. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3627. translateCurrName = "Unknown", //公务翻译费 Name
  3628. translateCurrCode = "Unknown"; //公务翻译费 Code
  3629. #region 处理费用币种
  3630. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3631. if (inviteCurrData != null)
  3632. {
  3633. inviteCurrName = inviteCurrData.Remark;
  3634. inviteCurrCode = inviteCurrData.Name;
  3635. }
  3636. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3637. if (sendCurrData != null)
  3638. {
  3639. sendCurrName = sendCurrData.Remark;
  3640. sendCurrCode = sendCurrData.Name;
  3641. }
  3642. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3643. if (eventsCurrData != null)
  3644. {
  3645. eventsCurrName = eventsCurrData.Remark;
  3646. eventsCurrCode = eventsCurrData.Name;
  3647. }
  3648. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3649. if (translateCurrData != null)
  3650. {
  3651. translateCurrName = translateCurrData.Remark;
  3652. translateCurrCode = translateCurrData.Name;
  3653. }
  3654. #endregion
  3655. _detail.PriceNameContent = _ioa.InviterArea;
  3656. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  3657. List<string> priceExpNames = new List<string>();
  3658. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  3659. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  3660. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  3661. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  3662. if (priceExpNames != null && priceExpNames.Count > 0)
  3663. {
  3664. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  3665. }
  3666. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  3667. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  3668. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  3669. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  3670. $@"备注:" + _ioa.Remark + "<br/>";
  3671. }
  3672. break;
  3673. case 82: //团组客户保险
  3674. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3675. if (customers != null)
  3676. {
  3677. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  3678. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3679. }
  3680. break;
  3681. case 85: //机票预订
  3682. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3683. if (jpRes != null)
  3684. {
  3685. string FlightsDescription = jpRes.FlightsDescription;
  3686. string PriceDescription = jpRes.PriceDescription;
  3687. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3688. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3689. }
  3690. break;
  3691. case 98://其他款项
  3692. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3693. if (gdpRes != null)
  3694. {
  3695. //var urlBase = $"http://132.232.92.186:24/Office/GrpFile/http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  3696. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  3697. //{
  3698. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  3699. //}
  3700. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3701. _detail.PriceNameContent = gdpRes.PriceName;
  3702. }
  3703. break;
  3704. case 285://收款退还
  3705. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3706. if (refundAndOtherMoney != null)
  3707. {
  3708. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3709. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3710. }
  3711. break;
  3712. case 751://酒店早餐
  3713. break;
  3714. case 1015://超支费用
  3715. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3716. if (groupExtraCost != null)
  3717. {
  3718. _detail.PriceNameContent = groupExtraCost.PriceName;
  3719. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3720. }
  3721. break;
  3722. default:
  3723. break;
  3724. }
  3725. /*
  3726. * 申请人
  3727. */
  3728. string operatorName = " - ";
  3729. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3730. if (_opUser != null)
  3731. {
  3732. operatorName = _opUser.CnName;
  3733. }
  3734. _detail.OperatorName = operatorName;
  3735. /*
  3736. * 审核人
  3737. */
  3738. string auditOperatorName = " - ";
  3739. if (entity.IsAuditGM != 0)
  3740. {
  3741. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3742. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3743. else
  3744. {
  3745. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3746. if (_adUser != null)
  3747. {
  3748. auditOperatorName = _adUser.CnName;
  3749. }
  3750. }
  3751. }
  3752. _detail.AuditOperatorName = auditOperatorName;
  3753. /*
  3754. * 超预算比例
  3755. */
  3756. string overBudgetStr = "";
  3757. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3758. else if (entity.ExceedBudget == 0)
  3759. {
  3760. if (entity.CTable == 76 || entity.CTable == 79)
  3761. {
  3762. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3763. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3764. }
  3765. else
  3766. {
  3767. overBudgetStr = "未超预算";
  3768. }
  3769. }
  3770. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3771. _detail.OverBudget = overBudgetStr;
  3772. decimal auditFee = 0.00M; //已审核金额 人名币
  3773. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3774. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3775. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3776. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3777. {
  3778. auditedFeeOriginal = entity.PayMoney;
  3779. auditFee = CurrPayStr;
  3780. }
  3781. else if (entity.IsAuditGM == 0)
  3782. {
  3783. unAuditFeeCNY = CurrPayStr;
  3784. unAuditFeeOriginal = OriginalCurrPay;
  3785. OriginalCurrPay = 0.00M;
  3786. }
  3787. /*
  3788. * 费用总计
  3789. */
  3790. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3791. {
  3792. CurrencyId = entity.PaymentCurrency,
  3793. CurrencyName = PaymentCurrency_WaitPay,
  3794. AmountPayable = entity.PayMoney,
  3795. ThisPayment = OriginalCurrPay,
  3796. BalancePayment = BalanceStr,
  3797. AuditedFunds = auditFee,
  3798. AuditedFundsOriginal = auditedFeeOriginal,
  3799. UnAuditFundsCNY = unAuditFeeCNY,
  3800. UnAuditFundsOriginal = unAuditFeeOriginal
  3801. });
  3802. _detail.IsAuditGM = entity.IsAuditGM;
  3803. detailList.Add(_detail);
  3804. }
  3805. #endregion
  3806. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3807. /*
  3808. * 下方描述处理
  3809. */
  3810. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3811. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3812. if (ccpCurrencyPrice != null)
  3813. {
  3814. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3815. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3816. }
  3817. else
  3818. {
  3819. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3820. }
  3821. string amountPayableStr = string.Format(@"应付款总金额: ");
  3822. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3823. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3824. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3825. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3826. foreach (var item in nonDuplicat)
  3827. {
  3828. var currencyName = item.CurrencyName;
  3829. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3830. if (strs.Count > 0)
  3831. {
  3832. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3833. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3834. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3835. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3836. //单独处理此次付款金额
  3837. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3838. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3839. //单独处理已审核费用
  3840. //if (item.CurrencyId == 836) //人民币
  3841. //{
  3842. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3843. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3844. //}
  3845. //else
  3846. //{
  3847. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3848. //}
  3849. if (currencyName.Equals("CNY"))
  3850. {
  3851. //已审核费用
  3852. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3853. //未审核费用
  3854. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3855. }
  3856. else
  3857. {
  3858. //已审核费用
  3859. 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"));
  3860. //未审核费用
  3861. 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"));
  3862. }
  3863. }
  3864. }
  3865. _view.TotalStr1 = amountPayableStr[..^1];
  3866. _view.TotalStr2 = thisPaymentStr[..^1];
  3867. _view.TotalStr3 = balancePaymentStr[..^1];
  3868. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3869. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3870. var _view1 = new
  3871. {
  3872. PageFuncAuth = pageFunAuthView,
  3873. Data = _view
  3874. };
  3875. return Ok(JsonView(_view1));
  3876. }
  3877. catch (Exception ex)
  3878. {
  3879. return Ok(JsonView(false, ex.Message));
  3880. }
  3881. }
  3882. /// <summary>
  3883. /// 费用审核
  3884. /// 修改团组费用审核状态
  3885. /// </summary>
  3886. /// <param name="_dto">参数Json字符串</param>
  3887. /// <returns></returns>
  3888. [HttpPost]
  3889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3890. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3891. {
  3892. #region 参数验证
  3893. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3894. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3895. #endregion
  3896. #region 页面操作权限验证
  3897. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3898. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3899. #endregion
  3900. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3901. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3902. DateTime dtNow = DateTime.Now;
  3903. _groupRepository.BeginTran();
  3904. int rst = 0;
  3905. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3906. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3907. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3908. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3909. var msgDatas = new List<dynamic>();
  3910. var dic_ccp_user = new Dictionary<int, int>() { };
  3911. foreach (var item in idList)
  3912. {
  3913. int CreditId = int.Parse(item);
  3914. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3915. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3916. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3917. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3918. .Where(s => s.Id == CreditId)
  3919. .ExecuteCommandAsync();
  3920. if (result < 1)
  3921. {
  3922. rst = -1;
  3923. _groupRepository.RollbackTran();
  3924. return Ok(JsonView(false, "操作失败并回滚!"));
  3925. }
  3926. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3927. if (creditData != null)
  3928. {
  3929. #region 应用通知配置
  3930. try
  3931. {
  3932. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3933. }
  3934. catch (Exception ex)
  3935. {
  3936. }
  3937. #endregion
  3938. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3939. string groupNameStr = string.Empty;
  3940. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3941. if (groupData != null) groupNameStr = groupData.TeamName;
  3942. string creditTypeStr = string.Empty;
  3943. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3944. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3945. string creditCurrency = string.Empty;
  3946. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3947. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3948. if (creditCurrency.Equals("CNY"))
  3949. {
  3950. creditData.DayRate = 1.0000M;
  3951. }
  3952. if (creditData.PayPercentage == 0.00M)
  3953. {
  3954. creditData.PayPercentage = 100M;
  3955. }
  3956. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3957. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3958. string msgContent = "";
  3959. if (creditCurrency.Equals("CNY"))
  3960. {
  3961. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  3962. }
  3963. else
  3964. {
  3965. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  3966. }
  3967. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3968. }
  3969. }
  3970. if (rst == 0)
  3971. {
  3972. _groupRepository.CommitTran();
  3973. foreach (var item in msgDatas)
  3974. {
  3975. //发送消息
  3976. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3977. }
  3978. #region 应用推送
  3979. try
  3980. {
  3981. foreach (var ccpId in dic_ccp_user.Keys)
  3982. {
  3983. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3984. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3985. }
  3986. }
  3987. catch (Exception)
  3988. {
  3989. }
  3990. #endregion
  3991. return Ok(JsonView(true, "操作成功!"));
  3992. }
  3993. return Ok(JsonView(false, "操作失败!"));
  3994. }
  3995. /// <summary>
  3996. /// 费用审核
  3997. /// 其他款项 文件下载
  3998. /// </summary>
  3999. /// <param name="id">其他款项 主键编号</param>
  4000. /// <returns></returns>
  4001. [HttpGet("{id}")]
  4002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4003. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4004. {
  4005. //网站域名
  4006. const string baseUrl = "http://132.232.92.186:24/Office/GrpFile/%E5%9B%A2%E7%BB%84%E5%A2%9E%E5%87%8F%E6%AC%BE%E9%A1%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6/";
  4007. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4008. .Queryable<Grp_DecreasePayments>()
  4009. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4010. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4011. .Select((x, y) => new
  4012. {
  4013. x.Id,
  4014. x.FilePath
  4015. })
  4016. .FirstAsync();
  4017. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4018. {
  4019. var url = $"{baseUrl}{otherInfo.FilePath}";
  4020. return Ok(JsonView(true, "操作成功!", url));
  4021. }
  4022. return Ok(JsonView(false, "暂无附件"));
  4023. }
  4024. #endregion
  4025. #region 机票费用录入
  4026. /// <summary>
  4027. /// 机票录入当前登录人可操作团组
  4028. /// </summary>
  4029. /// <param name="dto"></param>
  4030. /// <returns></returns>
  4031. [HttpPost]
  4032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4033. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4034. {
  4035. try
  4036. {
  4037. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4038. if (groupData.Code != 0)
  4039. {
  4040. return Ok(JsonView(false, groupData.Msg));
  4041. }
  4042. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4043. }
  4044. catch (Exception ex)
  4045. {
  4046. return Ok(JsonView(false, ex.Message));
  4047. }
  4048. }
  4049. /// <summary>
  4050. /// 机票费用录入列表
  4051. /// </summary>
  4052. /// <param name="dto"></param>
  4053. /// <returns></returns>
  4054. [HttpPost]
  4055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4056. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4057. {
  4058. try
  4059. {
  4060. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4061. if (groupData.Code != 0)
  4062. {
  4063. return Ok(JsonView(false, groupData.Msg));
  4064. }
  4065. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4066. }
  4067. catch (Exception ex)
  4068. {
  4069. return Ok(JsonView(false, ex.Message));
  4070. throw;
  4071. }
  4072. }
  4073. /// <summary>
  4074. /// 根据id查询费用录入信息
  4075. /// </summary>
  4076. /// <param name="dto"></param>
  4077. /// <returns></returns>
  4078. [HttpPost]
  4079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4080. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4081. {
  4082. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4083. if (groupData.Code != 0)
  4084. {
  4085. return Ok(JsonView(false, groupData.Msg));
  4086. }
  4087. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4088. }
  4089. /// <summary>
  4090. /// 机票费用录入操作(Status:1.新增,2.修改)
  4091. /// </summary>
  4092. /// <param name="dto"></param>
  4093. /// <returns></returns>
  4094. [HttpPost]
  4095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4096. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4097. {
  4098. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4099. if (groupData.Code != 0)
  4100. {
  4101. return Ok(JsonView(false, groupData.Msg));
  4102. }
  4103. #region 应用推送
  4104. try
  4105. {
  4106. var diId = dto.AirTicketResOpData.DiId;
  4107. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4108. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4109. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4110. //自动审核
  4111. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4112. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4113. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4114. $"GroupId:{diId};airId:{dataId};",
  4115. status,
  4116. auditMsg);
  4117. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4118. //2024-10-21 新增LZ UID
  4119. var userIds = new List<int>() { 21 };
  4120. string title = $"系统通知";
  4121. string content = "";
  4122. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4123. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4124. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4125. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4126. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4127. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4128. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4129. }
  4130. catch (Exception ex)
  4131. {
  4132. }
  4133. #endregion
  4134. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4135. }
  4136. /// <summary>
  4137. /// 机票费用自动审核 AI识别方式
  4138. /// </summary>
  4139. /// <returns></returns>
  4140. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4141. {
  4142. var ecoTypeIds = new List<int>() {
  4143. 459, //超经舱
  4144. 460, //经济舱
  4145. 1430, //公务舱(实际经济舱)
  4146. 1432, //头等舱(实际经济舱)
  4147. };
  4148. var bizTypeIds = new List<int>() {
  4149. 457, //头等舱
  4150. 458, //公务舱
  4151. 1431, //头等舱(实际公务舱)
  4152. };
  4153. var auditFeeTypeIds = new List<int>() { };
  4154. auditFeeTypeIds.AddRange(ecoTypeIds);
  4155. auditFeeTypeIds.AddRange(bizTypeIds);
  4156. int currModule = 85;
  4157. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4158. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4159. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4160. .Select((x, y) => new
  4161. {
  4162. x.Id,
  4163. CcpId = y.Id,
  4164. x.FlightsDate,
  4165. x.PrePrice,
  4166. x.CType,
  4167. x.ClientNum,
  4168. x.DIId
  4169. })
  4170. .FirstAsync();
  4171. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4172. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4173. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4174. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4175. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4176. var groupCostContents = await _sqlSugar
  4177. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4178. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4179. .ToListAsync();
  4180. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4181. //处理 成本详细信息日期为空 填装费用信息
  4182. var airFeeLabel = new StringBuilder();
  4183. airFeeLabel.AppendLine("费用成本:");
  4184. for (int i = 0; i < groupCostContents.Count; i++)
  4185. {
  4186. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4187. {
  4188. int index = i - 1;
  4189. if (index >= 0)
  4190. {
  4191. groupCostContents[i].Date = groupCostContents[index].Date;
  4192. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4193. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4194. }
  4195. }
  4196. else
  4197. {
  4198. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4199. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4200. }
  4201. var item = groupCostContents[i];
  4202. airFeeLabel.AppendLine($"{item.Date}");
  4203. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4204. }
  4205. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4206. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4207. //访问Kimi AI 返回价格结果
  4208. var msgs = new List<SeedMessages>()
  4209. {
  4210. new ()
  4211. {
  4212. Role = KimiRole.user,
  4213. Content = airFeeLabel.ToString()
  4214. }
  4215. };
  4216. var client = new KiMiApiClient();
  4217. var kimiApiResult = await client.SeedMessage(msgs);
  4218. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  4219. string clients = kimiApiResult_JObject["content"].ToString();
  4220. decimal ecoPri_kimiAI = 0.00M,
  4221. bizPri_kimiAI = 0.00M;
  4222. //单个价格: 经济舱价格
  4223. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  4224. //价格文本包含/:/前经济舱价格 /后公务舱价格
  4225. if (clients.Contains('/'))
  4226. {
  4227. var priArray = clients.Split('/');
  4228. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  4229. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  4230. }
  4231. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  4232. var isAutoAudit = false;
  4233. //价格验证处理
  4234. //经济舱
  4235. if (ecoTypeIds.Contains(airInfo.CType))
  4236. {
  4237. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  4238. }
  4239. //公务舱
  4240. else if (bizTypeIds.Contains(airInfo.CType))
  4241. {
  4242. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  4243. }
  4244. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  4245. //是否执行自动审核
  4246. if (isAutoAudit)
  4247. {
  4248. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4249. .SetColumns(x => x.IsAuditGM == 3)
  4250. .SetColumns(x => x.AuditGMOperate == 4)
  4251. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  4252. .Where(x => x.Id == airInfo.CcpId)
  4253. .ExecuteCommandAsync();
  4254. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  4255. }
  4256. return (false, "当前费用超过成本费用,不可自动审核!");
  4257. }
  4258. /// <summary>
  4259. /// 机票费用录入
  4260. /// 自动审核测试 - AI 识别
  4261. /// </summary>
  4262. /// <param name="groupId"></param>
  4263. /// <param name="Id"></param>
  4264. /// <returns></returns>
  4265. [HttpPost]
  4266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4267. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  4268. {
  4269. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  4270. return Ok(JsonView(status, msg));
  4271. }
  4272. /// <summary>
  4273. /// 根据舱位类型查询接团客户名单信息
  4274. /// </summary>
  4275. /// <param name="dto"></param>
  4276. /// <returns></returns>
  4277. [HttpPost]
  4278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4279. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  4280. {
  4281. try
  4282. {
  4283. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  4284. if (crm_Groups.Count != 0)
  4285. {
  4286. var Customer = new List<dynamic>();
  4287. foreach (var item in crm_Groups)
  4288. {
  4289. var data = new
  4290. {
  4291. item.Id,
  4292. item.Pinyin,
  4293. Name = item.LastName + item.FirstName
  4294. };
  4295. Customer.Add(data);
  4296. }
  4297. return Ok(JsonView(true, "查询成功!", Customer));
  4298. }
  4299. return Ok(JsonView(true, "暂无数据", crm_Groups));
  4300. }
  4301. catch (Exception ex)
  4302. {
  4303. return Ok(JsonView(false, "程序错误!"));
  4304. throw;
  4305. }
  4306. }
  4307. /// <summary>
  4308. /// 根据团号获取客户信息
  4309. /// </summary>
  4310. /// <param name="dto"></param>
  4311. /// <returns></returns>
  4312. [HttpPost]
  4313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4314. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  4315. {
  4316. var jw = JsonView(false);
  4317. if (dto.DIID < 1)
  4318. {
  4319. jw.Msg += "请输入正确的diid";
  4320. return Ok(jw);
  4321. }
  4322. var arr = GetSimplClientList(dto.DIID);
  4323. jw = JsonView(true, "获取成功!", arr);
  4324. return Ok(jw);
  4325. }
  4326. private List<SimplClientInfo> GetSimplClientList(int diId)
  4327. {
  4328. 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);
  4329. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  4330. foreach (var item in arr)
  4331. {
  4332. EncryptionProcessor.DecryptProperties(item);
  4333. }
  4334. return arr;
  4335. }
  4336. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  4337. {
  4338. string result = origin;
  4339. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4340. {
  4341. string[] temparr = origin.Split(',');
  4342. string fistrStr = temparr[0];
  4343. int count = temparr.Length;
  4344. bool success = int.TryParse(fistrStr, out int tempId);
  4345. if (success)
  4346. {
  4347. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4348. if (tempInfo != null)
  4349. {
  4350. if (count > 1)
  4351. {
  4352. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  4353. }
  4354. else
  4355. {
  4356. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  4357. }
  4358. }
  4359. }
  4360. }
  4361. return result;
  4362. }
  4363. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  4364. {
  4365. string result = origin;
  4366. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  4367. {
  4368. string[] temparr = origin.Split(',');
  4369. result = "";
  4370. foreach (var item in temparr)
  4371. {
  4372. bool success = int.TryParse(item, out int tempId);
  4373. if (success)
  4374. {
  4375. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  4376. if (tempInfo != null)
  4377. {
  4378. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4379. }
  4380. }
  4381. }
  4382. }
  4383. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4384. return result;
  4385. }
  4386. /// <summary>
  4387. /// 机票费用录入,删除
  4388. /// </summary>
  4389. /// <param name="dto"></param>
  4390. /// <returns></returns>
  4391. [HttpPost]
  4392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4393. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4394. {
  4395. try
  4396. {
  4397. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4398. if (res)
  4399. {
  4400. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4401. {
  4402. IsDel = 1,
  4403. DeleteUserId = dto.DeleteUserId,
  4404. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4405. }).ExecuteCommandAsync();
  4406. return Ok(JsonView(true, "删除成功!"));
  4407. }
  4408. return Ok(JsonView(false, "删除失败!"));
  4409. }
  4410. catch (Exception ex)
  4411. {
  4412. return Ok(JsonView(false, "程序错误!"));
  4413. throw;
  4414. }
  4415. }
  4416. /// <summary>
  4417. /// 导出机票录入报表
  4418. /// </summary>
  4419. /// <param name="dto"></param>
  4420. /// <returns></returns>
  4421. [HttpPost]
  4422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4423. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4424. {
  4425. try
  4426. {
  4427. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4428. if (groupData.Code != 0)
  4429. {
  4430. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4431. }
  4432. else
  4433. {
  4434. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4435. if (AirTicketReservations.Count != 0)
  4436. {
  4437. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4438. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4439. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4440. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4441. var designer = new WorkbookDesigner
  4442. {
  4443. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  4444. };
  4445. decimal countCost = 0;
  4446. foreach (var item in AirTicketReservations)
  4447. {
  4448. #region 处理客人姓名
  4449. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  4450. item.ClientName = clientNames;
  4451. #endregion
  4452. if (item.BankType == "其他")
  4453. {
  4454. item.BankNo = "--";
  4455. }
  4456. else
  4457. {
  4458. if (!string.IsNullOrEmpty(item.BankType))
  4459. {
  4460. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  4461. }
  4462. }
  4463. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4464. item.Price = System.Decimal.Round(item.Price, 2);
  4465. countCost += Convert.ToDecimal(item.Price);
  4466. }
  4467. designer.SetDataSource("Export", AirTicketReservations);
  4468. designer.SetDataSource("ExportDiCode", diCode);
  4469. designer.SetDataSource("ExportDiName", diName);
  4470. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4471. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4472. designer.Process();
  4473. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4474. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4475. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4476. return Ok(JsonView(true, "成功", url = rst));
  4477. }
  4478. else
  4479. {
  4480. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4481. }
  4482. }
  4483. }
  4484. catch (Exception ex)
  4485. {
  4486. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4487. throw;
  4488. }
  4489. }
  4490. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  4491. /// <summary>
  4492. /// 行程单导出
  4493. /// </summary>
  4494. /// <param name="dto"></param>
  4495. /// <returns></returns>
  4496. [HttpPost]
  4497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4498. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4499. {
  4500. try
  4501. {
  4502. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4503. if (groupData.Code != 0)
  4504. {
  4505. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4506. }
  4507. else
  4508. {
  4509. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4510. if (dto.Language == "CN")
  4511. {
  4512. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4513. var builder = new DocumentBuilder(doc);
  4514. int tableIndex = 0;//表格索引
  4515. //得到文档中的第一个表格
  4516. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4517. foreach (var item in _AirTicketReservations)
  4518. {
  4519. #region 处理固定数据
  4520. string[] FlightsCode = item.FlightsCode.Split('/');
  4521. if (FlightsCode.Length != 0)
  4522. {
  4523. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4524. if (_AirCompany != null)
  4525. {
  4526. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4527. }
  4528. else
  4529. {
  4530. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4531. }
  4532. }
  4533. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4534. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4535. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4536. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4537. string name = "";
  4538. foreach (string clientName in nameArray)
  4539. {
  4540. if (!name.Contains(clientName))
  4541. {
  4542. name += clientName + ",";
  4543. }
  4544. }
  4545. if (!string.IsNullOrWhiteSpace(name))
  4546. {
  4547. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4548. }
  4549. else
  4550. {
  4551. table.Range.Bookmarks["ClientName"].Text = "--";
  4552. }
  4553. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4554. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4555. table.Range.Bookmarks["JointTicket"].Text = "--";
  4556. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4557. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4558. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4559. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4560. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4561. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4562. #endregion
  4563. #region 循环数据处理
  4564. var airs = new List<AirInfo>();
  4565. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4566. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4567. for (int i = 0; i < FlightsCode.Length; i++)
  4568. {
  4569. var air = new AirInfo();
  4570. string[] tempstr = DayArray[i]
  4571. .Replace("\r\n", string.Empty)
  4572. .Replace("\\r\\n", string.Empty)
  4573. .TrimStart().TrimEnd()
  4574. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4575. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4576. string starCity = "";
  4577. if (star_Three != null)
  4578. {
  4579. starCity = star_Three.AirPort;
  4580. }
  4581. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4582. string EndCity = "";
  4583. if (End_Three != null)
  4584. {
  4585. EndCity = End_Three.AirPort;
  4586. }
  4587. air.Destination = starCity + "/" + EndCity;
  4588. air.Flight = FlightsCode[i];
  4589. air.SeatingClass = item.CTypeName;
  4590. string dateTime = tempstr[2];
  4591. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4592. air.FlightDate = DateTemp;
  4593. air.DepartureTime = tempstr[5];
  4594. air.LandingTime = tempstr[6];
  4595. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4596. air.TicketStatus = "--";
  4597. air.Luggage = "--";
  4598. air.DepartureTerminal = "--";
  4599. air.LandingTerminal = "--";
  4600. airs.Add(air);
  4601. }
  4602. int row = 13;
  4603. for (int i = 0; i < airs.Count; i++)
  4604. {
  4605. if (airs.Count > 2)
  4606. {
  4607. for (int j = 0; j < airs.Count - 2; j++)
  4608. {
  4609. var CopyRow = table.Rows[12].Clone(true);
  4610. table.Rows.Add(CopyRow);
  4611. }
  4612. }
  4613. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4614. int index = 0;
  4615. foreach (PropertyInfo property in properties)
  4616. {
  4617. string value = property.GetValue(airs[i]).ToString();
  4618. Cell ishcel0 = table.Rows[row].Cells[index];
  4619. var p = new Paragraph(doc);
  4620. string s = value;
  4621. p.AppendChild(new Run(doc, s));
  4622. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4623. ishcel0.AppendChild(p);
  4624. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4625. index++;
  4626. }
  4627. row++;
  4628. }
  4629. #endregion
  4630. var lastParagraph = new Paragraph(doc);
  4631. //第一个表格末尾加段落
  4632. table.ParentNode.InsertAfter(lastParagraph, table);
  4633. //复制第一个表格
  4634. Table cloneTable = (Table)table.Clone(true);
  4635. //在文档末尾段落后面加入复制的表格
  4636. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4637. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4638. {
  4639. int rownewsIndex = 13;
  4640. for (int i = 0; i < 2; i++)
  4641. {
  4642. var CopyRow = table.Rows[12].Clone(true);
  4643. table.Rows.RemoveAt(13);
  4644. table.Rows.Add(CopyRow);
  4645. rownewsIndex++;
  4646. }
  4647. }
  4648. else
  4649. {
  4650. table.Rows.RemoveAt(12);
  4651. }
  4652. cloneTable.Rows.RemoveAt(12);
  4653. }
  4654. if (_AirTicketReservations.Count != 0)
  4655. {
  4656. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4657. if (FlightsCode.Length != 0)
  4658. {
  4659. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4660. if (_AirCompany != null)
  4661. {
  4662. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4663. }
  4664. else
  4665. {
  4666. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4667. }
  4668. }
  4669. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4670. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4671. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4672. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4673. string name = "";
  4674. foreach (string clientName in nameArray)
  4675. {
  4676. if (!name.Contains(clientName))
  4677. {
  4678. name += clientName + ",";
  4679. }
  4680. }
  4681. if (!string.IsNullOrWhiteSpace(name))
  4682. {
  4683. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4684. }
  4685. else
  4686. {
  4687. table.Range.Bookmarks["ClientName"].Text = "--";
  4688. }
  4689. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4690. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4691. table.Range.Bookmarks["JointTicket"].Text = "--";
  4692. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4693. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4694. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4695. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4696. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4697. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4698. }
  4699. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4700. //保存合并后的文档
  4701. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4702. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4703. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4704. return Ok(JsonView(true, "成功!", rst));
  4705. }
  4706. else
  4707. {
  4708. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4709. var builder = new DocumentBuilder(doc);
  4710. int tableIndex = 0;//表格索引
  4711. //得到文档中的第一个表格
  4712. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4713. var texts = new List<string>();
  4714. foreach (var item in _AirTicketReservations)
  4715. {
  4716. string[] FlightsCode = item.FlightsCode.Split('/');
  4717. if (FlightsCode.Length != 0)
  4718. {
  4719. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4720. if (_AirCompany != null)
  4721. {
  4722. if (!transDic.ContainsKey(_AirCompany.CnName))
  4723. {
  4724. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4725. }
  4726. }
  4727. else
  4728. {
  4729. if (!transDic.ContainsKey("--"))
  4730. {
  4731. transDic.Add("--", "--");
  4732. }
  4733. }
  4734. }
  4735. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4736. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4737. string name = "";
  4738. foreach (string clientName in nameArray)
  4739. {
  4740. name += clientName + ",";
  4741. }
  4742. if (!texts.Contains(name))
  4743. {
  4744. texts.Add(name);
  4745. }
  4746. var airs = new List<AirInfo>();
  4747. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4748. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4749. for (int i = 0; i < FlightsCode.Length; i++)
  4750. {
  4751. var air = new AirInfo();
  4752. string[] tempstr = DayArray[i]
  4753. .Replace("\r\n", string.Empty)
  4754. .Replace("\\r\\n", string.Empty)
  4755. .TrimStart().TrimEnd()
  4756. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4757. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4758. if (star_Three != null)
  4759. {
  4760. if (!transDic.ContainsKey(star_Three.AirPort))
  4761. {
  4762. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4763. }
  4764. }
  4765. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4766. if (End_Three != null)
  4767. {
  4768. if (!transDic.ContainsKey(End_Three.AirPort))
  4769. {
  4770. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4771. }
  4772. }
  4773. if (!texts.Contains(item.CTypeName))
  4774. {
  4775. texts.Add(item.CTypeName);
  4776. }
  4777. }
  4778. }
  4779. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4780. if (transData.Count > 0)
  4781. {
  4782. foreach (TranslateResult item in transData)
  4783. {
  4784. if (!transDic.ContainsKey(item.Query))
  4785. {
  4786. transDic.Add(item.Query, item.Translation);
  4787. }
  4788. }
  4789. }
  4790. foreach (var item in _AirTicketReservations)
  4791. {
  4792. #region 处理固定数据
  4793. string[] FlightsCode = item.FlightsCode.Split('/');
  4794. if (FlightsCode.Length != 0)
  4795. {
  4796. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4797. if (_AirCompany != null)
  4798. {
  4799. string str = "--";
  4800. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4801. if (!string.IsNullOrEmpty(translateResult))
  4802. {
  4803. str = translateResult;
  4804. str = _airTicketResRep.Processing(str);
  4805. }
  4806. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4807. }
  4808. else
  4809. {
  4810. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4811. }
  4812. }
  4813. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4814. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4815. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4816. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4817. string names = "";
  4818. foreach (string clientName in nameArray)
  4819. {
  4820. names += clientName + ",";
  4821. }
  4822. if (!string.IsNullOrWhiteSpace(names))
  4823. {
  4824. string str = "--";
  4825. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4826. if (!string.IsNullOrEmpty(translateResult))
  4827. {
  4828. str = translateResult;
  4829. str = _airTicketResRep.Processing(str);
  4830. }
  4831. table.Range.Bookmarks["ClientName"].Text = str;
  4832. }
  4833. else
  4834. {
  4835. table.Range.Bookmarks["ClientName"].Text = "--";
  4836. }
  4837. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4838. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4839. table.Range.Bookmarks["JointTicket"].Text = "--";
  4840. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4841. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4842. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4843. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4844. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4845. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4846. #endregion
  4847. #region 循环数据处理
  4848. var airs = new List<AirInfo>();
  4849. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4850. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4851. for (int i = 0; i < FlightsCode.Length; i++)
  4852. {
  4853. var air = new AirInfo();
  4854. string[] tempstr = DayArray[i]
  4855. .Replace("\r\n", string.Empty)
  4856. .Replace("\\r\\n", string.Empty)
  4857. .TrimStart().TrimEnd()
  4858. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4859. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4860. string starCity = "";
  4861. if (star_Three != null)
  4862. {
  4863. string str2 = "--";
  4864. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4865. if (!string.IsNullOrEmpty(translateResult2))
  4866. {
  4867. str2 = translateResult2;
  4868. str2 = _airTicketResRep.Processing(str2);
  4869. }
  4870. starCity = str2;
  4871. }
  4872. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4873. string EndCity = "";
  4874. if (End_Three != null)
  4875. {
  4876. string str1 = "--";
  4877. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4878. if (!string.IsNullOrEmpty(translateResult1))
  4879. {
  4880. str1 = translateResult1;
  4881. str1 = _airTicketResRep.Processing(str1);
  4882. }
  4883. EndCity = str1;
  4884. }
  4885. air.Destination = starCity + "/" + EndCity;
  4886. air.Flight = FlightsCode[i];
  4887. string str = "--";
  4888. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4889. if (!string.IsNullOrEmpty(translateResult))
  4890. {
  4891. str = translateResult;
  4892. str = _airTicketResRep.Processing(str);
  4893. }
  4894. air.SeatingClass = str;
  4895. string dateTime = tempstr[2];
  4896. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4897. air.FlightDate = DateTemp;
  4898. air.DepartureTime = tempstr[5];
  4899. air.LandingTime = tempstr[6];
  4900. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4901. air.TicketStatus = "--";
  4902. air.Luggage = "--";
  4903. air.DepartureTerminal = "--";
  4904. air.LandingTerminal = "--";
  4905. airs.Add(air);
  4906. }
  4907. int row = 13;
  4908. for (int i = 0; i < airs.Count; i++)
  4909. {
  4910. if (airs.Count > 2)
  4911. {
  4912. for (int j = 0; j < airs.Count - 2; j++)
  4913. {
  4914. var CopyRow = table.Rows[12].Clone(true);
  4915. table.Rows.Add(CopyRow);
  4916. }
  4917. }
  4918. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4919. int index = 0;
  4920. foreach (PropertyInfo property in properties)
  4921. {
  4922. string value = property.GetValue(airs[i]).ToString();
  4923. Cell ishcel0 = table.Rows[row].Cells[index];
  4924. var p = new Paragraph(doc);
  4925. string s = value;
  4926. p.AppendChild(new Run(doc, s));
  4927. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4928. ishcel0.AppendChild(p);
  4929. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4930. //ishcel0.CellFormat.VerticalAlignment=
  4931. index++;
  4932. }
  4933. row++;
  4934. }
  4935. #endregion
  4936. var lastParagraph = new Paragraph(doc);
  4937. //第一个表格末尾加段落
  4938. table.ParentNode.InsertAfter(lastParagraph, table);
  4939. //复制第一个表格
  4940. Table cloneTable = (Table)table.Clone(true);
  4941. //在文档末尾段落后面加入复制的表格
  4942. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4943. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4944. {
  4945. int rownewsIndex = 13;
  4946. for (int i = 0; i < 2; i++)
  4947. {
  4948. var CopyRow = table.Rows[12].Clone(true);
  4949. table.Rows.RemoveAt(13);
  4950. table.Rows.Add(CopyRow);
  4951. rownewsIndex++;
  4952. }
  4953. }
  4954. else
  4955. {
  4956. table.Rows.RemoveAt(12);
  4957. }
  4958. cloneTable.Rows.RemoveAt(12);
  4959. }
  4960. if (_AirTicketReservations.Count != 0)
  4961. {
  4962. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4963. if (FlightsCode.Length != 0)
  4964. {
  4965. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4966. if (_AirCompany != null)
  4967. {
  4968. string str = "--";
  4969. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4970. if (!string.IsNullOrEmpty(translateResult))
  4971. {
  4972. str = translateResult;
  4973. str = _airTicketResRep.Processing(str);
  4974. }
  4975. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4976. }
  4977. else
  4978. {
  4979. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4980. }
  4981. }
  4982. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4983. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4984. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4985. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4986. string names = "";
  4987. foreach (string clientName in nameArray)
  4988. {
  4989. names += clientName + ",";
  4990. }
  4991. if (!string.IsNullOrWhiteSpace(names))
  4992. {
  4993. string str = "--";
  4994. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4995. if (!string.IsNullOrEmpty(translateResult))
  4996. {
  4997. str = translateResult;
  4998. str = _airTicketResRep.Processing(str);
  4999. }
  5000. table.Range.Bookmarks["ClientName"].Text = str;
  5001. }
  5002. else
  5003. {
  5004. table.Range.Bookmarks["ClientName"].Text = "--";
  5005. }
  5006. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5007. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5008. table.Range.Bookmarks["JointTicket"].Text = "--";
  5009. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5010. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5011. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5012. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5013. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5014. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5015. }
  5016. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5017. //保存合并后的文档
  5018. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5019. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5020. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5021. return Ok(JsonView(true, "成功!", rst));
  5022. }
  5023. }
  5024. }
  5025. catch (Exception ex)
  5026. {
  5027. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5028. throw;
  5029. }
  5030. }
  5031. #endregion
  5032. #region 团组增减款项 --> 其他款项
  5033. /// <summary>
  5034. /// 团组增减款项下拉框绑定
  5035. /// </summary>
  5036. /// <param name="dto"></param>
  5037. /// <returns></returns>
  5038. [HttpPost]
  5039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5040. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5041. {
  5042. #region 参数验证
  5043. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5044. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5045. #endregion
  5046. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5047. }
  5048. /// <summary>
  5049. /// 根据团组Id查询团组增减款项
  5050. /// </summary>
  5051. /// <param name="dto"></param>
  5052. /// <returns></returns>
  5053. [HttpPost]
  5054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5055. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5056. {
  5057. #region 参数验证
  5058. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5059. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5060. #endregion
  5061. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5062. }
  5063. /// <summary>
  5064. /// 团组增减款项操作(Status:1.新增,2.修改)
  5065. /// </summary>
  5066. /// <param name="dto"></param>
  5067. /// <returns></returns>
  5068. [HttpPost]
  5069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5070. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5071. {
  5072. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5073. if (groupData.Code != 200)
  5074. {
  5075. return Ok(JsonView(false, groupData.Msg));
  5076. }
  5077. #region 应用推送
  5078. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5079. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5080. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5081. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5082. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5083. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5084. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5085. if (recheck)
  5086. {
  5087. //自动审核
  5088. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5089. }
  5090. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5091. //2024-10-21 新增LZ UID
  5092. var userIds = new List<int>() { 21 };
  5093. string title = $"系统通知";
  5094. string content = "";
  5095. var diId = dto.DiId;
  5096. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5097. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5098. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5099. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5100. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5101. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5102. #endregion
  5103. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5104. }
  5105. /// <summary>
  5106. /// 团组增减款项操作 删除
  5107. /// </summary>
  5108. /// <param name="dto"></param>
  5109. /// <returns></returns>
  5110. [HttpPost]
  5111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5112. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5113. {
  5114. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5115. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5116. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5117. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5118. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5119. }
  5120. /// <summary>
  5121. /// 根据团组增减款项Id查询
  5122. /// </summary>
  5123. /// <param name="dto"></param>
  5124. /// <returns></returns>
  5125. [HttpPost]
  5126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5127. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5128. {
  5129. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5130. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5131. }
  5132. /// <summary>
  5133. /// 查询供应商名称
  5134. /// </summary>
  5135. /// <param name="dto"></param>
  5136. /// <returns></returns>
  5137. [HttpPost]
  5138. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5139. {
  5140. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5141. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5142. ?? new List<Grp_DecreasePayments>();
  5143. dbResult = dbResult.Distinct(new
  5144. ProductComparer()).ToList();
  5145. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5146. {
  5147. x.Id,
  5148. x.SupplierAddress,
  5149. x.SupplierArea,
  5150. x.SupplierContact,
  5151. x.SupplierContactNumber,
  5152. x.SupplierEmail,
  5153. x.SupplierName,
  5154. x.SupplierSocialAccount,
  5155. x.SupplierTypeId,
  5156. }).ToList());
  5157. return Ok(jw);
  5158. }
  5159. /// <summary>
  5160. /// 团组增减款项 OTA匹配
  5161. /// </summary>
  5162. /// <param name="file"></param>
  5163. /// <returns></returns>
  5164. [HttpPost]
  5165. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5166. {
  5167. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5168. string fileName = file.FileName;
  5169. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5170. {
  5171. return Ok(JsonView(false, "请上传Excel文件!"));
  5172. }
  5173. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5174. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5175. if (!Directory.Exists(path))
  5176. {
  5177. Directory.CreateDirectory(path);
  5178. }
  5179. var filePath = @$"{path}/{fileName}";
  5180. //保存文件
  5181. using (FileStream fs = System.IO.File.Create(filePath))
  5182. {
  5183. file.CopyTo(fs);
  5184. fs.Flush();
  5185. }
  5186. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5187. //读取ExcelFile
  5188. DataTable dt = ConvertExcelToDataTable(filePath);
  5189. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5190. dt.TableName = "TB";
  5191. //修改table列名
  5192. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5193. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5194. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5195. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5196. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5197. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5198. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5199. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5200. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5201. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5202. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5203. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5204. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5205. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5206. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5207. var otaOrderNos = new List<string>();
  5208. foreach (DataRow item in dt.Rows)
  5209. {
  5210. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5211. }
  5212. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5213. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  5214. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  5215. .Select((dp, di) => new
  5216. {
  5217. dp.PriceName,
  5218. dp.OTAOrderNo,
  5219. dp.FeeTotal,
  5220. di.TeamName,
  5221. })
  5222. .ToListAsync();
  5223. foreach (DataRow item in dt.Rows)
  5224. {
  5225. var otaOrderNo = item["OTAOrderNo"].ToString();
  5226. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  5227. if (oaData == null) continue;
  5228. item["GroupName"] = oaData.TeamName;
  5229. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  5230. }
  5231. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  5232. var pairs = new Dictionary<string, object>();
  5233. var datas = new List<DataTable>
  5234. {
  5235. dt
  5236. };
  5237. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  5238. return Ok(JsonView(true, "操作成功", new { url }));
  5239. }
  5240. #region
  5241. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  5242. {
  5243. // 创建Workbook对象
  5244. var workbook = new Workbook(excelFilePath);
  5245. // 获取第一个工作表
  5246. var worksheet = workbook.Worksheets[0];
  5247. // 将工作表转换为DataTable
  5248. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  5249. return dataTable;
  5250. }
  5251. #endregion
  5252. /// <summary>
  5253. /// 世运会数据
  5254. /// </summary>
  5255. /// <returns></returns>
  5256. [HttpGet]
  5257. public IActionResult WorldGamesData()
  5258. {
  5259. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  5260. var groupMenu = setData.GroupBy(x => x.T0);
  5261. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  5262. foreach (var item in groupMenu)
  5263. {
  5264. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  5265. {
  5266. Data = new SetDataView
  5267. {
  5268. Name = item.Key
  5269. },
  5270. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  5271. });
  5272. }
  5273. return Ok(JsonView(true, "success", resultArr));
  5274. }
  5275. #endregion
  5276. #region 文件上传、删除
  5277. /// <summary>
  5278. /// region 文件上传 可以带参数
  5279. /// </summary>
  5280. /// <param name="file"></param>
  5281. /// <returns></returns>
  5282. [HttpPost]
  5283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5284. public async Task<IActionResult> UploadProject(IFormFile file)
  5285. {
  5286. //var TypeName = Request.Headers["TypeName"].ToString();
  5287. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  5288. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5289. ////文件名称
  5290. //string projectFileName = file.FileName;
  5291. ////上传的文件的路径
  5292. //string filePath = $"{fileDir}/{projectFileName}";
  5293. //if (TypeName == "A")//A代表团组增减款项
  5294. //{
  5295. // filePath = fileDir + $@"\团组增减款项相关文件";
  5296. // if (!Directory.Exists(filePath))
  5297. // {
  5298. // Directory.CreateDirectory(filePath);
  5299. // }
  5300. // //上传的文件的路径
  5301. // filePath += $@"\{projectFileName}";
  5302. //}
  5303. //else if (TypeName == "B")//B代表商邀相关文件
  5304. //{
  5305. // //上传的文件的路径
  5306. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5307. // if (!Directory.Exists(filePath))
  5308. // {
  5309. // Directory.CreateDirectory(filePath);
  5310. // }
  5311. // //上传的文件的路径
  5312. // filePath = $@"\{projectFileName}";
  5313. //}
  5314. //try
  5315. //{
  5316. // using (FileStream fs = System.IO.File.Create(filePath))
  5317. // {
  5318. // file.CopyTo(fs);
  5319. // fs.Flush();
  5320. // }
  5321. //}
  5322. //catch (Exception ex)
  5323. //{
  5324. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  5325. //}
  5326. //return Ok(JsonView(true, "上传成功!", projectFileName));
  5327. try
  5328. {
  5329. var TypeName = Request.Headers["TypeName"].ToString();
  5330. if (file != null)
  5331. {
  5332. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5333. //文件名称
  5334. string projectFileName = file.FileName;
  5335. //上传的文件的路径
  5336. string filePath = $"{fileDir}/{projectFileName}";
  5337. if (TypeName == "A")//A代表团组增减款项
  5338. {
  5339. if (!Directory.Exists(fileDir))
  5340. {
  5341. Directory.CreateDirectory(fileDir);
  5342. }
  5343. //上传的文件的路径
  5344. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5345. }
  5346. else if (TypeName == "B")//B代表商邀相关文件
  5347. {
  5348. if (!Directory.Exists(fileDir))
  5349. {
  5350. Directory.CreateDirectory(fileDir);
  5351. }
  5352. //上传的文件的路径
  5353. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5354. }
  5355. using (FileStream fs = System.IO.File.Create(filePath))
  5356. {
  5357. file.CopyTo(fs);
  5358. fs.Flush();
  5359. }
  5360. return Ok(JsonView(true, "上传成功!", projectFileName));
  5361. }
  5362. else
  5363. {
  5364. return Ok(JsonView(false, "上传失败!"));
  5365. }
  5366. }
  5367. catch (Exception ex)
  5368. {
  5369. return Ok(JsonView(false, ex.Message));
  5370. }
  5371. }
  5372. /// <summary>
  5373. /// 删除指定文件
  5374. /// </summary>
  5375. /// <param name="dto"></param>
  5376. /// <returns></returns>
  5377. [HttpPost]
  5378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5379. public async Task<IActionResult> DelFile(DelFileDto dto)
  5380. {
  5381. try
  5382. {
  5383. var TypeName = Request.Headers["TypeName"].ToString();
  5384. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5385. string filePath = "";
  5386. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5387. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5388. int id = 0;
  5389. if (TypeName == "A")
  5390. {
  5391. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5392. // 删除该文件
  5393. System.IO.File.Delete(filePath);
  5394. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5395. .Where(a => a.Id == dto.Id)
  5396. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5397. .ExecuteCommandAsync();
  5398. }
  5399. else if (TypeName == "B")
  5400. {
  5401. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5402. // 删除该文件
  5403. System.IO.File.Delete(filePath);
  5404. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5405. if (info != null)
  5406. {
  5407. string[] files = Array.Empty<string>();
  5408. if (!string.IsNullOrEmpty(info.Attachment))
  5409. {
  5410. try
  5411. {
  5412. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5413. }
  5414. catch (Exception)
  5415. {
  5416. files = new List<string>() { info.Attachment }.ToArray();
  5417. }
  5418. }
  5419. if (files.Length > 0)
  5420. {
  5421. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5422. string filePath2 = string.Empty;
  5423. if (files1.Length > 0)
  5424. {
  5425. filePath2 = JsonConvert.SerializeObject(files1);
  5426. }
  5427. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5428. .Where(a => a.Id == dto.Id)
  5429. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5430. .ExecuteCommandAsync();
  5431. }
  5432. }
  5433. }
  5434. if (id != 0)
  5435. {
  5436. return Ok(JsonView(true, "成功!"));
  5437. }
  5438. else
  5439. {
  5440. return Ok(JsonView(false, "失败!"));
  5441. }
  5442. }
  5443. catch (Exception ex)
  5444. {
  5445. return Ok(JsonView(false, "程序错误!"));
  5446. throw;
  5447. }
  5448. }
  5449. /// <summary>
  5450. /// 文件上传多个文件 可以带参数
  5451. /// </summary>
  5452. /// <param name="files"></param>
  5453. /// <returns></returns>
  5454. [HttpPost]
  5455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5456. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5457. {
  5458. try
  5459. {
  5460. var TypeName = Request.Headers["TypeName"].ToString();
  5461. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5462. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5463. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5464. var filePahts = new List<string>();
  5465. foreach (var file in files)
  5466. {
  5467. //文件名称
  5468. string projectFileName = file.FileName;
  5469. //上传的文件的路径
  5470. string filePath = $"{fileDir}/{projectFileName}";
  5471. if (TypeName == "A")//A代表团组增减款项
  5472. {
  5473. if (!Directory.Exists(fileDir))
  5474. {
  5475. Directory.CreateDirectory(fileDir);
  5476. }
  5477. //上传的文件的路径
  5478. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5479. }
  5480. else if (TypeName == "B")//B代表商邀相关文件
  5481. {
  5482. if (!Directory.Exists(fileDir))
  5483. {
  5484. Directory.CreateDirectory(fileDir);
  5485. }
  5486. //上传的文件的路径
  5487. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5488. }
  5489. using (FileStream fs = System.IO.File.Create(filePath))
  5490. {
  5491. file.CopyTo(fs);
  5492. fs.Flush();
  5493. }
  5494. filePahts.Add(projectFileName);
  5495. }
  5496. return Ok(JsonView(true, "上传成功!", filePahts));
  5497. }
  5498. catch (Exception ex)
  5499. {
  5500. return Ok(JsonView(false, ex.Message));
  5501. }
  5502. }
  5503. #endregion
  5504. #region 商邀费用录入
  5505. /// <summary>
  5506. /// 根据团组Id查询商邀费用列表
  5507. /// </summary>
  5508. /// <param name="dto"></param>
  5509. /// <returns></returns>
  5510. [HttpPost]
  5511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5512. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5513. {
  5514. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5515. if (groupData.Code != 0)
  5516. {
  5517. return Ok(JsonView(false, groupData.Msg));
  5518. }
  5519. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5520. }
  5521. /// <summary>
  5522. /// 商邀费用列表
  5523. /// 下载文件
  5524. /// </summary>
  5525. /// <param name="id"></param>
  5526. /// <returns></returns>
  5527. [HttpGet("{id}")]
  5528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5529. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5530. {
  5531. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5532. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5533. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5534. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5535. var filePaths = new List<string>();
  5536. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5537. try
  5538. {
  5539. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. filePaths.Add(info.Attachment);
  5544. }
  5545. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5546. for (int i = 0; i < filePaths.Count; i++)
  5547. {
  5548. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5549. }
  5550. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5551. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5552. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5553. {
  5554. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5555. {
  5556. foreach (string filePath in filePaths)
  5557. {
  5558. if (System.IO.File.Exists(filePath))
  5559. {
  5560. // 获取文件名
  5561. string fileName = Path.GetFileName(filePath);
  5562. // 将文件添加到ZIP归档中
  5563. zipArchive.CreateEntryFromFile(filePath, fileName);
  5564. }
  5565. }
  5566. }
  5567. }
  5568. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5569. }
  5570. /// <summary>
  5571. /// 商邀费用 Info Page 基础数据源
  5572. /// </summary>
  5573. /// <returns></returns>
  5574. [HttpPost]
  5575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5576. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5577. {
  5578. try
  5579. {
  5580. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  5581. if (groupData.Code != 0)
  5582. {
  5583. return Ok(JsonView(false, groupData.Msg));
  5584. }
  5585. return Ok(JsonView(true, "操作成功", groupData.Data));
  5586. }
  5587. catch (Exception ex)
  5588. {
  5589. return Ok(JsonView(false, ex.Message));
  5590. throw;
  5591. }
  5592. }
  5593. /// <summary>
  5594. /// 根据商邀费用ID查询C表和商邀费用数据
  5595. /// </summary>
  5596. /// <param name="dto"></param>
  5597. /// <returns></returns>
  5598. [HttpPost]
  5599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5600. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5601. {
  5602. try
  5603. {
  5604. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5605. if (groupData.Code != 0)
  5606. {
  5607. return Ok(JsonView(false, groupData.Msg));
  5608. }
  5609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5610. }
  5611. catch (Exception ex)
  5612. {
  5613. return Ok(JsonView(false, ex.Message));
  5614. throw;
  5615. }
  5616. }
  5617. /// <summary>
  5618. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5619. /// </summary>
  5620. /// <param name="dto"></param>
  5621. /// <returns></returns>
  5622. [HttpPost]
  5623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5624. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5625. {
  5626. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5627. if (groupData.Code != 0)
  5628. {
  5629. return Ok(JsonView(false, groupData.Msg));
  5630. }
  5631. #region 应用推送
  5632. try
  5633. {
  5634. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5635. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5636. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5637. //2024-10-21 新增LZ UID
  5638. var userIds = new List<int>() { 21 };
  5639. string title = $"系统通知";
  5640. string content = "";
  5641. var diId = dto.DiId;
  5642. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5643. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5644. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5645. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5646. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5647. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5648. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5649. }
  5650. catch (Exception ex)
  5651. {
  5652. }
  5653. #endregion
  5654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5655. }
  5656. /// <summary>
  5657. /// 商邀删除
  5658. /// </summary>
  5659. /// <param name="dto"></param>
  5660. /// <returns></returns>
  5661. [HttpPost]
  5662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5663. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5664. {
  5665. try
  5666. {
  5667. _sqlSugar.BeginTran();
  5668. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5669. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5670. {
  5671. IsDel = 1,
  5672. DeleteUserId = dto.DeleteUserId,
  5673. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5674. })
  5675. .Where(it => it.Id == dto.Id)
  5676. .ExecuteCommand();
  5677. if (res1 > 0)
  5678. {
  5679. int _diId = 0;
  5680. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5681. if (_ioaInfo != null)
  5682. {
  5683. _diId = _ioaInfo.DiId;
  5684. }
  5685. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5686. .SetColumns(a => new Grp_CreditCardPayment()
  5687. {
  5688. IsDel = 1,
  5689. DeleteUserId = dto.DeleteUserId,
  5690. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5691. })
  5692. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5693. .ExecuteCommand();
  5694. if (res2 > 0)
  5695. {
  5696. _sqlSugar.CommitTran();
  5697. return Ok(JsonView(true, "删除成功!"));
  5698. }
  5699. }
  5700. _sqlSugar.RollbackTran();
  5701. return Ok(JsonView(false, "删除失败"));
  5702. }
  5703. catch (Exception ex)
  5704. {
  5705. _sqlSugar.RollbackTran();
  5706. return Ok(JsonView(false, ex.Message));
  5707. }
  5708. }
  5709. #endregion
  5710. #region 票据上传
  5711. /// <summary>
  5712. /// 团组模块文件上传
  5713. /// </summary>
  5714. /// <param name="dto"></param>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5718. {
  5719. var jw = JsonView(false);
  5720. long M = 1024 * 1024;
  5721. if (dto.Files == null || dto.Files.Count == 0)
  5722. {
  5723. jw.Msg = "无文件信息!";
  5724. return Ok(jw);
  5725. }
  5726. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5727. {
  5728. jw.Msg = "文件大小超过20M!";
  5729. return Ok(jw);
  5730. }
  5731. //var nameSp = dto.File.FileName.Split(".");
  5732. //if (nameSp.Length < 2)
  5733. //{
  5734. // jw.Msg = "拓展名称有误!";
  5735. // return Ok(jw);
  5736. //}
  5737. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5738. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5739. //{
  5740. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5741. // return Ok(jw);
  5742. //}
  5743. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5744. if (Ctable == null)
  5745. {
  5746. jw.Msg = "Ctable指向有误!";
  5747. return Ok(jw);
  5748. }
  5749. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5750. if (groupInfo == null)
  5751. {
  5752. jw.Msg = "团组信息不存在!";
  5753. return Ok(jw);
  5754. }
  5755. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5756. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5757. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5758. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5759. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5760. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5761. try
  5762. {
  5763. if (!Directory.Exists(fileBase))
  5764. {
  5765. Directory.CreateDirectory(fileBase);
  5766. }
  5767. var saveArr = new List<Grp_GroupModelFile>();
  5768. foreach (var fileStream in dto.Files)
  5769. {
  5770. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5771. var file = new Grp_GroupModelFile()
  5772. {
  5773. Cid = dto.Cid,
  5774. CreateTime = DateTime.Now,
  5775. CreateUserId = dto.Userid,
  5776. Ctable = dto.Ctable,
  5777. Diid = dto.Diid,
  5778. IsDel = 0,
  5779. FilePath = saveFilePath,
  5780. FileName = fileStream.FileName
  5781. };
  5782. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5783. {
  5784. fileStream.CopyTo(fs);
  5785. fs.Flush();
  5786. }
  5787. saveArr.Add(file);
  5788. }
  5789. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5790. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5791. jw = JsonView(true, "保存成功!", new
  5792. {
  5793. count = addResult,
  5794. filesName = saveArr.Select(x => x.FileName)
  5795. });
  5796. }
  5797. catch (Exception ex)
  5798. {
  5799. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5800. {
  5801. count = 0,
  5802. filesName = Array.Empty<string>(),
  5803. });
  5804. }
  5805. return Ok(jw);
  5806. }
  5807. /// <summary>
  5808. /// 查询各模块已保存文件
  5809. /// </summary>
  5810. /// <param name="dto"></param>
  5811. /// <returns></returns>
  5812. [HttpPost]
  5813. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5814. {
  5815. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5816. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5817. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5818. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5819. {
  5820. expression = Expressionable.Create<Grp_GroupModelFile>()
  5821. .And(x => visaIds.Contains(x.CreateUserId));
  5822. }
  5823. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5824. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5825. .Where(expression.ToExpression())
  5826. .ToList();
  5827. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5828. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5829. {
  5830. x.FileName,
  5831. x.Id,
  5832. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5833. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5834. })));
  5835. }
  5836. /// <summary>
  5837. /// 下载该团组下的所有文件
  5838. /// </summary>
  5839. /// <param name="dto"></param>
  5840. /// <returns></returns>
  5841. [HttpPost]
  5842. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5843. {
  5844. var jw = JsonView(false);
  5845. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5846. if (groupInfo == null)
  5847. {
  5848. jw.Msg = "团组信息不存在!";
  5849. return Ok(jw);
  5850. }
  5851. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5852. var isModule = Convert.ToBoolean(dto.isModule);
  5853. var Zips = new Dictionary<string, Stream>();
  5854. var io = new IOOperatorHelper();
  5855. if (isModule)
  5856. {
  5857. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5858. foreach (var moduleArr in moduleGroup)
  5859. {
  5860. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5861. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5862. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5863. var chiZips = new Dictionary<string, Stream>();
  5864. foreach (var item in moduleArr)
  5865. {
  5866. if (System.IO.File.Exists(item.FilePath))
  5867. {
  5868. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5869. {
  5870. byte[] bytes = new byte[fileStream.Length];
  5871. fileStream.Read(bytes, 0, bytes.Length);
  5872. fileStream.Close();
  5873. Stream stream = new MemoryStream(bytes);
  5874. chiZips.Add(item.FileName, stream);
  5875. }
  5876. }
  5877. }
  5878. if (chiZips.Count > 0)
  5879. {
  5880. var byts = io.ConvertZipStream(chiZips);
  5881. Stream stream = new MemoryStream(byts);
  5882. Zips.Add(key.Name + "_.zip", stream);
  5883. }
  5884. }
  5885. }
  5886. else
  5887. {
  5888. foreach (var item in dbQuery)
  5889. {
  5890. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5891. {
  5892. byte[] bytes = new byte[fileStream.Length];
  5893. fileStream.Read(bytes, 0, bytes.Length);
  5894. fileStream.Close();
  5895. var stream = new MemoryStream(bytes);
  5896. while (Zips.ContainsKey(item.FileName))
  5897. {
  5898. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5899. }
  5900. Zips.Add(item.FileName, stream);
  5901. }
  5902. }
  5903. }
  5904. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5905. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5906. if (Zips.Count > 0)
  5907. {
  5908. var byts = io.ConvertZipStream(Zips);
  5909. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5910. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5911. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5912. }
  5913. else
  5914. {
  5915. jw.Msg = "暂无生成文件!";
  5916. }
  5917. return Ok(jw);
  5918. }
  5919. /// <summary>
  5920. /// 下载该团组下此模块的所有文件
  5921. /// </summary>
  5922. /// <param name="dto"></param>
  5923. /// <returns></returns>
  5924. [HttpPost]
  5925. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5926. {
  5927. var jw = JsonView(false);
  5928. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5929. if (groupInfo == null)
  5930. {
  5931. jw.Msg = "团组信息不存在!";
  5932. return Ok(jw);
  5933. }
  5934. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5935. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5936. && x.IsDel == 0);
  5937. if (key == null)
  5938. {
  5939. jw.Msg = "Ctable指向错误!";
  5940. return Ok(jw);
  5941. }
  5942. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5943. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5944. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5945. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5946. var io = new IOOperatorHelper();
  5947. var Zips = new Dictionary<string, Stream>();
  5948. foreach (var item in dbQuery)
  5949. {
  5950. if (System.IO.File.Exists(item.FilePath))
  5951. {
  5952. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5953. {
  5954. byte[] bytes = new byte[fileStream.Length];
  5955. fileStream.Read(bytes, 0, bytes.Length);
  5956. fileStream.Close();
  5957. var stream = new MemoryStream(bytes);
  5958. while (Zips.ContainsKey(item.FileName))
  5959. {
  5960. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5961. }
  5962. Zips.Add(item.FileName, stream);
  5963. }
  5964. }
  5965. }
  5966. if (Zips.Count > 0)
  5967. {
  5968. var byts = io.ConvertZipStream(Zips);
  5969. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5970. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5971. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5972. }
  5973. else
  5974. {
  5975. jw.Msg = "暂无生成文件!";
  5976. }
  5977. return Ok(jw);
  5978. }
  5979. /// <summary>
  5980. /// 删除该团组下的指定文件
  5981. /// </summary>
  5982. /// <param name="dto"></param>
  5983. /// <returns></returns>
  5984. [HttpPost]
  5985. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5986. {
  5987. var jw = JsonView(false);
  5988. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5989. if (sing == null)
  5990. {
  5991. jw.Msg = "暂无";
  5992. return Ok(jw);
  5993. }
  5994. if (System.IO.File.Exists(sing.FilePath))
  5995. {
  5996. try
  5997. {
  5998. System.IO.File.Delete(sing.FilePath);
  5999. }
  6000. catch (Exception ex)
  6001. {
  6002. jw.Msg = "删除失败!" + ex.Message;
  6003. return Ok(jw);
  6004. }
  6005. }
  6006. sing.IsDel = 1;
  6007. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6008. sing.DeleteUserId = dto.UserId;
  6009. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6010. jw = JsonView(true, "删除成功!");
  6011. return Ok(jw);
  6012. }
  6013. #endregion
  6014. #region 共享文件上传
  6015. /// <summary>
  6016. /// 共享文件数据初始化
  6017. /// </summary>
  6018. /// <returns></returns>
  6019. [HttpGet]
  6020. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6021. {
  6022. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6023. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6024. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6025. .Select(x => x.Id)
  6026. .ToList()
  6027. .Contains(userid);
  6028. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6029. .Where(x => x.STid == 111 && x.IsDel == 0)
  6030. .Select(x => new
  6031. {
  6032. x.Name,
  6033. x.Id,
  6034. }).ToList();
  6035. if (isMarketingDepartment)
  6036. {
  6037. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6038. }
  6039. if (portType == 1)
  6040. {
  6041. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6042. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6043. .Where(x => x.IsDel == 0)
  6044. .OrderByDescending(x => x.VisitDate)
  6045. .Select(x => new
  6046. {
  6047. x.TeamName,
  6048. x.Id,
  6049. x.CityId,
  6050. })
  6051. .ToList()
  6052. .Select(x =>
  6053. {
  6054. var provinceId = x.CityId;
  6055. var isDefualtVal = true;
  6056. if (provinceId > 0)
  6057. {
  6058. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6059. if (parentId != null)
  6060. {
  6061. isDefualtVal = false;
  6062. provinceId = (int)parentId;
  6063. }
  6064. }
  6065. if (isDefualtVal)
  6066. {
  6067. provinceId = 122; //默认四川
  6068. }
  6069. return new
  6070. {
  6071. x.TeamName,
  6072. x.Id,
  6073. provinceId,
  6074. };
  6075. })
  6076. .ToList();
  6077. return Ok(JsonView(true, "SUCCESS!", new
  6078. {
  6079. dropDownType,
  6080. dropDownGroupList,
  6081. isMarketingDepartment
  6082. }));
  6083. }
  6084. else if (portType == 2 || portType == 3)
  6085. {
  6086. return Ok(JsonView(true, "SUCCESS!", new
  6087. {
  6088. dropDownType,
  6089. isMarketingDepartment
  6090. }));
  6091. }
  6092. else
  6093. {
  6094. return Ok(JsonView(false, "portType有误!"));
  6095. }
  6096. }
  6097. /// <summary>
  6098. /// 共享文件上传
  6099. /// </summary>
  6100. /// <param name="dto"></param>
  6101. /// <returns></returns>
  6102. [HttpPost]
  6103. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6104. {
  6105. var isGroup = new List<int> { 1412 };
  6106. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6107. {
  6108. return Ok(JsonView(false, "该文件需要关联团组!"));
  6109. }
  6110. if (dto.Files == null || dto.Files.Count == 0)
  6111. {
  6112. return Ok(JsonView(false, "无文件信息!"));
  6113. }
  6114. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6115. {
  6116. return Ok(JsonView(false, "文件大小超过20M!"));
  6117. }
  6118. if (dto.Userid < 1)
  6119. {
  6120. return Ok(JsonView(false, "请传入有效的Userid!"));
  6121. }
  6122. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6123. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6124. .Select((u, j) => new
  6125. {
  6126. u.CnName,
  6127. UserId = u.Id,
  6128. j.JobName,
  6129. })
  6130. .First();
  6131. if (jobInfo == null)
  6132. {
  6133. return Ok(JsonView(false, "请传入有效的Userid!"));
  6134. }
  6135. var commonFileExtensions = new List<string>
  6136. {
  6137. // 文本文件
  6138. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6139. // 图片文件
  6140. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6141. // 视频文件
  6142. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6143. // 音频文件
  6144. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6145. // 压缩文件
  6146. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6147. // 数据文件
  6148. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6149. };
  6150. try
  6151. {
  6152. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6153. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6154. commonFileExtensions.AddRange(settingExtend);
  6155. }
  6156. catch (Exception)
  6157. { }
  6158. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6159. if (setdata == null)
  6160. {
  6161. return Ok(JsonView(false, "请传入有效的FileType!"));
  6162. }
  6163. var insertList = new List<Grp_GroupShareFile>();
  6164. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6165. if (!Directory.Exists(winPath))
  6166. {
  6167. Directory.CreateDirectory(winPath);
  6168. }
  6169. foreach (var item in dto.Files)
  6170. {
  6171. var houzui = Path.GetExtension(item.FileName);
  6172. if (!commonFileExtensions.Contains(houzui))
  6173. {
  6174. return Ok(JsonView(false, "未知后缀名称!"));
  6175. }
  6176. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6177. var saveFilePath = winPath + fileName;
  6178. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6179. {
  6180. item.CopyTo(fs);
  6181. fs.Flush();
  6182. }
  6183. var fileDetail = new Grp_GroupShareFile()
  6184. {
  6185. CreateUserId = dto.Userid,
  6186. CreateTime = DateTime.Now,
  6187. UploadJob = jobInfo.JobName,
  6188. FileName = fileName,
  6189. FileType = dto.FileType,
  6190. Diid = dto.Diid,
  6191. FilePath = winPath + fileName,
  6192. };
  6193. insertList.Add(fileDetail);
  6194. }
  6195. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6196. return Ok(JsonView(true, "保存成功!"));
  6197. }
  6198. /// <summary>
  6199. /// 查询共享文件列表
  6200. /// </summary>
  6201. /// <param name="dto"></param>
  6202. /// <returns></returns>
  6203. [HttpPost]
  6204. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6205. {
  6206. var isGroup = new List<int> { 1412 };
  6207. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6208. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6209. .And(x => x.Diid == dto.Diid)
  6210. .And(x => x.FileType == dto.FileType)
  6211. .And(x => x.IsDel == 0)
  6212. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6213. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  6214. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  6215. int totalCount = 0;
  6216. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  6217. .Where(queryExpression.ToExpression())
  6218. .OrderBy(x => x.UploadJob)
  6219. .Select(x => new
  6220. {
  6221. x.Id,
  6222. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  6223. x.FileName,
  6224. x.FileType,
  6225. x.CreateTime,
  6226. })
  6227. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  6228. return Ok(JsonView(true, "SUCCESS!", new
  6229. {
  6230. FileList = dbQuery,
  6231. dto.PageSize,
  6232. dto.PageIndex,
  6233. totalCount
  6234. }));
  6235. }
  6236. /// <summary>
  6237. /// 删除共享文件模块下的指定文件
  6238. /// </summary>
  6239. /// <param name="dto"></param>
  6240. /// <returns></returns>
  6241. [HttpPost]
  6242. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  6243. {
  6244. var jw = JsonView(false);
  6245. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6246. if (sing == null)
  6247. {
  6248. jw.Msg = "暂无文件信息!";
  6249. return Ok(jw);
  6250. }
  6251. if (sing.CreateUserId != dto.UserId)
  6252. {
  6253. jw.Msg = "只能删除自己上传的文件!";
  6254. return Ok(jw);
  6255. }
  6256. if (System.IO.File.Exists(sing.FilePath))
  6257. {
  6258. try
  6259. {
  6260. System.IO.File.Delete(sing.FilePath);
  6261. }
  6262. catch (Exception ex)
  6263. {
  6264. jw.Msg = "删除失败!" + ex.Message;
  6265. return Ok(jw);
  6266. }
  6267. }
  6268. sing.IsDel = 1;
  6269. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6270. sing.DeleteUserId = dto.UserId;
  6271. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  6272. jw = JsonView(true, "删除成功!");
  6273. return Ok(jw);
  6274. }
  6275. #endregion
  6276. #region 团组英文资料
  6277. /// <summary>
  6278. /// 查询团组英文所有资料
  6279. /// </summary>
  6280. /// <param name="dto"></param>
  6281. /// <returns></returns>
  6282. [HttpPost]
  6283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6284. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  6285. {
  6286. try
  6287. {
  6288. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  6289. if (groupData.Code != 0)
  6290. {
  6291. return Ok(JsonView(false, groupData.Msg));
  6292. }
  6293. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6294. }
  6295. catch (Exception ex)
  6296. {
  6297. return Ok(JsonView(false, ex.Message));
  6298. throw;
  6299. }
  6300. }
  6301. /// <summary>
  6302. /// 团组英文资料操作(Status:1.新增,2.修改)
  6303. /// </summary>
  6304. /// <param name="dto"></param>
  6305. /// <returns></returns>
  6306. [HttpPost]
  6307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6308. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  6309. {
  6310. try
  6311. {
  6312. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  6313. if (groupData.Code != 0)
  6314. {
  6315. return Ok(JsonView(false, groupData.Msg));
  6316. }
  6317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6318. }
  6319. catch (Exception ex)
  6320. {
  6321. return Ok(JsonView(false, ex.Message));
  6322. throw;
  6323. }
  6324. }
  6325. /// <summary>
  6326. /// 团组英文资料Id查询数据
  6327. /// </summary>
  6328. /// <param name="dto"></param>
  6329. /// <returns></returns>
  6330. [HttpPost]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  6333. {
  6334. try
  6335. {
  6336. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  6337. if (_DelegationEnData != null)
  6338. {
  6339. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  6340. }
  6341. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  6342. }
  6343. catch (Exception ex)
  6344. {
  6345. return Ok(JsonView(false, "程序错误!"));
  6346. throw;
  6347. }
  6348. }
  6349. /// <summary>
  6350. /// 团组英文资料删除
  6351. /// </summary>
  6352. /// <param name="dto"></param>
  6353. /// <returns></returns>
  6354. [HttpPost]
  6355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6356. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  6357. {
  6358. try
  6359. {
  6360. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  6361. if (!res)
  6362. {
  6363. return Ok(JsonView(false, "删除失败"));
  6364. }
  6365. return Ok(JsonView(true, "删除成功!"));
  6366. }
  6367. catch (Exception ex)
  6368. {
  6369. return Ok(JsonView(false, ex.Message));
  6370. throw;
  6371. }
  6372. }
  6373. #endregion
  6374. #region 导出邀请函
  6375. /// <summary>
  6376. /// 导出邀请函页面初始化
  6377. /// </summary>
  6378. /// <param name="dto"></param>
  6379. /// <returns></returns>
  6380. [HttpPost]
  6381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6382. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  6383. {
  6384. try
  6385. {
  6386. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6387. var crm_Deles = new List<Crm_DeleClient>();
  6388. if (dto.DiId == 0)
  6389. {
  6390. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6391. }
  6392. else
  6393. {
  6394. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6395. }
  6396. return Ok(JsonView(true, "查询成功!", new
  6397. {
  6398. deleClient = crm_Deles,
  6399. delegations = grp_Delegations
  6400. }));
  6401. }
  6402. catch (Exception ex)
  6403. {
  6404. return Ok(JsonView(false, "程序错误!"));
  6405. throw;
  6406. }
  6407. }
  6408. /// <summary>
  6409. /// 导出邀请函
  6410. /// </summary>
  6411. /// <param name="dto"></param>
  6412. /// <returns></returns>
  6413. [HttpPost]
  6414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6415. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6416. {
  6417. #region 参数验证
  6418. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6419. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6420. #endregion
  6421. try
  6422. {
  6423. var transDic = new Dictionary<string, string>();
  6424. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6425. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6426. From Grp_TourClientList tcl
  6427. Left Join
  6428. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6429. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6430. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6431. From Crm_DeleClient dc
  6432. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6433. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6434. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6435. Where dc.IsDel = 0) temp
  6436. On temp.DcId =tcl.ClientId
  6437. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6438. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6439. var texts = new List<string>();
  6440. if (datas.Count != 0)
  6441. {
  6442. foreach (TourClientListDetailsView item in datas)
  6443. {
  6444. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6445. {
  6446. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6447. }
  6448. else
  6449. {
  6450. string name = item.LastName + item.FirstName;
  6451. texts.Add(name);
  6452. }
  6453. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6454. {
  6455. if (!transDic.ContainsKey(item.Job))
  6456. {
  6457. texts.Add(item.Job);
  6458. }
  6459. }
  6460. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6461. {
  6462. texts.Add(item.CompanyFullName);
  6463. }
  6464. }
  6465. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6466. if (transData.Count > 0)
  6467. {
  6468. foreach (TranslateResult item in transData)
  6469. {
  6470. if (!transDic.ContainsKey(item.Query))
  6471. {
  6472. transDic.Add(item.Query, item.Translation);
  6473. }
  6474. }
  6475. }
  6476. var list = new List<GuestList>();
  6477. foreach (var dele in datas)
  6478. {
  6479. var guestList = new GuestList();
  6480. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6481. {
  6482. guestList.Name = dele.Pinyin;
  6483. }
  6484. else
  6485. {
  6486. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6487. guestList.Name = Name;
  6488. }
  6489. if (dele.Sex == 0)
  6490. {
  6491. guestList.Sex = "Male";
  6492. }
  6493. else if (dele.Sex == 1)
  6494. {
  6495. guestList.Sex = "Female";
  6496. }
  6497. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6498. if (!string.IsNullOrEmpty(dele.Job))
  6499. {
  6500. guestList.Job = dele.Job;
  6501. }
  6502. list.Add(guestList);
  6503. }
  6504. //载入模板
  6505. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6506. var builder = new DocumentBuilder(doc);
  6507. //获取word里所有表格
  6508. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6509. //获取所填表格的序数
  6510. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6511. var rowStart = tableOne.Rows[0]; //获取第1行
  6512. //循环赋值
  6513. for (int i = 0; i < list.Count; i++)
  6514. {
  6515. builder.MoveToCell(0, i + 1, 0, 0);
  6516. builder.Write(list[i].Name.ToString());
  6517. builder.MoveToCell(0, i + 1, 1, 0);
  6518. builder.Write(list[i].Sex.ToString());
  6519. builder.MoveToCell(0, i + 1, 2, 0);
  6520. builder.Write(list[i].DOB.ToString());
  6521. builder.MoveToCell(0, i + 1, 3, 0);
  6522. builder.Write(list[i].Job.ToString());
  6523. }
  6524. //删除多余行
  6525. while (tableOne.Rows.Count > list.Count + 1)
  6526. {
  6527. tableOne.Rows.RemoveAt(list.Count + 1);
  6528. }
  6529. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6530. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6531. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6532. doc.Save(filePath);
  6533. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6534. return Ok(JsonView(true, "操作成功!", Url));
  6535. }
  6536. else
  6537. {
  6538. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6539. }
  6540. }
  6541. catch (Exception ex)
  6542. {
  6543. return Ok(JsonView(false, ex.Message));
  6544. throw;
  6545. }
  6546. }
  6547. #endregion
  6548. #region 团组经理模块 出入境费用
  6549. /// <summary>
  6550. /// 团组模块 - 出入境费用 - 省份基础数据源
  6551. /// </summary>
  6552. /// <returns></returns>
  6553. [HttpGet]
  6554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6555. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6556. {
  6557. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6558. }
  6559. /// <summary>
  6560. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6561. /// </summary>
  6562. /// <param name="dto"></param>
  6563. /// <returns></returns>
  6564. [HttpPost]
  6565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6566. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6567. {
  6568. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6569. var groupNamFirst = groupNameData.FirstOrDefault();
  6570. //SetDataInfoView
  6571. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6572. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6573. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6574. //验证城市归属并给默认值
  6575. int provinceId = 122;
  6576. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6577. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6578. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6579. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6580. return Ok(JsonView(true, "查询成功!", new
  6581. {
  6582. GroupNameData = groupNameData,
  6583. CurrencyData = _CurrencyData,
  6584. WordTypeData = wordTypeData,
  6585. ExcelTypeData = excelTypeData,
  6586. CurrencyInit = _currencyInfos,
  6587. ViewPermissionData = viewPermissionData
  6588. }));
  6589. }
  6590. /// <summary>
  6591. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6592. /// </summary>
  6593. /// <returns></returns>
  6594. [HttpGet("{provinceId}")]
  6595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6596. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6597. {
  6598. //验证城市归属并给默认值
  6599. if (provinceId < 1) provinceId = 122;
  6600. /*
  6601. * 122 四川
  6602. * 108 贵州
  6603. * 103 重庆
  6604. * 132 云南
  6605. */
  6606. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6607. return Ok(JsonView(true, "查询成功!", new
  6608. {
  6609. WordTypeData = wordTypeData,
  6610. ExcelTypeData = excelTypeData,
  6611. }));
  6612. }
  6613. /// <summary>
  6614. /// 团组模块 - 出入境费用
  6615. /// 实时汇率 tips
  6616. /// 签证费用 tips
  6617. /// 机票费用 tips
  6618. /// </summary>
  6619. /// <returns></returns>
  6620. [HttpPost]
  6621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6622. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6623. {
  6624. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6625. //默认币种显示
  6626. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6627. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6628. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6629. return Ok(JsonView(true, "查询成功!", new
  6630. {
  6631. //GroupNameData = groupNameData.Data,
  6632. visaData = visaData.Data,
  6633. airData,
  6634. reteInfos
  6635. }));
  6636. }
  6637. /// <summary>
  6638. /// 团组模块 - 出入境费用 - Info
  6639. /// </summary>
  6640. /// <param name="dto"></param>
  6641. /// <returns></returns>
  6642. [HttpPost]
  6643. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6645. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6646. {
  6647. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6648. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6649. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6650. }
  6651. /// <summary>
  6652. /// 团组模块 - 出入境费用 - 设置view权限
  6653. /// </summary>
  6654. /// <returns></returns>
  6655. [HttpPost]
  6656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6657. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6658. {
  6659. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6660. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6661. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6662. var permissions = new List<Grp_EnterExitCostPermission>();
  6663. foreach (var userId in dto.UserIds)
  6664. {
  6665. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6666. }
  6667. if (permissions.Any())
  6668. {
  6669. _sqlSugar.BeginTran();
  6670. try
  6671. {
  6672. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6673. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6674. if (result < 1)
  6675. {
  6676. _sqlSugar.RollbackTran();
  6677. return Ok(JsonView(false));
  6678. }
  6679. }
  6680. catch (Exception ex)
  6681. {
  6682. _sqlSugar.RollbackTran();
  6683. return Ok(JsonView(false, ex.Message));
  6684. }
  6685. _sqlSugar.CommitTran();
  6686. return Ok(JsonView(true));
  6687. }
  6688. return Ok(JsonView(false));
  6689. }
  6690. /// <summary>
  6691. /// 团组模块 - 出入境费用 - Add And Update
  6692. /// </summary>
  6693. /// <returns></returns>
  6694. [HttpPost]
  6695. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6697. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6698. {
  6699. try
  6700. {
  6701. var rateRecords = new List<RateRecordInfo>();
  6702. #region 汇率保存前存储
  6703. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  6704. if (info != null)
  6705. {
  6706. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  6707. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  6708. {
  6709. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  6710. {
  6711. CurrencyCode = x.CurrencyCode,
  6712. CurrencyName = x.CurrencyName,
  6713. UpdatePreRate = x.Rate,
  6714. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  6715. }).ToList();
  6716. }
  6717. else
  6718. {
  6719. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6720. {
  6721. CurrencyCode = x.CurrencyCode,
  6722. CurrencyName = x.CurrencyName,
  6723. UpdatePreRate = 0.00M,
  6724. UpdateBreRate = x.Rate
  6725. }).ToList();
  6726. }
  6727. }
  6728. else
  6729. {
  6730. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  6731. {
  6732. CurrencyCode = x.CurrencyCode,
  6733. CurrencyName = x.CurrencyName,
  6734. UpdatePreRate = 0.00M,
  6735. UpdateBreRate = x.Rate
  6736. }).ToList();
  6737. }
  6738. #endregion
  6739. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6740. if (dto.DayOtherPriceData.Any())
  6741. {
  6742. var inserList = dto.DayOtherPriceData
  6743. .Where(x => x.Id == 0)
  6744. .Select(x => new Grp_DayOtherPrice
  6745. {
  6746. Cost = x.Cost,
  6747. Id = x.Id,
  6748. CreateTime = DateTime.Now,
  6749. CreateUserId = dto.UserId,
  6750. Currency = x.Currency,
  6751. Diid = x.DiId,
  6752. Index = x.Index,
  6753. IsDel = 0,
  6754. SetDataId = x.SetDataId,
  6755. SubTotal = x.SubTotal,
  6756. Remark = x.Remark
  6757. })
  6758. .ToList();
  6759. var updateList = dto.DayOtherPriceData
  6760. .Where(x => x.Id != 0)
  6761. .Select(x => new Grp_DayOtherPrice
  6762. {
  6763. Cost = x.Cost,
  6764. Id = x.Id,
  6765. CreateTime = DateTime.Now,
  6766. CreateUserId = dto.UserId,
  6767. Currency = x.Currency,
  6768. Diid = x.DiId,
  6769. Index = x.Index,
  6770. IsDel = 0,
  6771. SetDataId = x.SetDataId,
  6772. SubTotal = x.SubTotal,
  6773. Remark = x.Remark
  6774. })
  6775. .ToList();
  6776. //添加
  6777. _sqlSugar.BeginTran();
  6778. if (inserList.Any())
  6779. {
  6780. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6781. }
  6782. if (updateList.Any())
  6783. {
  6784. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6785. }
  6786. _sqlSugar.CommitTran();
  6787. }
  6788. if (data.Code != 0)
  6789. {
  6790. return Ok(JsonView(false, data.Msg));
  6791. }
  6792. //生成默认文件pdf并且通知人员
  6793. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6794. {
  6795. DiId = dto.DiId,
  6796. ExportType = 1,
  6797. SubTypeId = 1005
  6798. }, "pdf");
  6799. //发送通知
  6800. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6801. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6802. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6803. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6804. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6805. //汇率信息记录
  6806. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6807. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  6808. //汇率验证、反推
  6809. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  6810. if (isSendMsg)
  6811. {
  6812. //消息推送
  6813. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  6814. }
  6815. #region //日志汇率记录
  6816. //按照已使用币种记录
  6817. if (checkCurrencys != null && checkCurrencys.Count > 0)
  6818. {
  6819. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  6820. //汇率记录中加入实时汇率
  6821. if (liveRates != null && liveRates.Count > 0)
  6822. {
  6823. foreach (var item in rateRecords)
  6824. {
  6825. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  6826. }
  6827. }
  6828. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  6829. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  6830. var logContent = new StringBuilder();
  6831. foreach (var item in rateRecords)
  6832. {
  6833. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  6834. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  6835. logContent.AppendLine(msg);
  6836. }
  6837. _eec_textLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】\r\n{logContent}", teamName, dto.DiId, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logContent.ToString());
  6838. }
  6839. #endregion
  6840. return Ok(JsonView(true, data.Msg, data.Data));
  6841. }
  6842. catch (Exception ex)
  6843. {
  6844. return Ok(JsonView(false, ex.Message));
  6845. }
  6846. }
  6847. /// <summary>
  6848. /// 团组模块 - 出入境费用 - Confirm 费用
  6849. /// </summary>
  6850. /// <returns></returns>
  6851. [HttpPost]
  6852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6853. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6854. {
  6855. //TODO:测试完毕需把对应的用户ID更改
  6856. //1、数据表添加字段
  6857. //2、更改字段接口()
  6858. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6859. //3、确认成功 给财务发送消息
  6860. if (_view.Code == 200)
  6861. {
  6862. if (dto.Type == 1)
  6863. {
  6864. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6865. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6866. }
  6867. }
  6868. return Ok(_view);
  6869. }
  6870. /// <summary>
  6871. /// 团组模块 - 出入境费用 - File download
  6872. /// </summary>
  6873. /// <param name="dto"></param>
  6874. /// <returns></returns>
  6875. [HttpPost]
  6876. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6878. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6879. {
  6880. try
  6881. {
  6882. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6883. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6884. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6885. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6886. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6887. 3 团组成员名单 1 团组成员名单", ""));
  6888. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6889. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6890. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6891. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6892. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6893. //数据源
  6894. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6895. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6896. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6897. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6898. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6899. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6900. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6901. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6902. .Select((x, a, b) => new
  6903. {
  6904. x.Index,
  6905. itemName = a.Name,
  6906. CurrencyStr = b.Name,
  6907. x.Cost,
  6908. x.SubTotal,
  6909. x.Remark
  6910. })
  6911. .OrderBy((x) => x.Index)
  6912. .ToList(); //其他款项费用
  6913. var peiceItemCurrencys = new List<string>();
  6914. if (_DayAndCosts.Any())
  6915. {
  6916. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6917. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6918. }
  6919. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6920. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6921. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6922. {
  6923. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6924. }
  6925. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6926. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6927. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6928. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6929. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6930. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6931. .Select((tcl, dc, cc) => new ClientInfo
  6932. {
  6933. LastName = dc.LastName,
  6934. FirstName = dc.FirstName,
  6935. Sex = dc.Sex,
  6936. Birthday = dc.BirthDay,
  6937. Company = cc.CompanyFullName,
  6938. Job = dc.Job
  6939. })
  6940. .ToList();
  6941. foreach (var item in DeleClientList)
  6942. {
  6943. EncryptionProcessor.DecryptProperties(item);
  6944. }
  6945. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6946. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6947. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6948. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6949. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6950. if (dto.ExportType == 1) //明细表
  6951. {
  6952. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6953. {
  6954. //获取模板
  6955. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6956. //载入模板
  6957. var doc = new Document(tempPath);
  6958. var builder = new DocumentBuilder(doc);
  6959. var dic = new Dictionary<string, string>();
  6960. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6961. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6962. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6963. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6964. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6965. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6966. //境内费用(其他费用)
  6967. if (_EnterExitCosts.ChoiceOne == 1)
  6968. {
  6969. string row1_1 = "";
  6970. if (_EnterExitCosts.Visa > 0)
  6971. {
  6972. //insidePayTotal += _EnterExitCosts.Visa;
  6973. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  6974. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6975. //{
  6976. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6977. //}
  6978. }
  6979. string row1_2 = "";
  6980. if (_EnterExitCosts.YiMiao > 0)
  6981. {
  6982. //insidePayTotal += _EnterExitCosts.YiMiao;
  6983. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  6984. }
  6985. if (_EnterExitCosts.HeSuan > 0)
  6986. {
  6987. //insidePayTotal += _EnterExitCosts.HeSuan;
  6988. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  6989. }
  6990. if (_EnterExitCosts.Service > 0)
  6991. {
  6992. //insidePayTotal += _EnterExitCosts.Service;
  6993. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  6994. }
  6995. string row1_3 = "";
  6996. if (_EnterExitCosts.Safe > 0)
  6997. {
  6998. //insidePayTotal += _EnterExitCosts.Safe;
  6999. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7000. }
  7001. if (_EnterExitCosts.Ticket > 0)
  7002. {
  7003. //insidePayTotal += _EnterExitCosts.Ticket;
  7004. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7005. }
  7006. string row1 = "";
  7007. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7008. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7009. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7010. row1 += $"备注:{_EnterExitCosts.Remark}";
  7011. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7012. dic.Add("Row1Str", row1);
  7013. }
  7014. string airTotalStr = string.Empty,
  7015. airPriceStr = string.Empty;
  7016. //经济舱
  7017. if (_EnterExitCosts.SumJJC == 1)
  7018. {
  7019. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7020. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7021. }
  7022. //公务舱
  7023. if (_EnterExitCosts.SumGWC == 1)
  7024. {
  7025. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7026. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7027. }
  7028. //头等舱
  7029. if (_EnterExitCosts.SumTDC == 1)
  7030. {
  7031. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7032. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7033. }
  7034. //汇率描述
  7035. string rateStr = "";
  7036. if (peiceItemCurrencyInfos.Any())
  7037. {
  7038. rateStr = "\r\n汇率描述:";
  7039. foreach (var item in peiceItemCurrencyInfos)
  7040. {
  7041. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7042. }
  7043. }
  7044. string twoItemRemark = "备注:";
  7045. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7046. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7047. dic.Add("AirTotalStr", airTotalStr);
  7048. dic.Add("AirPriceStr", airPriceStr);
  7049. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7050. dic.Add("TwoItemRemark", twoItemRemark);
  7051. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7052. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7053. int table1Row = 0,
  7054. table2Row = 0,
  7055. table3Row = 0,
  7056. table4Row = 0,
  7057. table5Row = 0;
  7058. //住宿费
  7059. if (_EnterExitCosts.ChoiceThree == 1)
  7060. {
  7061. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7062. table1Row = dac1.Count;
  7063. #region 填充word表格内容
  7064. for (int i = 0; i < dac1.Count; i++)
  7065. {
  7066. Grp_DayAndCost dac = dac1[i];
  7067. if (dac == null) continue;
  7068. builder.MoveToCell(0, i, 0, 0);
  7069. builder.Write("第" + dac.Days.ToString() + "晚:");
  7070. builder.MoveToCell(0, i, 1, 0);
  7071. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7072. //builder.Write(dac.Place == null ? "" : dac.Place);
  7073. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7074. builder.MoveToCell(0, i, 2, 0);
  7075. builder.Write("费用标准:");
  7076. string curr = "";
  7077. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7078. if (currData != null)
  7079. {
  7080. curr = currData.Name;
  7081. }
  7082. builder.MoveToCell(0, i, 3, 0);
  7083. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7084. builder.MoveToCell(0, i, 4, 0);
  7085. builder.Write("费用小计:");
  7086. builder.MoveToCell(0, i, 5, 0);
  7087. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7088. }
  7089. #endregion
  7090. }
  7091. else dic.Add("SubZS", "0.00");
  7092. //删除多余行
  7093. while (table1.Rows.Count > table1Row)
  7094. {
  7095. table1.Rows.RemoveAt(table1Row);
  7096. }
  7097. //伙食费
  7098. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7099. if (_EnterExitCosts.ChoiceFour == 1)
  7100. {
  7101. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7102. table2Row = dac2.Count;
  7103. #region 填充word表格内容
  7104. for (int i = 0; i < dac2.Count; i++)
  7105. {
  7106. Grp_DayAndCost dac = dac2[i];
  7107. if (dac == null) continue;
  7108. builder.MoveToCell(1, i, 0, 0);
  7109. builder.Write("第" + dac.Days.ToString() + "天:");
  7110. builder.MoveToCell(1, i, 1, 0);
  7111. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7112. builder.MoveToCell(1, i, 2, 0);
  7113. builder.Write("费用标准:");
  7114. string curr = "";
  7115. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7116. if (currData != null)
  7117. {
  7118. curr = currData.Name;
  7119. }
  7120. builder.MoveToCell(1, i, 3, 0);
  7121. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7122. builder.MoveToCell(1, i, 4, 0);
  7123. builder.Write("费用小计:");
  7124. builder.MoveToCell(1, i, 5, 0);
  7125. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7126. }
  7127. #endregion
  7128. }
  7129. else dic.Add("SubHS", "0.00");
  7130. //删除多余行
  7131. while (table2.Rows.Count > table2Row)
  7132. {
  7133. table2.Rows.RemoveAt(table2Row);
  7134. }
  7135. //公杂费
  7136. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7137. if (_EnterExitCosts.ChoiceFive == 1)
  7138. {
  7139. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7140. table3Row = dac3.Count;
  7141. #region 填充word表格内容
  7142. for (int i = 0; i < dac3.Count; i++)
  7143. {
  7144. Grp_DayAndCost dac = dac3[i];
  7145. if (dac == null) continue;
  7146. builder.MoveToCell(2, i, 0, 0);
  7147. builder.Write("第" + dac.Days.ToString() + "天:");
  7148. builder.MoveToCell(2, i, 1, 0);
  7149. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7150. builder.MoveToCell(2, i, 2, 0);
  7151. builder.Write("费用标准:");
  7152. string curr = "";
  7153. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7154. if (currData != null)
  7155. {
  7156. curr = currData.Name;
  7157. }
  7158. builder.MoveToCell(2, i, 3, 0);
  7159. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7160. builder.MoveToCell(2, i, 4, 0);
  7161. builder.Write("费用小计:");
  7162. builder.MoveToCell(2, i, 5, 0);
  7163. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7164. }
  7165. //删除多余行
  7166. while (table3.Rows.Count > table3Row)
  7167. {
  7168. table3.Rows.RemoveAt(table3Row);
  7169. }
  7170. #endregion
  7171. }
  7172. else dic.Add("SubGZF", "0.00");
  7173. //删除多余行
  7174. while (table3.Rows.Count > table3Row)
  7175. {
  7176. table3.Rows.RemoveAt(table3Row);
  7177. }
  7178. //培训费
  7179. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7180. if (_EnterExitCosts.ChoiceSix == 1)
  7181. {
  7182. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7183. dic.Add("SubPX", pxStr);
  7184. table4Row = dac4.Count;
  7185. #region 填充word表格内容
  7186. for (int i = 0; i < dac4.Count; i++)
  7187. {
  7188. Grp_DayAndCost dac = dac4[i];
  7189. if (dac == null) continue;
  7190. builder.MoveToCell(3, i, 0, 0);
  7191. builder.Write("第" + dac.Days.ToString() + "天:");
  7192. builder.MoveToCell(3, i, 1, 0);
  7193. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7194. builder.MoveToCell(3, i, 2, 0);
  7195. builder.Write("费用标准:");
  7196. string curr = "";
  7197. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7198. if (currData != null)
  7199. {
  7200. curr = currData.Name;
  7201. }
  7202. builder.MoveToCell(3, i, 3, 0);
  7203. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7204. builder.MoveToCell(3, i, 4, 0);
  7205. builder.Write("费用小计:");
  7206. builder.MoveToCell(3, i, 5, 0);
  7207. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7208. }
  7209. #endregion
  7210. }
  7211. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7212. //删除多余行
  7213. while (table4.Rows.Count > table4Row)
  7214. {
  7215. table4.Rows.RemoveAt(table4Row);
  7216. }
  7217. //其他费用
  7218. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7219. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7220. {
  7221. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  7222. dic.Add("titleQi", qtStr);
  7223. table5Row = dac5.Count;
  7224. #region 填充word表格内容
  7225. for (int i = 0; i < dac5.Count; i++)
  7226. {
  7227. var dac = dac5[i];
  7228. if (dac == null) continue;
  7229. builder.MoveToCell(4, i, 0, 0);
  7230. builder.Write("第" + dac.Index.ToString() + "项:");
  7231. builder.MoveToCell(4, i, 1, 0);
  7232. builder.Write(dac.itemName);
  7233. builder.MoveToCell(4, i, 2, 0);
  7234. builder.Write("费用标准:");
  7235. builder.MoveToCell(4, i, 3, 0);
  7236. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7237. builder.MoveToCell(4, i, 4, 0);
  7238. builder.Write("费用小计:");
  7239. builder.MoveToCell(4, i, 5, 0);
  7240. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7241. builder.MoveToCell(4, i, 6, 0);
  7242. builder.Write("备注:");
  7243. builder.MoveToCell(4, i, 7, 0);
  7244. builder.Write(dac.Remark);
  7245. }
  7246. #endregion
  7247. }
  7248. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7249. //删除多余行
  7250. while (table5.Rows.Count > table5Row)
  7251. {
  7252. table5.Rows.RemoveAt(table5Row);
  7253. }
  7254. //加上其他费用
  7255. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7256. decimal subJJC = 0.00M,
  7257. subGWC = 0.00M,
  7258. subTDC = 0.00M;
  7259. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7260. string totalLabel = string.Format("全部费用总计:");
  7261. //经济舱
  7262. if (_EnterExitCosts.SumJJC == 1)
  7263. {
  7264. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7265. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  7266. }
  7267. //公务舱
  7268. if (_EnterExitCosts.SumGWC == 1)
  7269. {
  7270. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7271. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  7272. }
  7273. //头等舱
  7274. if (_EnterExitCosts.SumTDC == 1)
  7275. {
  7276. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7277. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  7278. }
  7279. //TotalLabel
  7280. dic.Add("TotalLabel", totalLabel);
  7281. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7282. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7283. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7284. #region 填充word模板书签内容
  7285. foreach (var key in dic.Keys)
  7286. {
  7287. Bookmark bookmark = doc.Range.Bookmarks[key];
  7288. if (bookmark != null)
  7289. {
  7290. builder.MoveToBookmark(key);
  7291. builder.Write(dic[key]);
  7292. }
  7293. }
  7294. #endregion
  7295. #region 设置页眉
  7296. string userLabel = string.Empty;
  7297. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7298. if (currUserInfo != null)
  7299. {
  7300. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  7301. if (userInfo != null)
  7302. {
  7303. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  7304. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  7305. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  7306. }
  7307. }
  7308. //设置页脚
  7309. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  7310. #endregion
  7311. //文件名
  7312. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  7313. AsposeHelper.removewatermark_v2180();
  7314. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7315. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7316. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7317. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7318. }
  7319. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7320. {
  7321. //获取模板
  7322. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7323. //载入模板
  7324. var doc = new Document(tempPath);
  7325. var builder = new DocumentBuilder(doc);
  7326. var dic = new Dictionary<string, string>();
  7327. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7328. {
  7329. var list = new List<string>();
  7330. try
  7331. {
  7332. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7333. foreach (var item in spilitArr)
  7334. {
  7335. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7336. var depCode = spDotandEmpty[2].Substring(0, 3);
  7337. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7338. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7339. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7340. list.Add(depName);
  7341. list.Add(arrName);
  7342. }
  7343. list = list.Distinct().ToList();
  7344. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7345. }
  7346. catch (Exception)
  7347. {
  7348. dic.Add("ReturnCode", "行程录入不正确!");
  7349. }
  7350. }
  7351. else
  7352. {
  7353. dic.Add("ReturnCode", "未录入行程!");
  7354. }
  7355. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7356. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7357. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7358. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7359. {
  7360. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7361. dic.Add("Day", sp.Days.ToString());
  7362. }
  7363. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7364. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7365. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7366. //dic.Add("Names", Names);
  7367. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7368. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7369. decimal dac1totalPrice = 0.00M;
  7370. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7371. foreach (var dac in dac1)
  7372. {
  7373. if (dac.SubTotal == 0.00M)
  7374. {
  7375. continue;
  7376. }
  7377. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7378. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7379. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7380. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7381. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7382. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7383. builder.Write(currency);//币种
  7384. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7385. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7386. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7387. builder.Write("");//人数
  7388. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7389. builder.Write("");//天数
  7390. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7391. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7392. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7393. decimal rate = 0.00M;
  7394. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7395. builder.Write(rate.ToString("#0.0000"));//汇率
  7396. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7397. decimal rbmPrice = dac.SubTotal;
  7398. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7399. accommodationStartIndex++;
  7400. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7401. }
  7402. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7403. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7404. {
  7405. table1.Rows.RemoveAt(i - 1);
  7406. foodandotherStartIndex--;
  7407. }
  7408. if (dac2.Count == dac3.Count)//国家 币种 金额
  7409. {
  7410. for (int i = 0; i < dac2.Count; i++)
  7411. {
  7412. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7413. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7414. }
  7415. }
  7416. decimal dac2totalPrice = 0.00M;
  7417. foreach (var dac in dac2)
  7418. {
  7419. if (dac.SubTotal == 0)
  7420. {
  7421. continue;
  7422. }
  7423. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7424. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7425. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7426. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7427. builder.Write(currency);//币种
  7428. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7429. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7430. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7431. builder.Write("");//人数
  7432. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7433. builder.Write("");//天数
  7434. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7435. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7436. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7437. decimal rate = 0.00M;
  7438. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7439. builder.Write(rate.ToString("#0.0000"));//汇率
  7440. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7441. decimal rbmPrice = dac.SubTotal;
  7442. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7443. foodandotherStartIndex++;
  7444. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7445. }
  7446. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7447. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7448. {
  7449. table1.Rows.RemoveAt(i - 1);
  7450. }
  7451. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7452. string otherFeeStr = "";
  7453. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  7454. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  7455. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  7456. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7457. foreach (var otherInfo in dac5)
  7458. {
  7459. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7460. }
  7461. #endregion
  7462. if (otherFeeStr.Length > 0)
  7463. {
  7464. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7465. otherFeeStr = $"({otherFeeStr})";
  7466. dic.Add("OtherFeeStr", otherFeeStr);
  7467. }
  7468. //总计
  7469. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7470. //国际旅费
  7471. string outsideAir = string.Empty;
  7472. string allPriceAir = string.Empty;
  7473. if (_EnterExitCosts.SumJJC == 1)
  7474. {
  7475. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7476. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7477. }
  7478. if (_EnterExitCosts.SumGWC == 1)
  7479. {
  7480. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7481. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7482. }
  7483. if (_EnterExitCosts.SumTDC == 1)
  7484. {
  7485. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7486. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7487. }
  7488. dic.Add("InTravelPrice", $"({outsideAir})");
  7489. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7490. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7491. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7492. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7493. foreach (var key in dic.Keys)
  7494. {
  7495. builder.MoveToBookmark(key);
  7496. builder.Write(dic[key]);
  7497. }
  7498. //模板文件名
  7499. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7500. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7501. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7502. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7503. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7504. }
  7505. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7506. {
  7507. //获取模板
  7508. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7509. //载入模板
  7510. var designer = new WorkbookDesigner
  7511. {
  7512. Workbook = new Workbook(tempPath)
  7513. };
  7514. var dic = new Dictionary<string, string>();
  7515. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7516. {
  7517. var list = new List<string>();
  7518. try
  7519. {
  7520. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7521. foreach (var item in spilitArr)
  7522. {
  7523. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7524. var depCode = spDotandEmpty[2].Substring(0, 3);
  7525. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7526. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7527. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7528. list.Add(depName);
  7529. list.Add(arrName);
  7530. }
  7531. list = list.Distinct().ToList();
  7532. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7533. }
  7534. catch (Exception)
  7535. {
  7536. dic.Add("ReturnCode", "行程录入不正确!");
  7537. }
  7538. }
  7539. else
  7540. {
  7541. dic.Add("ReturnCode", "未录入行程!");
  7542. }
  7543. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7544. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7545. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7546. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7547. {
  7548. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7549. dic.Add("Day", sp.Days.ToString());
  7550. }
  7551. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7552. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7553. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7554. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7555. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7556. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7557. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7558. designer.SetDataSource("Name", Names);
  7559. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7560. designer.SetDataSource("Day", dic["Day"] + "天");
  7561. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7562. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7563. int startIndex = 10;
  7564. const int startIndexcopy = 10;
  7565. if (dac2.Count == dac3.Count)//国家 币种 金额
  7566. {
  7567. for (int i = 0; i < dac2.Count; i++)
  7568. {
  7569. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7570. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7571. }
  7572. }
  7573. var dtdac1 = new DataTable();
  7574. var place = new List<string>();
  7575. dtdac1.Columns.AddRange(new DataColumn[] {
  7576. new(){ ColumnName = "city"},
  7577. new(){ ColumnName = "curr"},
  7578. new(){ ColumnName = "criterion"},
  7579. new(){ ColumnName = "number",DataType = typeof(int)},
  7580. new(){ ColumnName = "day",DataType = typeof(int)},
  7581. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7582. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7583. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7584. });
  7585. var dtdac2 = new DataTable();
  7586. dtdac2.Columns.AddRange(new DataColumn[] {
  7587. new(){ ColumnName = "city"},
  7588. new(){ ColumnName = "curr"},
  7589. new(){ ColumnName = "criterion"},
  7590. new(){ ColumnName = "number",DataType = typeof(int)},
  7591. new(){ ColumnName = "day",DataType = typeof(int)},
  7592. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  7593. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  7594. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7595. });
  7596. dtdac1.TableName = "tb1";
  7597. dtdac2.TableName = "tb2";
  7598. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7599. foreach (var item in dac1)
  7600. {
  7601. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7602. if (place.Contains(item.Place))
  7603. {
  7604. continue;
  7605. }
  7606. DataRow row = dtdac1.NewRow();
  7607. row["city"] = item.Place;
  7608. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7609. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7610. row["curr"] = currency;
  7611. row["rate"] = rate.ToString("#0.0000");
  7612. row["criterion"] = item.Cost.ToString("#0.00");
  7613. row["number"] = 1;
  7614. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7615. //row["costRMB"] = rbmPrice;
  7616. dtdac1.Rows.Add(row);
  7617. place.Add(item.Place);
  7618. }
  7619. place = new List<string>();
  7620. foreach (var item in dac2)
  7621. {
  7622. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7623. if (place.Contains(item.Place))
  7624. {
  7625. continue;
  7626. }
  7627. DataRow row = dtdac2.NewRow();
  7628. row["city"] = item.Place;
  7629. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7630. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7631. row["curr"] = currency;
  7632. row["rate"] = rate.ToString("#0.0000");
  7633. row["criterion"] = item.Cost.ToString("#0.00");
  7634. row["number"] = 1;
  7635. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7636. //row["cost"] = item.SubTotal;
  7637. //row["costRMB"] = rbmPrice;
  7638. dtdac2.Rows.Add(row);
  7639. place.Add(item.Place);
  7640. //dac2totalPrice += rbmPrice;
  7641. }
  7642. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7643. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7644. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7645. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7646. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7647. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7648. string cell4Str1 = string.Empty;
  7649. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7650. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7651. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7652. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7653. string cellStr = $" 5.其他费用(";
  7654. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7655. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7656. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7657. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7658. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7659. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7660. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7661. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7662. foreach (var otherInfo in dac5)
  7663. {
  7664. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7665. }
  7666. #endregion
  7667. if (cellStr.Length > 8)
  7668. {
  7669. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7670. }
  7671. cellStr += ")";
  7672. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7673. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7674. decimal pxFee = dac4.Sum(it => it.Cost);
  7675. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7676. string celllastStr1 = "";
  7677. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7678. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7679. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7680. celllastStr1 += $",国际旅费 元";
  7681. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7682. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7683. designer.SetDataSource("cell4Str", cell4Str);
  7684. designer.SetDataSource("cellStr", cellStr);
  7685. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7686. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7687. designer.SetDataSource("celllastStr", celllastStr);
  7688. Workbook wb = designer.Workbook;
  7689. var sheet = wb.Worksheets[0];
  7690. //绑定datatable数据集
  7691. designer.SetDataSource(dtdac1);
  7692. designer.SetDataSource(dtdac2);
  7693. designer.Process();
  7694. var rowStart = dtdac1.Rows.Count;
  7695. while (rowStart > 0)
  7696. {
  7697. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7698. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7699. startIndex++;
  7700. rowStart--;
  7701. }
  7702. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7703. startIndex += 1; //总计行
  7704. rowStart = dtdac2.Rows.Count;
  7705. while (rowStart > 0)
  7706. {
  7707. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7708. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7709. startIndex++;
  7710. rowStart--;
  7711. }
  7712. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7713. wb.CalculateFormula(true);
  7714. //模板文件名
  7715. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7716. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7717. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7718. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7719. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7720. }
  7721. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7722. {
  7723. //获取模板
  7724. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7725. //载入模板
  7726. var doc = new Document(tempPath);
  7727. var builder = new DocumentBuilder(doc);
  7728. var dic = new Dictionary<string, string>
  7729. {
  7730. { "GroupName", _DelegationInfo.TeamName },
  7731. { "ClientUnit", _DelegationInfo.ClientUnit }
  7732. };
  7733. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7734. string missionLeaderJob = "";//负责人job
  7735. //int groupNumber = 0; //团人数
  7736. if (DeleClientList.Count > 0)
  7737. {
  7738. missionLeader = DeleClientList[0]?.Name ?? "";
  7739. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7740. }
  7741. dic.Add("MissionLeader", missionLeader); //团负责人
  7742. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7743. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7744. #region MyRegion
  7745. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7746. //{
  7747. // List<string> list = new List<string>();
  7748. // try
  7749. // {
  7750. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7751. // foreach (var item in spilitArr)
  7752. // {
  7753. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7754. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7755. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7756. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7757. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7758. // list.Add(depName);
  7759. // list.Add(arrName);
  7760. // }
  7761. // list = list.Distinct().ToList();
  7762. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7763. // }
  7764. // catch (Exception)
  7765. // {
  7766. // dic.Add("ReturnCode", "行程录入不正确!");
  7767. // }
  7768. //}
  7769. //else
  7770. //{
  7771. // dic.Add("ReturnCode", "未录入行程!");
  7772. //}
  7773. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7774. dic.Add("ReturnCode", string.Join("、", countrys));
  7775. #endregion
  7776. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7777. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7778. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7779. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7780. //{
  7781. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7782. // dic.Add("Day", sp.Days.ToString());
  7783. //}
  7784. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7785. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7786. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7787. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7788. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7789. //培训人员名单
  7790. int cultivateRowIndex = 7;
  7791. foreach (var item in DeleClientList)
  7792. {
  7793. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7794. builder.Write(item.Name);
  7795. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7796. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7797. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7798. string birthDay = "";
  7799. if (item.Birthday != null)
  7800. {
  7801. DateTime dt = Convert.ToDateTime(item.Birthday);
  7802. birthDay = $"{dt.Year}.{dt.Month}";
  7803. }
  7804. builder.Write(birthDay);
  7805. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7806. builder.Write(item.Company);
  7807. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7808. builder.Write(item.Job);
  7809. cultivateRowIndex++;
  7810. }
  7811. //删除多余行
  7812. //cultivateRowIndex -= 2;
  7813. int delRows = 10 + 7 - cultivateRowIndex;
  7814. if (delRows > 0)
  7815. {
  7816. for (int i = 0; i < delRows; i++)
  7817. {
  7818. table1.Rows.RemoveAt(cultivateRowIndex);
  7819. //cultivateRowIndex++;
  7820. }
  7821. }
  7822. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7823. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7824. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7825. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7826. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7827. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7828. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7829. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7830. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7831. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7832. //其他费用
  7833. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7834. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7835. //其他费用合计
  7836. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7837. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7838. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7839. //公务舱合计
  7840. //国际旅费
  7841. //string outsideJJ = "";
  7842. //string allPriceJJ = "";
  7843. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7844. {
  7845. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7846. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7847. }
  7848. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7849. {
  7850. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7851. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7852. }
  7853. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7854. {
  7855. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7856. dic.Add("AirFeeTotal", airFeeTotalStr);
  7857. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7858. dic.Add("FeeTotal", feeTotalStr);
  7859. }
  7860. foreach (var key in dic.Keys)
  7861. {
  7862. builder.MoveToBookmark(key);
  7863. builder.Write(dic[key]);
  7864. }
  7865. //模板文件名
  7866. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7867. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7868. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7869. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7870. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7871. }
  7872. }
  7873. else if (dto.ExportType == 2) //表格
  7874. {
  7875. //利用键值对存放数据
  7876. Dictionary<string, string> dic = new Dictionary<string, string>();
  7877. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7878. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7879. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7880. dic.Add("Day", sp.Days.ToString());
  7881. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7882. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7883. {
  7884. //获取模板
  7885. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7886. //载入模板
  7887. var doc = new Document(tempPath);
  7888. var builder = new DocumentBuilder(doc);
  7889. dic.Add("TeamName", _DelegationInfo.TeamName);
  7890. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7891. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7892. string missionLeaderName = "",
  7893. missionLeaderJob = "";
  7894. if (DeleClientList.Count > 0)
  7895. {
  7896. missionLeaderName = DeleClientList[0].Name;
  7897. missionLeaderJob = DeleClientList[0].Job;
  7898. }
  7899. dic.Add("MissionLeaderName", missionLeaderName);
  7900. dic.Add("MissionLeaderJob", missionLeaderJob);
  7901. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7902. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7903. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7904. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7905. int rowCount = 10;//总人数行
  7906. int startRowIndex = 7; //起始行
  7907. for (int i = 0; i < DeleClientList.Count; i++)
  7908. {
  7909. builder.MoveToCell(0, startRowIndex, 0, 0);
  7910. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7911. builder.MoveToCell(0, startRowIndex, 1, 0);
  7912. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7913. builder.Write(sex);//性别
  7914. builder.MoveToCell(0, startRowIndex, 2, 0);
  7915. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7916. builder.MoveToCell(0, startRowIndex, 3, 0);
  7917. builder.Write(DeleClientList[i].Company);//工作单位
  7918. builder.MoveToCell(0, startRowIndex, 4, 0);
  7919. builder.Write(DeleClientList[i].Job);//职务及级别
  7920. builder.MoveToCell(0, startRowIndex, 5, 0);
  7921. builder.Write("");//人员属性
  7922. builder.MoveToCell(0, startRowIndex, 6, 0);
  7923. builder.Write("");//上次出国时间
  7924. startRowIndex++;
  7925. }
  7926. int nullRow = rowCount - DeleClientList.Count;//空行
  7927. for (int i = 0; i < nullRow; i++)
  7928. {
  7929. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7930. }
  7931. foreach (var key in dic.Keys)
  7932. {
  7933. builder.MoveToBookmark(key);
  7934. builder.Write(dic[key]);
  7935. }
  7936. //模板文件名
  7937. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7938. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7939. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7940. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7941. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7942. }
  7943. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7944. {
  7945. //获取模板
  7946. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7947. //载入模板
  7948. var doc = new Document(tempPath);
  7949. var builder = new DocumentBuilder(doc);
  7950. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7951. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7952. dic.Add("Names", Names);
  7953. int accommodationRows = 12;
  7954. //int foodandotherRows = 12;
  7955. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7956. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7957. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7958. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7959. int accommodationStartIndex = 6;
  7960. decimal dac1totalPrice = 0.00M;
  7961. foreach (var dac in dac1)
  7962. {
  7963. if (dac.SubTotal == 0)
  7964. {
  7965. continue;
  7966. }
  7967. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7968. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7969. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7970. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7971. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7972. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7973. builder.Write(currency);//币种
  7974. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7975. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7976. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7977. builder.Write("");//人数
  7978. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7979. builder.Write("");//天数
  7980. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7981. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7982. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7983. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7984. builder.Write(rate.ToString("#0.0000"));//汇率
  7985. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7986. decimal rbmPrice = rate * dac.SubTotal;
  7987. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7988. accommodationStartIndex++;
  7989. dac1totalPrice += rbmPrice;
  7990. }
  7991. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7992. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7993. builder.Write("小计");
  7994. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7995. builder.Write(dac1totalPrice.ToString("#0.00"));
  7996. accommodationStartIndex++;
  7997. int nullRow = accommodationRows - dac1.Count;
  7998. //删除空行
  7999. //if (nullRow > 0)
  8000. //{
  8001. // int rowIndex = accommodationStartIndex;
  8002. // for (int i = 0; i < nullRow; i++)
  8003. // {
  8004. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8005. // row.Remove();
  8006. // rowIndex++;
  8007. // }
  8008. //}
  8009. if (dac2.Count == dac3.Count)//国家 币种 金额
  8010. {
  8011. for (int i = 0; i < dac2.Count; i++)
  8012. {
  8013. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8014. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8015. }
  8016. }
  8017. int foodandotherStartIndex = 19;//
  8018. decimal dac2totalPrice = 0.00M;
  8019. foreach (var dac in dac2)
  8020. {
  8021. if (dac.SubTotal == 0)
  8022. {
  8023. continue;
  8024. }
  8025. //foodandotherStartIndex = 12;
  8026. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8027. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8028. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8029. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8030. builder.Write(currency);//币种
  8031. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8032. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8033. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8034. builder.Write("");//人数
  8035. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8036. builder.Write("");//天数
  8037. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8038. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8039. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8040. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8041. builder.Write(rate.ToString("#0.0000"));//汇率
  8042. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8043. decimal rbmPrice = rate * dac.SubTotal;
  8044. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8045. foodandotherStartIndex++;
  8046. dac2totalPrice += rbmPrice;
  8047. }
  8048. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8049. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8050. //删除空行
  8051. //if (dac2.Count < foodandotherRows)
  8052. //{
  8053. // while (table2.Rows.Count > dac2.Count)
  8054. // {
  8055. // table2.Rows.RemoveAt(dac2.Count);
  8056. // }
  8057. //}
  8058. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8059. string otherFeeStr = "";
  8060. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8061. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8062. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8063. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8064. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8065. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8066. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8067. foreach (var otherInfo in dac5)
  8068. {
  8069. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8070. }
  8071. #endregion
  8072. if (otherFeeStr.Length > 0)
  8073. {
  8074. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8075. otherFeeStr = $"({otherFeeStr})";
  8076. dic.Add("OtherFeeStr", otherFeeStr);
  8077. }
  8078. foreach (var key in dic.Keys)
  8079. {
  8080. builder.MoveToBookmark(key);
  8081. builder.Write(dic[key]);
  8082. }
  8083. //模板文件名
  8084. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8085. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8086. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8087. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8088. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8089. }
  8090. }
  8091. else if (dto.ExportType == 3)
  8092. {
  8093. if (dto.SubTypeId == 1) //团组成员名单
  8094. {
  8095. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8096. //获取模板
  8097. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8098. //载入模板
  8099. var doc = new Document(tempPath);
  8100. var builder = new DocumentBuilder(doc);
  8101. //获取word里所有表格
  8102. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8103. //获取所填表格的序数
  8104. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8105. var rowStart = tableOne.Rows[0]; //获取第1行
  8106. //循环赋值
  8107. for (int i = 0; i < DeleClientList.Count; i++)
  8108. {
  8109. builder.MoveToCell(0, i + 1, 0, 0);
  8110. builder.Write(DeleClientList[i].Name);
  8111. builder.MoveToCell(0, i + 1, 1, 0);
  8112. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8113. builder.Write(sex);
  8114. builder.MoveToCell(0, i + 1, 2, 0);
  8115. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8116. builder.MoveToCell(0, i + 1, 3, 0);
  8117. builder.Write(DeleClientList[i].Company);
  8118. builder.MoveToCell(0, i + 1, 4, 0);
  8119. builder.Write(DeleClientList[i].Job);
  8120. }
  8121. //删除多余行
  8122. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8123. {
  8124. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8125. }
  8126. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8127. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8128. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8129. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8130. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8131. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8132. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8133. }
  8134. }
  8135. return Ok(JsonView(400, "操作失败!", ""));
  8136. }
  8137. catch (Exception ex)
  8138. {
  8139. return Ok(JsonView(400, ex.Message, ""));
  8140. }
  8141. }
  8142. /// <summary>
  8143. /// 获取三公费用标准city
  8144. /// </summary>
  8145. /// <param name="placeData"></param>
  8146. /// <param name="nationalTravelFeeId"></param>
  8147. /// <returns></returns>
  8148. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8149. {
  8150. string _city = string.Empty;
  8151. if (placeData.Count < 1) return _city;
  8152. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8153. if (data == null) return _city;
  8154. string country = data.Country;
  8155. string city = data.City;
  8156. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8157. else _city = city;
  8158. return _city;
  8159. }
  8160. ///// <summary>
  8161. ///// 团组模块 - 出入境费用 - 明细表导出
  8162. ///// </summary>
  8163. ///// <returns></returns>
  8164. //[HttpPost]
  8165. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8166. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8167. //{
  8168. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8169. // if (data.Code != 0)
  8170. // {
  8171. // return Ok(JsonView(false, data.Msg));
  8172. // }
  8173. // return Ok(JsonView(true, data.Msg, data.Data));
  8174. //}
  8175. /// <summary>
  8176. /// 团组模块 - 出入境费用 - 一键清空
  8177. /// </summary>
  8178. /// <returns></returns>
  8179. [HttpPost]
  8180. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8182. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8183. {
  8184. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8185. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8186. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8187. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8188. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8189. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8190. .SetColumns(x => new Grp_DayOtherPrice
  8191. {
  8192. IsDel = 1,
  8193. DeleteUserId = dto.UserId,
  8194. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8195. })
  8196. .ExecuteCommandAsync();
  8197. if (_view.Code == 0)
  8198. {
  8199. return Ok(JsonView(true, "操作成功"));
  8200. }
  8201. return Ok(JsonView(false, "操作失败"));
  8202. }
  8203. /// <summary>
  8204. /// 团组模块 - 出入境费用 - 子项删除
  8205. /// </summary>
  8206. /// <returns></returns>
  8207. [HttpPost]
  8208. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8210. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8211. {
  8212. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8213. if (data.Code != 0)
  8214. {
  8215. return Ok(JsonView(false, data.Msg));
  8216. }
  8217. return Ok(JsonView(true, "操作成功!", data.Data));
  8218. }
  8219. /// <summary>
  8220. /// 删除三公其他费用
  8221. /// </summary>
  8222. /// <param name="dto"></param>
  8223. /// <returns></returns>
  8224. [HttpPost]
  8225. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8226. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  8227. {
  8228. var jw = JsonView(false, "删除失败!");
  8229. var data = new Grp_DayOtherPrice()
  8230. {
  8231. Id = dto.Id,
  8232. IsDel = 1,
  8233. DeleteUserId = dto.DeleteUserId,
  8234. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8235. };
  8236. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8237. if (del > 0)
  8238. {
  8239. jw.Code = 200;
  8240. jw.Msg = "删除成功!";
  8241. }
  8242. return Ok(jw);
  8243. }
  8244. /// <summary>
  8245. /// 团组模块 - 出入境国家费用标准 List
  8246. /// </summary>
  8247. /// <returns></returns>
  8248. [HttpPost]
  8249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8250. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  8251. {
  8252. int provinceId = dto.ProvinceId;
  8253. if (provinceId < 1) provinceId = 122; //默认四川省数据
  8254. var nftData = await _sqlSugar
  8255. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  8256. JoinType.Left, ntf.Currency == sd1.Id,
  8257. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8258. JoinType.Left, ntf.ProvinceId == c.Id
  8259. ))
  8260. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8261. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  8262. {
  8263. Id = ntf.Id,
  8264. ProvinceId = ntf.ProvinceId,
  8265. ProvinceName = c.Name_CN,
  8266. Continent = ntf.Continent,
  8267. Country = ntf.Country,
  8268. City = ntf.City,
  8269. Currency = ntf.Currency,
  8270. CurrencyCode = sd1.Name,
  8271. CurrencyName = sd1.Remark,
  8272. RoomCost = ntf.RoomCost,
  8273. FoodCost = ntf.FoodCost,
  8274. PublicCost = ntf.PublicCost,
  8275. LastUpdateUserId = ntf.LastUpdateUserId,
  8276. LastUpdateUserName = u.CnName,
  8277. LastUpdateTime = ntf.LastUpdateTime
  8278. })
  8279. .ToListAsync();
  8280. return Ok(JsonView(true, "查询成功!", nftData));
  8281. }
  8282. /// <summary>
  8283. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  8284. /// </summary>
  8285. /// <returns></returns>
  8286. [HttpPost]
  8287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8288. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  8289. {
  8290. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  8291. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  8292. List<string> countryData = new List<string>();
  8293. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  8294. countryData = countryData.Distinct().ToList();
  8295. List<dynamic> dataSource = new List<dynamic>();
  8296. foreach (var item in countryData)
  8297. {
  8298. var cityData1 = new List<string>();
  8299. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  8300. var countryData2 = new
  8301. {
  8302. CountryName = item,
  8303. CityData = cityData1
  8304. };
  8305. if (!dataSource.Contains(countryData2))
  8306. {
  8307. dataSource.Add(countryData2);
  8308. }
  8309. }
  8310. return Ok(JsonView(true, "查询成功!", dataSource));
  8311. }
  8312. /// <summary>
  8313. /// 团组模块 - 出入境国家费用标准 Page List
  8314. /// </summary>
  8315. /// <returns></returns>
  8316. [HttpPost]
  8317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8318. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  8319. {
  8320. int portId = dto.PortType,
  8321. pageIndex = dto.PageIndex,
  8322. pageSize = dto.PageSize;
  8323. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8324. if (pageIndex == 0) pageIndex = 1;
  8325. if (pageSize == 0) pageSize = 10;
  8326. RefAsync<int> total = 0;
  8327. var nationalTravelFeeData = await _sqlSugar
  8328. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  8329. JoinType.Left, ntf.Currency == sd1.Id,
  8330. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  8331. JoinType.Left, ntf.ProvinceId == sd2.Id
  8332. ))
  8333. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  8334. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  8335. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  8336. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  8337. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  8338. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  8339. {
  8340. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  8341. Id = ntf.Id,
  8342. ProvinceId = ntf.ProvinceId,
  8343. ProvinceName = sd2.Name_CN,
  8344. Continent = ntf.Continent,
  8345. Country = ntf.Country,
  8346. City = ntf.City,
  8347. Currency = ntf.Currency,
  8348. CurrencyCode = sd1.Name,
  8349. CurrencyName = sd1.Remark,
  8350. RoomCost = ntf.RoomCost,
  8351. FoodCost = ntf.FoodCost,
  8352. PublicCost = ntf.PublicCost,
  8353. LastUpdateUserId = ntf.LastUpdateUserId,
  8354. LastUpdateUserName = u.CnName,
  8355. LastUpdateTime = ntf.LastUpdateTime,
  8356. Remark = ntf.Remark
  8357. })
  8358. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8359. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  8360. }
  8361. /// <summary>
  8362. /// 团组模块 - 出入境国家费用标准 根据城市查询
  8363. /// </summary>
  8364. /// <returns></returns>
  8365. [HttpPost]
  8366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8367. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  8368. {
  8369. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  8370. int portId = dto.PortType;
  8371. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  8372. string whereSql = string.Empty;
  8373. if (!string.IsNullOrEmpty(dto.Country))
  8374. {
  8375. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  8376. }
  8377. if (!string.IsNullOrEmpty(dto.City))
  8378. {
  8379. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  8380. }
  8381. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  8382. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  8383. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  8384. From Grp_NationalTravelFee gntf
  8385. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  8386. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  8387. Where gntf.Isdel = 0 {0} ", whereSql);
  8388. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  8389. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  8390. }
  8391. /// <summary>
  8392. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  8393. /// </summary>
  8394. /// <returns></returns>
  8395. [HttpPost]
  8396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8397. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  8398. {
  8399. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  8400. }
  8401. /// <summary>
  8402. /// 团组模块 - 出入境国家费用标准 - Del
  8403. /// </summary>
  8404. /// <returns></returns>
  8405. [HttpPost]
  8406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8407. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  8408. {
  8409. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  8410. {
  8411. Id = dto.Id,
  8412. DeleteUserId = dto.DeleteUserId,
  8413. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8414. IsDel = 1
  8415. };
  8416. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  8417. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  8418. .WhereColumns(it => new { it.Id })
  8419. .ExecuteCommandAsync();
  8420. if (delStatus <= 0)
  8421. {
  8422. return Ok(JsonView(false, "删除失败!"));
  8423. }
  8424. return Ok(JsonView(true, "操作成功!"));
  8425. }
  8426. /// <summary>
  8427. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  8428. /// 注:Get 请求Headers 加 Token
  8429. /// </summary>
  8430. /// <param name="groupId"></param>
  8431. /// <returns></returns>
  8432. [HttpGet("{groupId}")]
  8433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8434. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  8435. {
  8436. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8437. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  8438. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  8439. data.ForEach(x =>
  8440. {
  8441. x.CreateUserId = _currUserInfo.UserId;
  8442. });
  8443. if (data.Any())
  8444. {
  8445. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  8446. if (add > 0)
  8447. {
  8448. return Ok(JsonView(true, "操作成功!"));
  8449. }
  8450. }
  8451. return Ok(JsonView(false, "未操作!"));
  8452. }
  8453. #endregion
  8454. #region 团组经理模块 出入境费用-草稿
  8455. /// <summary>
  8456. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8457. /// </summary>
  8458. /// <returns></returns>
  8459. [HttpGet]
  8460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8461. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8462. {
  8463. var provData = await _groupRepository.ProvinceBasicSource();
  8464. return Ok(JsonView(true, "查询成功!", provData));
  8465. }
  8466. /// <summary>
  8467. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8468. /// </summary>
  8469. /// <returns></returns>
  8470. [HttpGet("{provinceId}")]
  8471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8472. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8473. {
  8474. //验证城市归属并给默认值
  8475. if (provinceId < 1) provinceId = 122;
  8476. /*
  8477. * 122 四川
  8478. * 108 贵州
  8479. * 103 重庆
  8480. * 132 云南
  8481. */
  8482. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8483. return Ok(JsonView(true, "查询成功!", new
  8484. {
  8485. WordTypeData = wordTypeData,
  8486. ExcelTypeData = excelTypeData,
  8487. }));
  8488. }
  8489. /// <summary>
  8490. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8491. /// </summary>
  8492. /// <returns></returns>
  8493. [HttpPost]
  8494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8495. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8496. {
  8497. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8498. .Where(x => x.IsDel == 0)
  8499. .OrderByDescending(x => x.CreateTime)
  8500. .Select(x => new { x.Id, x.DraftName })
  8501. .ToListAsync();
  8502. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8503. //SetDataInfoView
  8504. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8505. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8506. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8507. int provinceId = dto.ProvinceId;
  8508. if (provinceId < 1) provinceId = 122;
  8509. /*
  8510. * 122 四川
  8511. * 108 贵州
  8512. * 103 重庆
  8513. * 132 云南
  8514. */
  8515. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8516. //默认币种显示
  8517. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8518. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8519. return Ok(JsonView(true, "查询成功!", new
  8520. {
  8521. DraftNameDatas = draftNameDatas,
  8522. CurrencyData = _CurrencyData,
  8523. WordTypeData = wordTypeData,
  8524. ExcelTypeData = excelTypeData,
  8525. CurrencyInit = _currencyInfos,
  8526. ViewPermissionData = viewPermissionData
  8527. }));
  8528. }
  8529. /// <summary>
  8530. /// 团组模块 - 出入境费用-草稿
  8531. /// 实时汇率 tips
  8532. /// 机票费用 tips
  8533. /// </summary>
  8534. /// <returns></returns>
  8535. [HttpPost]
  8536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8537. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8538. {
  8539. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8540. return Ok(JsonView(true, "查询成功!", new
  8541. {
  8542. //GroupNameData = groupNameData.Data,
  8543. //visaData = visaData.Data,
  8544. //airData = airData.Data,
  8545. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8546. }));
  8547. }
  8548. /// <summary>
  8549. /// 团组模块 - 出入境费用-草稿
  8550. /// 签证费用 tips
  8551. /// </summary>
  8552. /// <returns></returns>
  8553. [HttpPost]
  8554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8555. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8556. {
  8557. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8558. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8559. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8560. .Select(x => x.NationalTravelFeeId)
  8561. .Distinct()
  8562. .ToListAsync();
  8563. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8564. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8565. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8566. .Select(x => x.Country)
  8567. .Distinct()
  8568. .ToArrayAsync();
  8569. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8570. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8571. return Ok(JsonView(true, "查询成功!", new
  8572. {
  8573. totalAmt,
  8574. remark
  8575. }));
  8576. }
  8577. /// <summary>
  8578. /// 团组模块 - 出入境费用-草稿 - Info
  8579. /// </summary>
  8580. /// <returns></returns>
  8581. [HttpPost]
  8582. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8584. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8585. {
  8586. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8587. }
  8588. /// <summary>
  8589. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8590. /// </summary>
  8591. /// <returns></returns>
  8592. [HttpPost]
  8593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8594. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8595. {
  8596. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8597. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8598. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8599. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8600. foreach (var userId in dto.UserIds)
  8601. {
  8602. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8603. }
  8604. if (permissions.Any())
  8605. {
  8606. _sqlSugar.BeginTran();
  8607. try
  8608. {
  8609. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8610. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8611. if (result < 1)
  8612. {
  8613. _sqlSugar.RollbackTran();
  8614. return Ok(JsonView(false));
  8615. }
  8616. }
  8617. catch (Exception ex)
  8618. {
  8619. _sqlSugar.RollbackTran();
  8620. return Ok(JsonView(false, ex.Message));
  8621. }
  8622. _sqlSugar.CommitTran();
  8623. return Ok(JsonView(true));
  8624. }
  8625. return Ok(JsonView(false));
  8626. }
  8627. /// <summary>
  8628. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8629. /// </summary>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8634. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8635. {
  8636. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8637. if (data.Code != 0)
  8638. {
  8639. return Ok(JsonView(false, data.Msg));
  8640. }
  8641. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8642. //汇率信息记录
  8643. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8644. return Ok(JsonView(true, data.Msg, data.Data));
  8645. }
  8646. /// <summary>
  8647. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8648. /// </summary>
  8649. /// <param name="dto"></param>
  8650. /// <returns></returns>
  8651. [HttpPost]
  8652. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8654. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8655. {
  8656. try
  8657. {
  8658. var id = dto.Id;
  8659. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8660. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8661. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8662. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8663. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8664. 3 团组成员名单 1 团组成员名单", ""));
  8665. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8666. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8667. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8668. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8669. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8670. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8671. //数据源
  8672. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8673. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8674. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8675. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8676. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8677. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8678. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8679. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8680. .Select((x, a, b) => new
  8681. {
  8682. x.Index,
  8683. itemName = a.Name,
  8684. CurrencyStr = b.Name,
  8685. x.Cost,
  8686. x.SubTotal,
  8687. x.Remark
  8688. })
  8689. .OrderBy((x) => x.Index)
  8690. .ToList(); //其他款项费用
  8691. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8692. var peiceItemCurrencys = new List<string>();
  8693. if (_DayAndCosts.Any())
  8694. {
  8695. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8696. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8697. }
  8698. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8699. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8700. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8701. {
  8702. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8703. }
  8704. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8705. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8706. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8707. if (dto.ExportType == 1) //明细表
  8708. {
  8709. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8710. {
  8711. //获取模板
  8712. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8713. //载入模板
  8714. Document doc = new Document(tempPath);
  8715. DocumentBuilder builder = new DocumentBuilder(doc);
  8716. //利用键值对存放数据
  8717. Dictionary<string, string> dic = new Dictionary<string, string>();
  8718. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8719. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8720. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8721. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8722. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8723. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8724. //境内费用(其他费用)
  8725. if (_EnterExitCosts.ChoiceOne == 1)
  8726. {
  8727. string row1_1 = "";
  8728. if (_EnterExitCosts.Visa > 0)
  8729. {
  8730. //insidePayTotal += _EnterExitCosts.Visa;
  8731. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8732. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8733. //{
  8734. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8735. //}
  8736. }
  8737. string row1_2 = "";
  8738. if (_EnterExitCosts.YiMiao > 0)
  8739. {
  8740. //insidePayTotal += _EnterExitCosts.YiMiao;
  8741. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8742. }
  8743. if (_EnterExitCosts.HeSuan > 0)
  8744. {
  8745. //insidePayTotal += _EnterExitCosts.HeSuan;
  8746. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8747. }
  8748. if (_EnterExitCosts.Service > 0)
  8749. {
  8750. //insidePayTotal += _EnterExitCosts.Service;
  8751. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8752. }
  8753. string row1_3 = "";
  8754. if (_EnterExitCosts.Safe > 0)
  8755. {
  8756. //insidePayTotal += _EnterExitCosts.Safe;
  8757. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8758. }
  8759. if (_EnterExitCosts.Ticket > 0)
  8760. {
  8761. //insidePayTotal += _EnterExitCosts.Ticket;
  8762. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8763. }
  8764. string row1 = "";
  8765. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8766. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8767. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8768. row1 += $"备注:{_EnterExitCosts.Remark}";
  8769. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8770. dic.Add("Row1Str", row1);
  8771. }
  8772. string airTotalStr = string.Empty,
  8773. airPriceStr = string.Empty;
  8774. //经济舱
  8775. if (_EnterExitCosts.SumJJC == 1)
  8776. {
  8777. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8778. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8779. }
  8780. //公务舱
  8781. if (_EnterExitCosts.SumGWC == 1)
  8782. {
  8783. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8784. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8785. }
  8786. //头等舱
  8787. if (_EnterExitCosts.SumTDC == 1)
  8788. {
  8789. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8790. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8791. }
  8792. //汇率描述
  8793. string rateStr = "";
  8794. if (peiceItemCurrencyInfos.Any())
  8795. {
  8796. rateStr = "\r\n汇率描述:";
  8797. foreach (var item in peiceItemCurrencyInfos)
  8798. {
  8799. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8800. }
  8801. }
  8802. string twoItemRemark = "备注:";
  8803. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8804. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8805. dic.Add("AirTotalStr", airTotalStr);
  8806. dic.Add("AirPriceStr", airPriceStr);
  8807. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8808. dic.Add("TwoItemRemark", twoItemRemark);
  8809. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8810. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8811. int table1Row = 0,
  8812. table2Row = 0,
  8813. table3Row = 0,
  8814. table4Row = 0,
  8815. table5Row = 0;
  8816. //住宿费
  8817. if (_EnterExitCosts.ChoiceThree == 1)
  8818. {
  8819. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8820. table1Row = dac1.Count;
  8821. #region 填充word表格内容
  8822. for (int i = 0; i < dac1.Count; i++)
  8823. {
  8824. var dac = dac1[i];
  8825. if (dac == null) continue;
  8826. builder.MoveToCell(0, i, 0, 0);
  8827. builder.Write("第" + dac.Days.ToString() + "晚:");
  8828. builder.MoveToCell(0, i, 1, 0);
  8829. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8830. //builder.Write(dac.Place == null ? "" : dac.Place);
  8831. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8832. builder.MoveToCell(0, i, 2, 0);
  8833. builder.Write("费用标准:");
  8834. string curr = "";
  8835. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8836. if (currData != null)
  8837. {
  8838. curr = currData.Name;
  8839. }
  8840. builder.MoveToCell(0, i, 3, 0);
  8841. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8842. builder.MoveToCell(0, i, 4, 0);
  8843. builder.Write("费用小计:");
  8844. builder.MoveToCell(0, i, 5, 0);
  8845. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8846. }
  8847. #endregion
  8848. }
  8849. else dic.Add("SubZS", "0.00");
  8850. //删除多余行
  8851. while (table1.Rows.Count > table1Row)
  8852. {
  8853. table1.Rows.RemoveAt(table1Row);
  8854. }
  8855. //伙食费
  8856. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8857. if (_EnterExitCosts.ChoiceFour == 1)
  8858. {
  8859. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8860. table2Row = dac2.Count;
  8861. #region 填充word表格内容
  8862. for (int i = 0; i < dac2.Count; i++)
  8863. {
  8864. var dac = dac2[i];
  8865. if (dac == null) continue;
  8866. builder.MoveToCell(1, i, 0, 0);
  8867. builder.Write("第" + dac.Days.ToString() + "天:");
  8868. builder.MoveToCell(1, i, 1, 0);
  8869. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8870. builder.MoveToCell(1, i, 2, 0);
  8871. builder.Write("费用标准:");
  8872. string curr = "";
  8873. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8874. if (currData != null)
  8875. {
  8876. curr = currData.Name;
  8877. }
  8878. builder.MoveToCell(1, i, 3, 0);
  8879. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8880. builder.MoveToCell(1, i, 4, 0);
  8881. builder.Write("费用小计:");
  8882. builder.MoveToCell(1, i, 5, 0);
  8883. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8884. }
  8885. #endregion
  8886. }
  8887. else dic.Add("SubHS", "0.00");
  8888. //删除多余行
  8889. while (table2.Rows.Count > table2Row)
  8890. {
  8891. table2.Rows.RemoveAt(table2Row);
  8892. }
  8893. //公杂费
  8894. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8895. if (_EnterExitCosts.ChoiceFive == 1)
  8896. {
  8897. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8898. table3Row = dac3.Count;
  8899. #region 填充word表格内容
  8900. for (int i = 0; i < dac3.Count; i++)
  8901. {
  8902. var dac = dac3[i];
  8903. if (dac == null) continue;
  8904. builder.MoveToCell(2, i, 0, 0);
  8905. builder.Write("第" + dac.Days.ToString() + "天:");
  8906. builder.MoveToCell(2, i, 1, 0);
  8907. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8908. builder.MoveToCell(2, i, 2, 0);
  8909. builder.Write("费用标准:");
  8910. string curr = "";
  8911. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8912. if (currData != null)
  8913. {
  8914. curr = currData.Name;
  8915. }
  8916. builder.MoveToCell(2, i, 3, 0);
  8917. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8918. builder.MoveToCell(2, i, 4, 0);
  8919. builder.Write("费用小计:");
  8920. builder.MoveToCell(2, i, 5, 0);
  8921. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8922. }
  8923. //删除多余行
  8924. while (table3.Rows.Count > table3Row)
  8925. {
  8926. table3.Rows.RemoveAt(table3Row);
  8927. }
  8928. #endregion
  8929. }
  8930. else dic.Add("SubGZF", "0.00");
  8931. //删除多余行
  8932. while (table3.Rows.Count > table3Row)
  8933. {
  8934. table3.Rows.RemoveAt(table3Row);
  8935. }
  8936. //培训费
  8937. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8938. if (_EnterExitCosts.ChoiceSix == 1)
  8939. {
  8940. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8941. dic.Add("SubPX", pxStr);
  8942. table4Row = dac4.Count;
  8943. #region 填充word表格内容
  8944. for (int i = 0; i < dac4.Count; i++)
  8945. {
  8946. var dac = dac4[i];
  8947. if (dac == null) continue;
  8948. builder.MoveToCell(3, i, 0, 0);
  8949. builder.Write("第" + dac.Days.ToString() + "天:");
  8950. builder.MoveToCell(3, i, 1, 0);
  8951. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8952. builder.MoveToCell(3, i, 2, 0);
  8953. builder.Write("费用标准:");
  8954. string curr = "";
  8955. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8956. if (currData != null)
  8957. {
  8958. curr = currData.Name;
  8959. }
  8960. builder.MoveToCell(3, i, 3, 0);
  8961. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8962. builder.MoveToCell(3, i, 4, 0);
  8963. builder.Write("费用小计:");
  8964. builder.MoveToCell(3, i, 5, 0);
  8965. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8966. }
  8967. #endregion
  8968. }
  8969. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8970. //删除多余行
  8971. while (table4.Rows.Count > table4Row)
  8972. {
  8973. table4.Rows.RemoveAt(table4Row);
  8974. }
  8975. //其他费用
  8976. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8977. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8978. {
  8979. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8980. dic.Add("titleQi", qtStr);
  8981. table5Row = dac5.Count;
  8982. #region 填充word表格内容
  8983. for (int i = 0; i < dac5.Count; i++)
  8984. {
  8985. var dac = dac5[i];
  8986. if (dac == null) continue;
  8987. builder.MoveToCell(4, i, 0, 0);
  8988. builder.Write("第" + dac.Index.ToString() + "项:");
  8989. builder.MoveToCell(4, i, 1, 0);
  8990. builder.Write(dac.itemName);
  8991. builder.MoveToCell(4, i, 2, 0);
  8992. builder.Write("费用标准:");
  8993. builder.MoveToCell(4, i, 3, 0);
  8994. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8995. builder.MoveToCell(4, i, 4, 0);
  8996. builder.Write("费用小计:");
  8997. builder.MoveToCell(4, i, 5, 0);
  8998. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8999. builder.MoveToCell(4, i, 6, 0);
  9000. builder.Write("备注:");
  9001. builder.MoveToCell(4, i, 7, 0);
  9002. builder.Write(dac.Remark);
  9003. }
  9004. #endregion
  9005. }
  9006. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9007. //删除多余行
  9008. while (table5.Rows.Count > table5Row)
  9009. {
  9010. table5.Rows.RemoveAt(table5Row);
  9011. }
  9012. //加上其他费用
  9013. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9014. decimal subJJC = 0.00M,
  9015. subGWC = 0.00M,
  9016. subTDC = 0.00M;
  9017. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9018. string totalLabel = string.Format("全部费用总计:");
  9019. //经济舱
  9020. if (_EnterExitCosts.SumJJC == 1)
  9021. {
  9022. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9023. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9024. }
  9025. //公务舱
  9026. if (_EnterExitCosts.SumGWC == 1)
  9027. {
  9028. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9029. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9030. }
  9031. //头等舱
  9032. if (_EnterExitCosts.SumTDC == 1)
  9033. {
  9034. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9035. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9036. }
  9037. //TotalLabel
  9038. dic.Add("TotalLabel", totalLabel);
  9039. #region 填充word模板书签内容
  9040. foreach (var key in dic.Keys)
  9041. {
  9042. Bookmark bookmark = doc.Range.Bookmarks[key];
  9043. if (bookmark != null)
  9044. {
  9045. builder.MoveToBookmark(key);
  9046. builder.Write(dic[key]);
  9047. }
  9048. }
  9049. #endregion
  9050. //文件名
  9051. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9052. strFileName = CommonFun.ValidFileName(strFileName);
  9053. AsposeHelper.removewatermark_v2180();
  9054. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9055. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9056. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9057. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9058. }
  9059. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9060. {
  9061. //获取模板
  9062. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9063. //载入模板
  9064. Document doc = new Document(tempPath);
  9065. DocumentBuilder builder = new DocumentBuilder(doc);
  9066. Dictionary<string, string> dic = new Dictionary<string, string>();
  9067. string returnCodeLabel = string.Empty;
  9068. if (nationalTravelFeeData.Any())
  9069. {
  9070. List<string> list = new List<string>();
  9071. foreach (var item in nationalTravelFeeData)
  9072. {
  9073. list.Add($"{item.Country}({item.City})");
  9074. }
  9075. list = list.Distinct().ToList();
  9076. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9077. }
  9078. var countryLabel = string.Empty;
  9079. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9080. if (countryData.Any())
  9081. {
  9082. countryLabel = string.Join("、", countryData);
  9083. }
  9084. dic.Add("ReturnCodeAir", returnCodeLabel);
  9085. dic.Add("VisitStartDate", "-");
  9086. dic.Add("VisitEndDate", "-");
  9087. dic.Add("Day", "-");
  9088. dic.Add("VisitCountry", countryLabel);
  9089. dic.Add("ClientUnit", "-");
  9090. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9091. //dic.Add("Names", Names);
  9092. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9093. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9094. decimal dac1totalPrice = 0.00M;
  9095. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9096. foreach (var dac in dac1)
  9097. {
  9098. if (dac.SubTotal == 0.00M)
  9099. {
  9100. continue;
  9101. }
  9102. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9103. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9104. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9105. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9106. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9107. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9108. builder.Write(currency);//币种
  9109. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9110. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9111. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9112. builder.Write("");//人数
  9113. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9114. builder.Write("");//天数
  9115. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9116. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9117. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9118. decimal rate = 0.00M;
  9119. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9120. builder.Write(rate.ToString("#0.0000"));//汇率
  9121. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9122. decimal rbmPrice = dac.SubTotal;
  9123. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9124. accommodationStartIndex++;
  9125. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9126. }
  9127. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9128. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9129. {
  9130. table1.Rows.RemoveAt(i - 1);
  9131. foodandotherStartIndex--;
  9132. }
  9133. if (dac2.Count == dac3.Count)//国家 币种 金额
  9134. {
  9135. for (int i = 0; i < dac2.Count; i++)
  9136. {
  9137. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9138. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9139. }
  9140. }
  9141. decimal dac2totalPrice = 0.00M;
  9142. foreach (var dac in dac2)
  9143. {
  9144. if (dac.SubTotal == 0)
  9145. {
  9146. continue;
  9147. }
  9148. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9149. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9150. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9151. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9152. builder.Write(currency);//币种
  9153. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9154. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9155. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9156. builder.Write("");//人数
  9157. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9158. builder.Write("");//天数
  9159. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9160. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9161. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9162. decimal rate = 0.00M;
  9163. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9164. builder.Write(rate.ToString("#0.0000"));//汇率
  9165. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9166. decimal rbmPrice = dac.SubTotal;
  9167. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9168. foodandotherStartIndex++;
  9169. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9170. }
  9171. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9172. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9173. {
  9174. table1.Rows.RemoveAt(i - 1);
  9175. }
  9176. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9177. string otherFeeStr = "";
  9178. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9179. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9180. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9181. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9182. foreach (var otherInfo in dac5)
  9183. {
  9184. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9185. }
  9186. #endregion
  9187. if (otherFeeStr.Length > 0)
  9188. {
  9189. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9190. otherFeeStr = $"({otherFeeStr})";
  9191. dic.Add("OtherFeeStr", otherFeeStr);
  9192. }
  9193. //总计
  9194. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9195. //国际旅费
  9196. string outsideAir = string.Empty;
  9197. string allPriceAir = string.Empty;
  9198. if (_EnterExitCosts.SumJJC == 1)
  9199. {
  9200. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9201. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9202. }
  9203. if (_EnterExitCosts.SumGWC == 1)
  9204. {
  9205. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9206. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9207. }
  9208. if (_EnterExitCosts.SumTDC == 1)
  9209. {
  9210. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9211. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9212. }
  9213. dic.Add("InTravelPrice", $"({outsideAir})");
  9214. dic.Add("FinalSumPrice", $"({allPriceAir})");
  9215. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  9216. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  9217. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  9218. foreach (var key in dic.Keys)
  9219. {
  9220. builder.MoveToBookmark(key);
  9221. builder.Write(dic[key]);
  9222. }
  9223. //模板文件名
  9224. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9225. strFileName = CommonFun.ValidFileName(strFileName);
  9226. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9227. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9228. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9229. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9230. }
  9231. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  9232. {
  9233. //获取模板
  9234. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  9235. //载入模板
  9236. WorkbookDesigner designer = new WorkbookDesigner();
  9237. designer.Workbook = new Workbook(tempPath);
  9238. Dictionary<string, string> dic = new Dictionary<string, string>();
  9239. string returnCodeLabel = string.Empty;
  9240. if (nationalTravelFeeData.Any())
  9241. {
  9242. List<string> list = new List<string>();
  9243. foreach (var item in nationalTravelFeeData)
  9244. {
  9245. list.Add($"{item.Country}({item.City})");
  9246. }
  9247. list = list.Distinct().ToList();
  9248. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9249. }
  9250. var countryLabel = string.Empty;
  9251. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9252. if (countryData.Any())
  9253. {
  9254. countryLabel = string.Join("、", countryData);
  9255. }
  9256. dic.Add("ReturnCodeAir", returnCodeLabel);
  9257. dic.Add("VisitStartDate", "-");
  9258. dic.Add("VisitEndDate", "-");
  9259. dic.Add("Day", "0");
  9260. dic.Add("VisitCountry", countryLabel);
  9261. dic.Add("ClientUnit", "-");
  9262. designer.SetDataSource("ClientUnit", "-");
  9263. designer.SetDataSource("VisitCountry", countryLabel);
  9264. designer.SetDataSource("Group", "-");
  9265. designer.SetDataSource("ClientUnitTitle", "-");
  9266. designer.SetDataSource("Name", "-");
  9267. designer.SetDataSource("VisitStartDate", "-");
  9268. designer.SetDataSource("Day", "0");
  9269. designer.SetDataSource("ReturnCode", returnCodeLabel);
  9270. designer.SetDataSource("ReturnCodeAir", "-");
  9271. int startIndex = 10;
  9272. const int startIndexcopy = 10;
  9273. if (dac2.Count == dac3.Count)//国家 币种 金额
  9274. {
  9275. for (int i = 0; i < dac2.Count; i++)
  9276. {
  9277. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9278. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9279. }
  9280. }
  9281. DataTable dtdac1 = new DataTable();
  9282. List<string> place = new List<string>();
  9283. dtdac1.Columns.AddRange(new DataColumn[] {
  9284. new DataColumn(){ ColumnName = "city"},
  9285. new DataColumn(){ ColumnName = "curr"},
  9286. new DataColumn(){ ColumnName = "criterion"},
  9287. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9288. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9289. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9290. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9291. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  9292. });
  9293. DataTable dtdac2 = new DataTable();
  9294. dtdac2.Columns.AddRange(new DataColumn[] {
  9295. new DataColumn(){ ColumnName = "city"},
  9296. new DataColumn(){ ColumnName = "curr"},
  9297. new DataColumn(){ ColumnName = "criterion"},
  9298. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  9299. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  9300. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  9301. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  9302. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  9303. });
  9304. dtdac1.TableName = "tb1";
  9305. dtdac2.TableName = "tb2";
  9306. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  9307. foreach (var item in dac1)
  9308. {
  9309. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9310. if (place.Contains(item.Place))
  9311. {
  9312. continue;
  9313. }
  9314. DataRow row = dtdac1.NewRow();
  9315. row["city"] = item.Place;
  9316. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9317. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9318. row["curr"] = currency;
  9319. row["rate"] = rate.ToString("#0.0000");
  9320. row["criterion"] = item.Cost.ToString("#0.00");
  9321. row["number"] = 1;
  9322. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9323. //row["costRMB"] = rbmPrice;
  9324. dtdac1.Rows.Add(row);
  9325. place.Add(item.Place);
  9326. }
  9327. place = new List<string>();
  9328. foreach (var item in dac2)
  9329. {
  9330. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  9331. if (place.Contains(item.Place))
  9332. {
  9333. continue;
  9334. }
  9335. DataRow row = dtdac2.NewRow();
  9336. row["city"] = item.Place;
  9337. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  9338. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  9339. row["curr"] = currency;
  9340. row["rate"] = rate.ToString("#0.0000");
  9341. row["criterion"] = item.Cost.ToString("#0.00");
  9342. row["number"] = 1;
  9343. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  9344. //row["cost"] = item.SubTotal;
  9345. //row["costRMB"] = rbmPrice;
  9346. dtdac2.Rows.Add(row);
  9347. place.Add(item.Place);
  9348. //dac2totalPrice += rbmPrice;
  9349. }
  9350. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  9351. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  9352. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9353. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  9354. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  9355. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  9356. string cell4Str1 = string.Empty;
  9357. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  9358. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  9359. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  9360. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  9361. string cellStr = $" 5.其他费用(";
  9362. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  9363. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  9364. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  9365. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  9366. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  9367. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  9368. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  9369. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  9370. foreach (var otherInfo in dac5)
  9371. {
  9372. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  9373. }
  9374. #endregion
  9375. if (cellStr.Length > 8)
  9376. {
  9377. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  9378. }
  9379. cellStr += ")";
  9380. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  9381. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  9382. decimal pxFee = dac4.Sum(it => it.Cost);
  9383. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  9384. string celllastStr1 = "";
  9385. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  9386. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  9387. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  9388. celllastStr1 += $",国际旅费 元";
  9389. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  9390. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  9391. designer.SetDataSource("cell4Str", cell4Str);
  9392. designer.SetDataSource("cellStr", cellStr);
  9393. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  9394. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9395. designer.SetDataSource("celllastStr", celllastStr);
  9396. Workbook wb = designer.Workbook;
  9397. var sheet = wb.Worksheets[0];
  9398. //绑定datatable数据集
  9399. designer.SetDataSource(dtdac1);
  9400. designer.SetDataSource(dtdac2);
  9401. designer.Process();
  9402. var rowStart = dtdac1.Rows.Count;
  9403. while (rowStart > 0)
  9404. {
  9405. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  9406. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9407. startIndex++;
  9408. rowStart--;
  9409. }
  9410. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  9411. startIndex += 1; //总计行
  9412. rowStart = dtdac2.Rows.Count;
  9413. while (rowStart > 0)
  9414. {
  9415. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  9416. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  9417. startIndex++;
  9418. rowStart--;
  9419. }
  9420. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  9421. wb.CalculateFormula(true);
  9422. //模板文件名
  9423. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9424. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9425. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9426. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9427. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9428. }
  9429. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  9430. {
  9431. //获取模板
  9432. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  9433. //载入模板
  9434. Document doc = new Document(tempPath);
  9435. DocumentBuilder builder = new DocumentBuilder(doc);
  9436. Dictionary<string, string> dic = new Dictionary<string, string>();
  9437. dic.Add("GroupName", "-");
  9438. dic.Add("ClientUnit", "-");
  9439. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  9440. //string missionLeaderJob = "";//负责人job
  9441. //int groupNumber = 0; //团人数
  9442. dic.Add("MissionLeader", "-"); //团负责人
  9443. dic.Add("MissionLeaderJob", "-"); //团负责人job
  9444. dic.Add("GroupNumber", "0"); //团人数
  9445. dic.Add("Day", "0");
  9446. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  9447. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  9448. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9449. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9450. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  9451. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  9452. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  9453. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  9454. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9455. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9456. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9457. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9458. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9459. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9460. //其他费用
  9461. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9462. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9463. //其他费用合计
  9464. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9465. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9466. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9467. //公务舱合计
  9468. //国际旅费
  9469. //string outsideJJ = "";
  9470. //string allPriceJJ = "";
  9471. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9472. {
  9473. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9474. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9475. }
  9476. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9477. {
  9478. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9479. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9480. }
  9481. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9482. {
  9483. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9484. dic.Add("AirFeeTotal", airFeeTotalStr);
  9485. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9486. dic.Add("FeeTotal", feeTotalStr);
  9487. }
  9488. foreach (var key in dic.Keys)
  9489. {
  9490. builder.MoveToBookmark(key);
  9491. builder.Write(dic[key]);
  9492. }
  9493. //模板文件名
  9494. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9495. strFileName = CommonFun.ValidFileName(strFileName);
  9496. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9497. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9498. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9499. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9500. }
  9501. }
  9502. else if (dto.ExportType == 2) //表格
  9503. {
  9504. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9505. }
  9506. else if (dto.ExportType == 3)
  9507. {
  9508. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9509. }
  9510. return Ok(JsonView(400, "只可导出明细表!", ""));
  9511. }
  9512. catch (Exception ex)
  9513. {
  9514. return Ok(JsonView(400, ex.Message, ""));
  9515. }
  9516. }
  9517. /// <summary>
  9518. /// 获取三公费用标准city
  9519. /// </summary>
  9520. /// <param name="placeData"></param>
  9521. /// <param name="nationalTravelFeeId"></param>
  9522. /// <returns></returns>
  9523. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9524. {
  9525. string _city = string.Empty;
  9526. if (!placeData.Any()) return _city;
  9527. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9528. if (data == null) return _city;
  9529. string country = data.Country;
  9530. string city = data.City;
  9531. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9532. else _city = city;
  9533. return _city;
  9534. }
  9535. /// <summary>
  9536. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9537. /// </summary>
  9538. /// <returns></returns>
  9539. [HttpPost]
  9540. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9542. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9543. {
  9544. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9545. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9546. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9547. if (_view.Code == 0)
  9548. {
  9549. return Ok(JsonView(true, "操作成功"));
  9550. }
  9551. return Ok(JsonView(false, "操作失败"));
  9552. }
  9553. /// <summary>
  9554. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9555. /// </summary>
  9556. /// <returns></returns>
  9557. [HttpPost]
  9558. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9560. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9561. {
  9562. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9563. if (data.Code != 0)
  9564. {
  9565. return Ok(JsonView(false, data.Msg));
  9566. }
  9567. return Ok(JsonView(true, "操作成功!", data.Data));
  9568. }
  9569. /// <summary>
  9570. /// 三公其他费用草稿 删除
  9571. /// </summary>
  9572. /// <param name="dto"></param>
  9573. /// <returns></returns>
  9574. [HttpPost]
  9575. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9576. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9577. {
  9578. var jw = JsonView(false, "删除失败!");
  9579. var data = new Grp_DayOtherPriceDraft()
  9580. {
  9581. Id = dto.Id,
  9582. IsDel = 1,
  9583. DeleteUserId = dto.DeleteUserId,
  9584. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9585. };
  9586. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9587. if (del > 0)
  9588. {
  9589. jw.Code = 200;
  9590. jw.Msg = "删除成功!";
  9591. }
  9592. return Ok(jw);
  9593. }
  9594. /// <summary>
  9595. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9596. /// </summary>
  9597. /// <returns></returns>
  9598. [HttpPost]
  9599. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9600. {
  9601. var jw = JsonView(false);
  9602. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9603. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9604. jw.Code = StatusCodes.Status200OK;
  9605. jw.Msg = "操作成功!";
  9606. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9607. return Ok(jw);
  9608. }
  9609. /// <summary>
  9610. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9611. /// </summary>
  9612. /// <param name="dto"></param>
  9613. /// <returns></returns>
  9614. [HttpPost]
  9615. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9616. {
  9617. int userId = dto.UserId,
  9618. portId = dto.PortType,
  9619. groupId = dto.GroupId,
  9620. draftId = dto.DraftId;
  9621. _portTypeData.Add(1);
  9622. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9623. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9624. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9625. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9626. _sqlSugar.BeginTran();
  9627. try
  9628. {
  9629. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9630. if (draftDatas == null)
  9631. {
  9632. _sqlSugar.RollbackTran();
  9633. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9634. }
  9635. //验证可覆盖已有数据 两边创建人需为同一人;
  9636. int draftCreateUserId = draftDatas.CreateUserId,
  9637. formalCreateUserId = 0;
  9638. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9639. if (formalData != null)
  9640. {
  9641. formalCreateUserId = formalData.CreateUserId;
  9642. if (draftCreateUserId != formalCreateUserId)
  9643. {
  9644. _sqlSugar.RollbackTran();
  9645. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9646. }
  9647. }
  9648. //默认添加查看、编辑权限(创建人、自己)
  9649. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9650. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9651. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9652. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9653. newExterData.DiId = groupId;
  9654. newExterData.CreateUserId = userId;
  9655. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9656. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9657. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9658. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9659. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9660. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9661. //数据如果存在执行删除
  9662. if (enterExitCostInfo != null)
  9663. {
  9664. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9665. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9666. .Where(x => x.Id == enterExitCostInfo.Id)
  9667. .ExecuteCommand();
  9668. _sqlSugar.Updateable<Grp_DayAndCost>()
  9669. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9670. .Where(x => x.DiId == groupId)
  9671. .ExecuteCommand();
  9672. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9673. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9674. .Where(x => x.Diid == groupId)
  9675. .ExecuteCommand();
  9676. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9677. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9678. .Where(x => x.GroupId == groupId)
  9679. .ExecuteCommand();
  9680. }
  9681. //执行insert
  9682. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9683. if (insertId < 1)
  9684. {
  9685. _sqlSugar.RollbackTran();
  9686. return Ok(JsonView(false, "草稿数据导入失败!"));
  9687. }
  9688. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9689. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9690. #region 默认添加权限
  9691. #endregion
  9692. _sqlSugar.CommitTran();
  9693. //执行操作之后
  9694. //生成默认文件pdf并且通知人员
  9695. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9696. {
  9697. DiId = groupId,
  9698. ExportType = 1,
  9699. SubTypeId = 1005
  9700. }, "pdf");
  9701. //发送通知
  9702. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9703. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9704. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9705. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9706. //汇率信息记录
  9707. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9708. return Ok(JsonView(true));
  9709. }
  9710. catch (Exception ex)
  9711. {
  9712. _sqlSugar.RollbackTran();
  9713. return Ok(JsonView(false, ex.Message));
  9714. }
  9715. }
  9716. #endregion
  9717. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9718. /// <summary>
  9719. /// 获取币种基础数据(含逻辑处理)
  9720. /// </summary>
  9721. /// <returns></returns>
  9722. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9723. {
  9724. return await GeneralMethod.EnterExitCostInitRate();
  9725. }
  9726. /// <summary>
  9727. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9728. /// </summary>
  9729. /// <returns></returns>
  9730. [HttpPost]
  9731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9732. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9733. {
  9734. //验证城市归属并给默认值
  9735. int provinceId = dto.ProvinceId;
  9736. if (provinceId < 1) provinceId = 122;
  9737. var dataSource = await _sqlSugar
  9738. .Queryable<Sys_SetData>()
  9739. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9740. .ToListAsync();
  9741. var fileTypes = new List<EecSetDataInfoView>();
  9742. //三公费用-Word明细类型
  9743. var wordTypeData = dataSource
  9744. .Where(it => it.STid == 72)
  9745. .Select(x => new EecSetDataInfoView
  9746. {
  9747. ParentId = 1,
  9748. Id = x.Id,
  9749. Name = x.Name
  9750. })
  9751. .ToArray();
  9752. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9753. var excelTypeData = dataSource
  9754. .Where(it => it.STid == 73)
  9755. .Select(x => new EecSetDataInfoView
  9756. {
  9757. ParentId = 2,
  9758. Id = x.Id,
  9759. Name = x.Name
  9760. })
  9761. .ToArray();
  9762. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9763. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9764. fileTypes.Add(groupNameList);
  9765. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9766. //默认币种显示
  9767. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9768. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9769. return Ok(JsonView(true, "查询成功!", new
  9770. {
  9771. FileTypeData = fileTypes,
  9772. CurrencyInit = _currencyInfos,
  9773. viewPermissionData = viewPermissionData
  9774. }));
  9775. }
  9776. /// <summary>
  9777. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9778. /// </summary>
  9779. /// <returns></returns>
  9780. [HttpPost]
  9781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9782. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9783. {
  9784. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9785. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9786. RefAsync<int> total = 0;
  9787. int diId = 0;
  9788. var status = int.TryParse(dto.GroupName, out diId);
  9789. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9790. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9791. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9792. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9793. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9794. .OrderByDescending(x => x.VisitStartDate)
  9795. .Select(x => new EnterExitCostMobileGroupView()
  9796. {
  9797. Id = x.Id,
  9798. GroupName = x.TeamName,
  9799. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9800. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9801. ProvinceId = x.CityId
  9802. })
  9803. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9804. //处理省份Id
  9805. if (data.Any())
  9806. {
  9807. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9808. if (provCityDatas.Any())
  9809. {
  9810. foreach (var item in data)
  9811. {
  9812. var provinceId = item.ProvinceId;
  9813. var isDefualtVal = true;
  9814. if (provinceId > 0)
  9815. {
  9816. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9817. if (parentId != null)
  9818. {
  9819. isDefualtVal = false;
  9820. item.ProvinceId = (int)parentId;
  9821. }
  9822. }
  9823. if (isDefualtVal)
  9824. {
  9825. item.ProvinceId = 122; //默认四川
  9826. }
  9827. }
  9828. }
  9829. }
  9830. //处理是否显示
  9831. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9832. {
  9833. foreach (var item in data)
  9834. {
  9835. item.IsView = true;
  9836. }
  9837. }
  9838. return Ok(JsonView(true, "查询成功!", data, total));
  9839. }
  9840. /// <summary>
  9841. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9842. /// </summary>
  9843. /// <returns></returns>
  9844. [HttpPost]
  9845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9846. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9847. {
  9848. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9849. RefAsync<int> total = 0;
  9850. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9851. .Where(x => x.IsDel == 0 && x.STid == 66)
  9852. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9853. .Select(x => new
  9854. {
  9855. id = x.Id,
  9856. name = x.Name,
  9857. remark = x.Remark,
  9858. })
  9859. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9860. return Ok(JsonView(true, "查询成功!", data, total));
  9861. }
  9862. /// <summary>
  9863. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9864. /// </summary>
  9865. /// <returns></returns>
  9866. [HttpPost]
  9867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9868. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9869. {
  9870. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9871. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9872. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9873. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9874. var groupOtherRateData = groupRateData.TeamRates;
  9875. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9876. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9877. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9878. groupOtherRateData = groupOtherRateData
  9879. .Select(x => new TeamRateDescAddCurrencyIdView
  9880. {
  9881. CurrencyId = x.CurrencyId,
  9882. CurrencyName = x.CurrencyName,
  9883. CurrencyCode = x.CurrencyCode,
  9884. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9885. }).ToList();
  9886. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9887. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9888. }
  9889. /// <summary>
  9890. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9891. /// </summary>
  9892. /// <returns></returns>
  9893. [HttpPost]
  9894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9895. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9896. {
  9897. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9898. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9899. var tipsData = new List<int>() { 1, 2, 3 };
  9900. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9901. if (dto.TipsType == 1)
  9902. {
  9903. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9904. }
  9905. else if (dto.TipsType == 2)
  9906. {
  9907. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9908. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9909. }
  9910. else if (dto.TipsType == 3)
  9911. {
  9912. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9913. return Ok(JsonView(true, "查询成功!", airData));
  9914. }
  9915. return Ok(JsonView(false));
  9916. }
  9917. /// <summary>
  9918. /// 团组模块 - 出入境国家费用标准-移动端 List
  9919. /// </summary>
  9920. /// <returns></returns>
  9921. [HttpPost]
  9922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9923. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9924. {
  9925. Stopwatch sw = new Stopwatch();
  9926. sw.Start();
  9927. int provinceId = dto.ProvinceId;
  9928. if (provinceId < 1) provinceId = 122; // 默认四川
  9929. RefAsync<int> total = 0;
  9930. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9931. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9932. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9933. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9934. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9935. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9936. .Select((ntf, sd, u, sd1) => new
  9937. {
  9938. Id = ntf.Id,
  9939. Area = $"{ntf.Country}-{ntf.City}",
  9940. Currency = ntf.Currency,
  9941. CurrencyCode = sd.Name,
  9942. CurrencyName = sd.Remark,
  9943. RoomCost = ntf.RoomCost,
  9944. FoodCost = ntf.FoodCost,
  9945. PublicCost = ntf.PublicCost,
  9946. TrainCost = ntf.TrainCost,
  9947. LastUpdateUserId = ntf.LastUpdateUserId,
  9948. LastUpdateUserName = u.CnName,
  9949. LastUpdateTime = ntf.LastUpdateTime
  9950. })
  9951. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9952. sw.Stop();
  9953. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9954. }
  9955. /// <summary>
  9956. /// 团组模块 - 出入境费用-移动端 - Info
  9957. /// </summary>
  9958. /// <returns></returns>
  9959. [HttpPost]
  9960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9961. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9962. {
  9963. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9964. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9965. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9966. return Ok(data);
  9967. }
  9968. /// <summary>
  9969. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9970. /// </summary>
  9971. /// <returns></returns>
  9972. [HttpPost]
  9973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9974. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9975. {
  9976. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9977. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9978. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9979. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9980. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9981. mobileInfo.DiId = dto.DiId;
  9982. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9983. if (eecInfo == null) return Ok(mobileInfo);
  9984. //验证查看权限
  9985. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9986. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9987. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9988. mobileInfo.IsAssignPerm = isSet;
  9989. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9990. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9991. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9992. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9993. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9994. {
  9995. SubId = dac.Id,
  9996. DiId = dac.DiId,
  9997. Type = dac.Type,
  9998. Days = dac.Days,
  9999. NationalTravelFeeId = dac.NationalTravelFeeId,
  10000. Arae = $"{ntf.Country}-{ntf.City}",
  10001. Cost = dac.Cost,
  10002. Currency = dac.Currency,
  10003. CurrencyName = sd.Name,
  10004. SubTotal = dac.SubTotal,
  10005. })
  10006. .ToList();
  10007. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10008. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10009. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10010. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10011. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10012. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10013. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10014. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10015. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10016. //其他款项
  10017. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10018. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10019. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10020. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10021. .OrderBy((dop, sd1, sd2) => dop.Index)
  10022. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10023. {
  10024. SubId = dop.Id,
  10025. DiId = dop.Diid,
  10026. Index = dop.Index,
  10027. SetDataId = dop.SetDataId,
  10028. SetDataName = sd1.Name,
  10029. Cost = dop.Cost,
  10030. Currency = dop.Currency,
  10031. CurrencyName = sd2.Remark,
  10032. SubTotal = dop.SubTotal,
  10033. Remark = dop.Remark,
  10034. })
  10035. .ToArray();
  10036. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10037. return Ok(mobileInfo);
  10038. }
  10039. /// <summary>
  10040. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10041. /// </summary>
  10042. /// <returns></returns>
  10043. [HttpPost]
  10044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10045. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10046. {
  10047. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10048. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10049. //验证查看权限
  10050. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10051. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10052. var userIds = await _sqlSugar
  10053. .Queryable<Grp_EnterExitCostPermission>()
  10054. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10055. .Select(x => x.UserId)
  10056. .ToArrayAsync();
  10057. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10058. var perUsersView = new List<dynamic>();
  10059. foreach (var item in perUsers)
  10060. {
  10061. bool isView1 = false;
  10062. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10063. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10064. }
  10065. return Ok(JsonView(perUsersView));
  10066. }
  10067. /// <summary>
  10068. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10069. /// </summary>
  10070. /// <returns></returns>
  10071. [HttpPost]
  10072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10073. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10074. {
  10075. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10076. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10077. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10078. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10079. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10080. //验证查看权限
  10081. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10082. //if (!isView) return Ok(JsonView(false, msg));
  10083. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10084. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10085. var subType = dto.SubType;
  10086. if (subType == 1) //1:境内费用
  10087. {
  10088. var oneData = new ChoiceOneMobileSubInfoView()
  10089. {
  10090. Id = eecInfo.Id,
  10091. ChoiceOne = eecInfo.ChoiceOne,
  10092. ChoiceOneTotalCost = eecInfo.InsidePay,
  10093. Visa = eecInfo.Visa,
  10094. VisaRemark = eecInfo.VisaRemark,
  10095. YiMiao = eecInfo.YiMiao,
  10096. HeSuan = eecInfo.HeSuan,
  10097. Service = eecInfo.Service,
  10098. Ticket = eecInfo.Ticket,
  10099. Safe = eecInfo.Safe,
  10100. FirstItemRemark = eecInfo.FirstItemRemark
  10101. };
  10102. return Ok(JsonView(oneData));
  10103. }
  10104. else if (subType == 2) //2:国际旅费
  10105. {
  10106. var twoData = new ChoiceTwoMobileSubInfoView()
  10107. {
  10108. Id = eecInfo.Id,
  10109. ChoiceTwoJJ = eecInfo.SumJJC,
  10110. OutsideJJPay = eecInfo.OutsideJJPay,
  10111. ChoiceTwoGW = eecInfo.SumGWC,
  10112. OutsideGWPay = eecInfo.OutsideGWPay,
  10113. ChoiceTwoTD = eecInfo.SumTDC,
  10114. OutsideTDPay = eecInfo.OutsideTDPay,
  10115. AirJJ = eecInfo.AirJJ,
  10116. AirGW = eecInfo.AirGW,
  10117. AirTD = eecInfo.AirTD,
  10118. CityTranffic = eecInfo.CityTranffic,
  10119. TwoItemRemark = eecInfo.TwoItemRemark
  10120. };
  10121. return Ok(JsonView(twoData));
  10122. }
  10123. else if (subType == 3) //3:住宿费
  10124. {
  10125. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10126. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10127. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10128. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10129. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10130. {
  10131. SubId = dac.Id,
  10132. DiId = dac.DiId,
  10133. Type = dac.Type,
  10134. Days = dac.Days,
  10135. NationalTravelFeeId = dac.NationalTravelFeeId,
  10136. Arae = $"{ntf.Country}-{ntf.City}",
  10137. Cost = dac.Cost,
  10138. Currency = dac.Currency,
  10139. CurrencyName = sd.Name,
  10140. SubTotal = dac.SubTotal,
  10141. })
  10142. .ToArray();
  10143. var data = new ChoiceMobileSubInfo3To6View()
  10144. {
  10145. ParentId = eecInfo.Id,
  10146. Choice = eecInfo.ChoiceThree,
  10147. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10148. Details = dayAndCostDatas
  10149. };
  10150. return Ok(JsonView(data));
  10151. }
  10152. else if (subType == 4) //4:伙食费
  10153. {
  10154. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10155. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10156. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10157. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10158. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10159. {
  10160. SubId = dac.Id,
  10161. DiId = dac.DiId,
  10162. Type = dac.Type,
  10163. Days = dac.Days,
  10164. NationalTravelFeeId = dac.NationalTravelFeeId,
  10165. Arae = $"{ntf.Country}-{ntf.City}",
  10166. Cost = dac.Cost,
  10167. Currency = dac.Currency,
  10168. CurrencyName = sd.Name,
  10169. SubTotal = dac.SubTotal,
  10170. })
  10171. .ToArray();
  10172. var data = new ChoiceMobileSubInfo3To6View()
  10173. {
  10174. ParentId = eecInfo.Id,
  10175. Choice = eecInfo.ChoiceFour,
  10176. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10177. Details = dayAndCostDatas
  10178. };
  10179. return Ok(JsonView(data));
  10180. }
  10181. else if (subType == 5) //5:公杂费
  10182. {
  10183. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10184. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10185. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10186. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10187. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10188. {
  10189. SubId = dac.Id,
  10190. DiId = dac.DiId,
  10191. Type = dac.Type,
  10192. Days = dac.Days,
  10193. NationalTravelFeeId = dac.NationalTravelFeeId,
  10194. Arae = $"{ntf.Country}-{ntf.City}",
  10195. Cost = dac.Cost,
  10196. Currency = dac.Currency,
  10197. CurrencyName = sd.Name,
  10198. SubTotal = dac.SubTotal,
  10199. })
  10200. .ToArray();
  10201. var data = new ChoiceMobileSubInfo3To6View()
  10202. {
  10203. ParentId = eecInfo.Id,
  10204. Choice = eecInfo.ChoiceFive,
  10205. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10206. Details = dayAndCostDatas
  10207. };
  10208. return Ok(JsonView(data));
  10209. }
  10210. else if (subType == 6) //6:培训费
  10211. {
  10212. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10213. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10214. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10215. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  10216. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10217. {
  10218. SubId = dac.Id,
  10219. DiId = dac.DiId,
  10220. Type = dac.Type,
  10221. Days = dac.Days,
  10222. NationalTravelFeeId = dac.NationalTravelFeeId,
  10223. Arae = $"{ntf.Country}-{ntf.City}",
  10224. Cost = dac.Cost,
  10225. Currency = dac.Currency,
  10226. CurrencyName = sd.Name,
  10227. SubTotal = dac.SubTotal,
  10228. })
  10229. .ToArray();
  10230. var data = new ChoiceMobileSubInfo3To6View()
  10231. {
  10232. ParentId = eecInfo.Id,
  10233. Choice = eecInfo.ChoiceSix,
  10234. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10235. Details = dayAndCostDatas
  10236. };
  10237. return Ok(JsonView(data));
  10238. }
  10239. else if (subType == 7) //7:其他
  10240. {
  10241. //其他款项
  10242. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10243. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10244. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10245. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10246. .OrderBy((dop, sd1, sd2) => dop.Index)
  10247. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10248. {
  10249. SubId = dop.Id,
  10250. DiId = dop.Diid,
  10251. Index = dop.Index,
  10252. SetDataId = dop.SetDataId,
  10253. SetDataName = sd1.Name,
  10254. Cost = dop.Cost,
  10255. Currency = dop.Currency,
  10256. CurrencyName = sd2.Name,
  10257. SubTotal = dop.SubTotal,
  10258. Remark = dop.Remark,
  10259. })
  10260. .ToArray();
  10261. var data = new ChoiceSevenMobileSubInfoView()
  10262. {
  10263. ParentId = eecInfo.Id,
  10264. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10265. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10266. Details = otherData
  10267. };
  10268. return Ok(JsonView(data));
  10269. }
  10270. return Ok(JsonView(false));
  10271. }
  10272. #region op
  10273. ///// <summary>
  10274. ///// 移动端更新费用消息通知
  10275. ///// </summary>
  10276. ///// <param name="diid"></param>
  10277. ///// <param name="id"></param>
  10278. ///// <param name="currUserId"></param>
  10279. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  10280. //{
  10281. // try
  10282. // {
  10283. // ////生成默认文件pdf并且通知人员
  10284. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10285. // //{
  10286. // // DiId = diid,
  10287. // // ExportType = 1,
  10288. // // SubTypeId = 1005
  10289. // //}, "pdf");
  10290. // ////发送通知
  10291. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10292. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10293. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10294. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  10295. // ////汇率信息记录
  10296. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10297. // }
  10298. // catch (Exception ex)
  10299. // {
  10300. // //记录日志
  10301. // throw;
  10302. // }
  10303. //}
  10304. /// <summary>
  10305. /// 验证出入境费用数据是否存在
  10306. /// 不存在添加
  10307. /// </summary>
  10308. /// <param name="diId"></param>
  10309. /// <param name="currUserId"></param>
  10310. /// <returns></returns>
  10311. /// <exception cref="CustomException"></exception>
  10312. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  10313. {
  10314. var parentId = 0;
  10315. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10316. if (info != null)
  10317. {
  10318. parentId = info.Id;
  10319. }
  10320. else
  10321. {
  10322. var currencys = await EnterExitCostMobileGetCurrencyInit();
  10323. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10324. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10325. parentId = addId;
  10326. }
  10327. return parentId;
  10328. }
  10329. /// <summary>
  10330. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  10331. /// </summary>
  10332. /// <returns></returns>
  10333. [HttpPost]
  10334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10335. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  10336. {
  10337. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10338. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10339. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10340. //验证编辑权限
  10341. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10342. //if (!isEdit) return Ok(JsonView(false, msg));
  10343. var permissions = new List<Grp_EnterExitCostPermission>();
  10344. foreach (var userId in dto.UserIds)
  10345. {
  10346. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  10347. }
  10348. if (permissions.Any())
  10349. {
  10350. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10351. {
  10352. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10353. }
  10354. _sqlSugar.BeginTran();
  10355. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  10356. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10357. if (result < 1)
  10358. {
  10359. _sqlSugar.RollbackTran();
  10360. return Ok(JsonView(false));
  10361. }
  10362. _sqlSugar.CommitTran();
  10363. return Ok(JsonView(true));
  10364. }
  10365. return Ok(JsonView(false));
  10366. }
  10367. /// <summary>
  10368. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  10369. /// </summary>
  10370. /// <returns></returns>
  10371. [HttpPost]
  10372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10373. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  10374. {
  10375. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10376. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10377. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10378. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10379. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10380. int id = dto.Id;
  10381. if (id <= 0) //add
  10382. {
  10383. //int provinceId = dto.ProvinceId;
  10384. int groupId = dto.DiId;
  10385. //if (provinceId < 1) provinceId = 122;
  10386. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  10387. info.LastUpdateUserId = dto.CurrUserId;
  10388. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10389. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  10390. if (add < 1) return Ok(JsonView(false));
  10391. id = add;
  10392. }
  10393. else //update
  10394. {
  10395. ////验证编辑权限
  10396. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10397. //if (!isEdit) return Ok(JsonView(false, msg));
  10398. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  10399. {
  10400. CurrencyRemark = currencyStr,
  10401. LastUpdateUserId = dto.CurrUserId,
  10402. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10403. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  10404. if (upd < 1) return Ok(JsonView(false));
  10405. }
  10406. #region 汇率变更时更改币种相关费用
  10407. var opDayCosts = new List<Grp_DayAndCost>();
  10408. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  10409. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10410. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  10411. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10412. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10413. .Select((dac, sd) => new
  10414. {
  10415. dac.Id,
  10416. dac.DiId,
  10417. CurrencyCode = sd.Name,
  10418. dac.Cost
  10419. })
  10420. .ToList();
  10421. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10422. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10423. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10424. .Select((dop, sd) => new
  10425. {
  10426. dop.Id,
  10427. dop.Diid,
  10428. CurrencyCode = sd.Name,
  10429. dop.Cost
  10430. })
  10431. .ToList();
  10432. if (dayCosts.Count > 0)
  10433. {
  10434. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10435. foreach (var dc in new_dayCosts)
  10436. {
  10437. var thisCurrency = dc.Key.ToUpper();
  10438. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10439. if (thisRate == 0.00M) continue;
  10440. foreach (var dcSub in dc)
  10441. {
  10442. opDayCosts.Add(new Grp_DayAndCost()
  10443. {
  10444. Id = dcSub.Id,
  10445. DiId = dcSub.DiId,
  10446. Cost = dcSub.Cost,
  10447. SubTotal = dcSub.Cost * thisRate,
  10448. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10449. });
  10450. }
  10451. }
  10452. if (opDayCosts.Count > 0)
  10453. {
  10454. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10455. }
  10456. }
  10457. if (dayOtherCosts.Count > 0)
  10458. {
  10459. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10460. foreach (var dc in new_dayOtherCosts)
  10461. {
  10462. var thisCurrency = dc.Key.ToUpper();
  10463. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10464. if (thisRate == 0.00M) continue;
  10465. foreach (var dcSub in dc)
  10466. {
  10467. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10468. {
  10469. Id = dcSub.Id,
  10470. Diid = dcSub.Diid,
  10471. Cost = dcSub.Cost,
  10472. SubTotal = dcSub.Cost * thisRate,
  10473. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10474. });
  10475. }
  10476. }
  10477. if (opDayOtherCosts.Count > 0)
  10478. {
  10479. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10480. }
  10481. }
  10482. #endregion
  10483. //消息通知
  10484. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10485. //汇率信息记录
  10486. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10487. return Ok(JsonView(new { parentId = id }));
  10488. }
  10489. /// <summary>
  10490. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10491. /// </summary>
  10492. /// <returns></returns>
  10493. [HttpPost]
  10494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10495. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10496. {
  10497. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10498. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10499. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10500. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10501. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10502. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  10503. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10504. int id = dto.Id;
  10505. if (id <= 0) //add
  10506. {
  10507. checkboxInfo.CreateUserId = dto.CurrUserId;
  10508. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10509. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10510. if (add < 1) return Ok(JsonView(false));
  10511. }
  10512. else //update
  10513. {
  10514. ////验证编辑权限
  10515. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10516. //if (!isEdit) return Ok(JsonView(false, msg));
  10517. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10518. .UpdateColumns(x => new
  10519. {
  10520. x.ChoiceOne,
  10521. x.ChoiceTwo,
  10522. x.SumJJC,
  10523. x.SumGWC,
  10524. x.SumTDC,
  10525. x.ChoiceThree,
  10526. x.ChoiceFour,
  10527. x.ChoiceFive,
  10528. x.ChoiceSix,
  10529. x.OtherExpenses_Checked
  10530. })
  10531. .Where(x => x.Id == id)
  10532. .ExecuteCommandAsync();
  10533. if (upd < 1) return Ok(JsonView(false));
  10534. }
  10535. return Ok(JsonView(new { parentId = id }));
  10536. }
  10537. /// <summary>
  10538. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10539. /// </summary>
  10540. /// <returns></returns>
  10541. [HttpPost]
  10542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10543. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10544. {
  10545. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10546. // if (provinceId < 1) provinceId = 122;
  10547. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10548. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10549. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10550. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10551. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10552. var checkboxInfo = new Grp_EnterExitCost()
  10553. {
  10554. Id = id,
  10555. //ProvinceId = provinceId,
  10556. DiId = diId,
  10557. CreateUserId = currUserId,
  10558. LastUpdateUserId = dto.CurrUserId,
  10559. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10560. };
  10561. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10562. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10563. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10564. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10565. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10566. if (id <= 0) //add
  10567. {
  10568. checkboxInfo.CreateUserId = dto.CurrUserId;
  10569. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10570. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10571. if (add < 1) return Ok(JsonView(false));
  10572. }
  10573. else //update
  10574. {
  10575. ////验证编辑权限
  10576. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10577. //if (!isEdit) return Ok(JsonView(false, msg));
  10578. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10579. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  10580. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  10581. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10582. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10583. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10584. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10585. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10586. .Where(x => x.Id == id)
  10587. .ExecuteCommandAsync();
  10588. if (upd < 1) return Ok(JsonView(false));
  10589. }
  10590. return Ok(JsonView(new { parentId = id }));
  10591. }
  10592. /// <summary>
  10593. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10594. /// </summary>
  10595. /// <returns></returns>
  10596. [HttpPost]
  10597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10598. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10599. {
  10600. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10601. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10602. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10603. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10604. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10605. info.FirstItemRemark = dto.FirstItemRemark;
  10606. info.LastUpdateUserId = dto.CurrUserId;
  10607. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10608. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10609. int id = dto.Id;
  10610. if (id <= 0) //add
  10611. {
  10612. info.CreateUserId = dto.CurrUserId;
  10613. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10614. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10615. if (add < 1) return Ok(JsonView(false));
  10616. id = add;
  10617. }
  10618. else //update
  10619. {
  10620. ////验证编辑权限
  10621. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10622. //if (!isEdit) return Ok(JsonView(false, msg));
  10623. var upd = await _sqlSugar.Updateable(info)
  10624. .UpdateColumns(x => new
  10625. {
  10626. x.ChoiceOne,
  10627. x.InsidePay,
  10628. x.VisaRemark,
  10629. x.Visa,
  10630. x.Service,
  10631. x.Safe,
  10632. x.Ticket,
  10633. x.HeSuan,
  10634. x.YiMiao,
  10635. x.FirstItemRemark,
  10636. x.LastUpdateUserId,
  10637. x.LastUpdateTime
  10638. })
  10639. .Where(x => x.Id == id)
  10640. .ExecuteCommandAsync();
  10641. if (upd < 1) return Ok(JsonView(false));
  10642. }
  10643. //消息通知
  10644. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10645. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10646. }
  10647. /// <summary>
  10648. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10649. /// </summary>
  10650. /// <returns></returns>
  10651. [HttpPost]
  10652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10653. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10654. {
  10655. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10656. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10657. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10658. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10659. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10660. info.DiId = dto.DiId;
  10661. //info.ProvinceId = dto.ProvinceId;
  10662. info.OutsideJJPay = dto.OutsideJJPay;
  10663. info.OutsideGWPay = dto.OutsideGWPay;
  10664. info.OutsideTDPay = dto.OutsideTDPay;
  10665. info.AirJJ = dto.AirJJ;
  10666. info.AirGW = dto.AirGW;
  10667. info.AirTD = dto.AirTD;
  10668. info.CityTranffic = dto.CityTranffic;
  10669. info.TwoItemRemark = dto.TwoItemRemark;
  10670. info.SumJJC = dto.ChoiceTwoJJ;
  10671. info.SumGWC = dto.ChoiceTwoGW;
  10672. info.SumTDC = dto.ChoiceTwoTD;
  10673. info.LastUpdateUserId = dto.CurrUserId;
  10674. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  10675. int id = dto.Id;
  10676. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10677. if (id <= 0) //add i
  10678. {
  10679. info.CreateUserId = dto.CurrUserId;
  10680. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10681. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10682. if (addId <= 0) return Ok(JsonView(false));
  10683. id = addId;
  10684. }
  10685. else //update
  10686. {
  10687. ////验证编辑权限
  10688. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10689. //if (!isEdit) return Ok(JsonView(false, msg));
  10690. var upd = await _sqlSugar.Updateable(info)
  10691. .UpdateColumns(x => new
  10692. {
  10693. x.SumJJC,
  10694. x.OutsideJJPay,
  10695. x.SumGWC,
  10696. x.OutsideGWPay,
  10697. x.SumTDC,
  10698. x.OutsideTDPay,
  10699. x.AirJJ,
  10700. x.AirGW,
  10701. x.AirTD,
  10702. x.CityTranffic,
  10703. x.TwoItemRemark,
  10704. x.LastUpdateTime,
  10705. x.LastUpdateUserId
  10706. })
  10707. .Where(x => x.Id == id)
  10708. .ExecuteCommandAsync();
  10709. if (upd < 1) return Ok(JsonView(false));
  10710. }
  10711. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10712. gwcItemTotal = info.AirGW + info.CityTranffic;
  10713. tdcItemTotal = info.AirTD + info.CityTranffic;
  10714. //消息通知
  10715. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10716. return Ok(JsonView(new
  10717. {
  10718. parentId = id,
  10719. choiceTwoJJ = dto.ChoiceTwoJJ,
  10720. jjcItemTotal = jjcItemTotal,
  10721. choiceTwoGW = dto.ChoiceTwoGW,
  10722. gwcItemTotal = gwcItemTotal,
  10723. choiceTwoTD = dto.ChoiceTwoTD,
  10724. tdcItemTotal = tdcItemTotal
  10725. }));
  10726. }
  10727. /// <summary>
  10728. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10729. /// </summary>
  10730. /// <returns></returns>
  10731. [HttpPost]
  10732. [ApiExplorerSettings(IgnoreApi = true)]
  10733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10734. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10735. {
  10736. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10737. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10738. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10739. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10740. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10741. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10742. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10743. var infos = infos1.Select(x => new Grp_DayAndCost
  10744. {
  10745. Id = x.Id,
  10746. DiId = dto.DiId,
  10747. Type = dto.FeeType,
  10748. Days = x.Days,
  10749. NationalTravelFeeId = x.NationalTravelFeeId,
  10750. Cost = x.Cost,
  10751. Currency = x.Currency,
  10752. SubTotal = x.SubTotal,
  10753. CreateUserId = dto.CurrUserId
  10754. })
  10755. .ToList();
  10756. var adds = infos.Where(x => x.Id <= 0).ToList();
  10757. var upds = infos.Where(x => x.Id > 0).ToList();
  10758. if (adds.Count > 0)
  10759. {
  10760. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10761. if (add < 1) return Ok(JsonView(false));
  10762. }
  10763. if (upds.Count > 0)
  10764. {
  10765. var upd = await _sqlSugar.Updateable(adds)
  10766. .UpdateColumns(x => new
  10767. {
  10768. x.Days,
  10769. x.NationalTravelFeeId,
  10770. x.Cost,
  10771. x.Currency,
  10772. x.SubTotal
  10773. })
  10774. .WhereColumns(x => new { x.Id })
  10775. .ExecuteCommandAsync();
  10776. if (upd < 1) return Ok(JsonView(false));
  10777. }
  10778. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10779. //消息通知
  10780. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10781. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10782. return Ok(JsonView(new { itemTotal = itemTotal }));
  10783. }
  10784. /// <summary>
  10785. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10786. /// </summary>
  10787. /// <returns></returns>
  10788. [HttpPost]
  10789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10790. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10791. {
  10792. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10793. int subId = dto.SubId, feeType = dto.FeeType;
  10794. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10795. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10796. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10797. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10798. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10799. subInfo.Id = subId;
  10800. subInfo.DiId = dto.DiId;
  10801. if (feeType == 3) subInfo.Type = 1;
  10802. else if (feeType == 4) subInfo.Type = 2;
  10803. else if (feeType == 5) subInfo.Type = 3;
  10804. else if (feeType == 6) subInfo.Type = 4;
  10805. subInfo.CreateUserId = dto.CurrUserId;
  10806. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10807. if (parentId < 1) return Ok(JsonView(false));
  10808. //子表op
  10809. if (subId < 1)
  10810. {
  10811. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10812. if (subAdd < 1) return Ok(JsonView(false));
  10813. }
  10814. else
  10815. {
  10816. ////验证编辑权限
  10817. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10818. //if (!isEdit) return Ok(JsonView(false, msg));
  10819. var subUpd = await _sqlSugar.Updateable(subInfo)
  10820. .UpdateColumns(x => new
  10821. {
  10822. x.Days,
  10823. x.NationalTravelFeeId,
  10824. x.Cost,
  10825. x.Currency,
  10826. x.SubTotal
  10827. })
  10828. .WhereColumns(x => new { x.Id })
  10829. .ExecuteCommandAsync();
  10830. if (subUpd < 1) return Ok(JsonView(false));
  10831. }
  10832. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10833. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10834. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10835. }
  10836. /// <summary>
  10837. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10838. /// </summary>
  10839. /// <returns></returns>
  10840. [HttpPost]
  10841. [ApiExplorerSettings(IgnoreApi = true)]
  10842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10843. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10844. {
  10845. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10846. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10847. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10848. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10849. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10850. {
  10851. Id = x.Id,
  10852. Diid = dto.DiId,
  10853. SetDataId = x.SetDataId,
  10854. Index = x.Index,
  10855. Cost = x.Cost,
  10856. Currency = x.Currency,
  10857. SubTotal = x.SubTotal,
  10858. CreateUserId = dto.CurrUserId,
  10859. Remark = x.Remark
  10860. }).ToList();
  10861. var adds = infos.Where(x => x.Id <= 0).ToList();
  10862. var upds = infos.Where(x => x.Id > 0).ToList();
  10863. if (adds.Count > 0)
  10864. {
  10865. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10866. if (add < 1) return Ok(JsonView(false));
  10867. }
  10868. if (upds.Count > 0)
  10869. {
  10870. var upd = await _sqlSugar.Updateable(adds)
  10871. .UpdateColumns(x => new
  10872. {
  10873. x.Index,
  10874. x.SetDataId,
  10875. x.Cost,
  10876. x.Currency,
  10877. x.SubTotal,
  10878. x.Remark
  10879. })
  10880. .WhereColumns(x => new { x.Id })
  10881. .ExecuteCommandAsync();
  10882. if (upd < 1) return Ok(JsonView(false));
  10883. }
  10884. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10885. //消息通知
  10886. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10887. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10888. return Ok(JsonView(new { itemTotal = itemTotal }));
  10889. }
  10890. /// <summary>
  10891. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10892. /// </summary>
  10893. /// <returns></returns>
  10894. [HttpPost]
  10895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10896. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10897. {
  10898. int subId = dto.SubId;
  10899. int diId = dto.Diid;
  10900. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10901. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10902. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10903. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10904. subInfo.Id = subId;
  10905. subInfo.Diid = dto.Diid;
  10906. subInfo.CreateUserId = dto.CurrUserId;
  10907. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10908. if (parentId < 1) return Ok(JsonView(false));
  10909. #region 子表op
  10910. if (subId < 1)//add
  10911. {
  10912. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10913. if (subAdd < 1) return Ok(JsonView(false));
  10914. }
  10915. else //upd
  10916. {
  10917. ////验证编辑权限
  10918. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10919. //if (!isEdit) return Ok(JsonView(false, msg));
  10920. var subUpd = await _sqlSugar.Updateable(subInfo)
  10921. .UpdateColumns(x => new
  10922. {
  10923. x.Index,
  10924. x.SetDataId,
  10925. x.Cost,
  10926. x.Currency,
  10927. x.SubTotal,
  10928. x.Remark
  10929. })
  10930. .WhereColumns(x => new { x.Id })
  10931. .ExecuteCommandAsync();
  10932. if (subUpd < 1) return Ok(JsonView(false));
  10933. }
  10934. #endregion
  10935. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10936. //消息通知
  10937. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10938. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10939. }
  10940. /// <summary>
  10941. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10942. /// </summary>
  10943. /// <returns></returns>
  10944. [HttpPost]
  10945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10946. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10947. {
  10948. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10949. if (data.Code != 0)
  10950. {
  10951. return Ok(JsonView(false, data.Msg));
  10952. }
  10953. return Ok(JsonView(true, "操作成功!", data.Data));
  10954. }
  10955. /// <summary>
  10956. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10957. /// </summary>
  10958. /// <param name="dto"></param>
  10959. /// <returns></returns>
  10960. [HttpPost]
  10961. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10962. {
  10963. var data = new Grp_DayOtherPrice()
  10964. {
  10965. Id = dto.Id,
  10966. IsDel = 1,
  10967. DeleteUserId = dto.DeleteUserId,
  10968. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10969. };
  10970. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10971. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10972. return Ok(JsonView(false, "删除失败!"));
  10973. }
  10974. #endregion
  10975. #endregion
  10976. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10977. /// <summary>
  10978. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10979. /// </summary>
  10980. /// <returns></returns>
  10981. [HttpGet]
  10982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10983. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10984. {
  10985. var provData = await _groupRepository.ProvinceBasicSource();
  10986. return Ok(JsonView(true, "查询成功!", provData));
  10987. }
  10988. /// <summary>
  10989. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10990. /// </summary>
  10991. /// <returns></returns>
  10992. [HttpPost]
  10993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10994. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10995. {
  10996. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10997. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10998. RefAsync<int> total = 0;
  10999. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11000. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11001. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11002. .Select(x => new
  11003. {
  11004. Id = x.Id,
  11005. DraftName = x.DraftName,
  11006. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11007. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11008. .Any()
  11009. })
  11010. .OrderByDescending(x => x.Id)
  11011. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11012. return Ok(JsonView(true, "查询成功!", data, total));
  11013. }
  11014. /// <summary>
  11015. /// 出入境费用-草稿 移动端
  11016. /// 获取币种基础数据(含逻辑处理)
  11017. /// </summary>
  11018. /// <returns></returns>
  11019. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11020. {
  11021. return await GeneralMethod.EnterExitCostInitRate();
  11022. }
  11023. /// <summary>
  11024. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11025. /// </summary>
  11026. /// <returns></returns>
  11027. [HttpPost]
  11028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11029. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11030. {
  11031. //验证城市归属并给默认值
  11032. int provinceId = dto.ProvinceId;
  11033. if (provinceId < 1) provinceId = 122;
  11034. var dataSource = await _sqlSugar
  11035. .Queryable<Sys_SetData>()
  11036. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11037. .ToListAsync();
  11038. //三公费用-Word明细类型
  11039. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11040. .Select(x => new SetDataInfoView
  11041. {
  11042. Id = x.Id,
  11043. Name = x.Name,
  11044. Remark = x.Remark
  11045. })
  11046. .ToList();
  11047. //三公费用-Excel明细类型
  11048. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11049. .Select(x => new SetDataInfoView
  11050. {
  11051. Id = x.Id,
  11052. Name = x.Name,
  11053. Remark = x.Remark
  11054. })
  11055. .ToList();
  11056. //默认币种显示
  11057. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11058. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11059. return Ok(JsonView(true, "查询成功!", new
  11060. {
  11061. WordTypeData = wordTypeData,
  11062. ExcelTypeData = excelTypeData,
  11063. CurrencyInit = _currencyInfos,
  11064. viewPermissionData = viewPermissionData
  11065. }));
  11066. }
  11067. /// <summary>
  11068. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11069. /// </summary>
  11070. /// <returns></returns>
  11071. [HttpPost]
  11072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11073. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11074. {
  11075. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11076. RefAsync<int> total = 0;
  11077. int diId = 0;
  11078. var status = int.TryParse(dto.GroupName, out diId);
  11079. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11080. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11081. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11082. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11083. .OrderByDescending(x => x.VisitStartDate)
  11084. .Select(x => new
  11085. {
  11086. Id = x.Id,
  11087. GroupName = x.TeamName
  11088. })
  11089. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11090. return Ok(JsonView(true, "查询成功!", data, total));
  11091. }
  11092. /// <summary>
  11093. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11094. /// </summary>
  11095. /// <returns></returns>
  11096. [HttpPost]
  11097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11098. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11099. {
  11100. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11101. RefAsync<int> total = 0;
  11102. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11103. .Where(x => x.IsDel == 0 && x.STid == 66)
  11104. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11105. .Select(x => new
  11106. {
  11107. id = x.Id,
  11108. name = x.Name,
  11109. remark = x.Remark,
  11110. })
  11111. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11112. return Ok(JsonView(true, "查询成功!", data, total));
  11113. }
  11114. /// <summary>
  11115. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11116. /// </summary>
  11117. /// <returns></returns>
  11118. [HttpPost]
  11119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11120. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11121. {
  11122. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11123. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11124. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11125. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11126. var groupOtherRateData = groupRateData.TeamRates;
  11127. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11128. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11129. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11130. groupOtherRateData = groupOtherRateData
  11131. .Select(x => new TeamRateDescAddCurrencyIdView
  11132. {
  11133. CurrencyId = x.CurrencyId,
  11134. CurrencyName = x.CurrencyName,
  11135. CurrencyCode = x.CurrencyCode,
  11136. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11137. }).ToList();
  11138. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11139. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11140. }
  11141. /// <summary>
  11142. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11143. /// </summary>
  11144. /// <returns></returns>
  11145. [HttpPost]
  11146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11147. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11148. {
  11149. int portType = dto.PortType;
  11150. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11151. var tipsData = new List<int>() { 1, 2, 3 };
  11152. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11153. if (dto.TipsType == 1)
  11154. {
  11155. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11156. }
  11157. else if (dto.TipsType == 2)
  11158. {
  11159. if (portType == 2)
  11160. {
  11161. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11162. }
  11163. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11164. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11165. .Select(x => x.NationalTravelFeeId)
  11166. .Distinct()
  11167. .ToListAsync();
  11168. if (portType == 2)
  11169. {
  11170. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11171. }
  11172. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11173. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11174. .Select(x => x.Country)
  11175. .Distinct()
  11176. .ToArrayAsync();
  11177. if (portType == 2)
  11178. {
  11179. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11180. }
  11181. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11182. return Ok(JsonView(true, "查询成功!", new
  11183. {
  11184. totalAmt = totalAmt,
  11185. remark = remark
  11186. }));
  11187. }
  11188. else if (dto.TipsType == 3)
  11189. {
  11190. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11191. }
  11192. return Ok(JsonView(false));
  11193. }
  11194. /// <summary>
  11195. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11196. /// </summary>
  11197. /// <returns></returns>
  11198. [HttpPost]
  11199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11200. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11201. {
  11202. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11203. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11204. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11205. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11206. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11207. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11208. var info = new Grp_EnterExitCostDraft()
  11209. {
  11210. ProvinceId = dto.ProvinceId,
  11211. DraftName = dto.DraftName,
  11212. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  11213. CreateUserId = dto.CurrUserId
  11214. };
  11215. _sqlSugar.BeginTran();
  11216. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11217. if (draftId < 1)
  11218. {
  11219. _sqlSugar.RollbackTran();
  11220. return Ok(JsonView(false, "草稿创建失败!"));
  11221. }
  11222. //添加默认权限
  11223. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  11224. _sqlSugar.CommitTran();
  11225. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  11226. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11227. mobileInfo.Id = draftId;
  11228. mobileInfo.DraftName = dto.DraftName;
  11229. mobileInfo.Currencys = rateInfos;
  11230. mobileInfo.IsAssignPerm = assignPerm;
  11231. return Ok(JsonView(mobileInfo));
  11232. }
  11233. /// <summary>
  11234. /// 出入境费用-草稿-移动端 查看编辑提示消息
  11235. /// </summary>
  11236. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  11237. /// <summary>
  11238. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  11239. /// </summary>
  11240. /// <returns></returns>
  11241. [HttpPost]
  11242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11243. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  11244. {
  11245. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11246. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11247. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11248. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  11249. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  11250. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  11251. //验证查看编辑权限
  11252. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11253. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11254. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  11255. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  11256. mobileInfo.IsAssignPerm = assignPerm;
  11257. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11258. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11259. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11260. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11261. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11262. {
  11263. ParentId = dac.ParentId,
  11264. SubId = dac.Id,
  11265. Type = dac.Type,
  11266. Days = dac.Days,
  11267. NationalTravelFeeId = dac.NationalTravelFeeId,
  11268. Arae = $"{ntf.Country}-{ntf.City}",
  11269. Cost = dac.Cost,
  11270. Currency = dac.Currency,
  11271. CurrencyName = sd.Name,
  11272. SubTotal = dac.SubTotal,
  11273. })
  11274. .ToList();
  11275. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  11276. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  11277. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  11278. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  11279. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  11280. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  11281. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  11282. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  11283. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  11284. //其他款项
  11285. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11286. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11287. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11288. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11289. .OrderBy((dop, sd1, sd2) => dop.Index)
  11290. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11291. {
  11292. ParentId = dop.ParentId,
  11293. SubId = dop.Id,
  11294. Index = dop.Index,
  11295. SetDataId = dop.SetDataId,
  11296. SetDataName = sd1.Name,
  11297. Cost = dop.Cost,
  11298. Currency = dop.Currency,
  11299. CurrencyName = sd2.Remark,
  11300. SubTotal = dop.SubTotal,
  11301. Remark = dop.Remark,
  11302. })
  11303. .ToArray();
  11304. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  11305. return Ok(mobileInfo);
  11306. }
  11307. /// <summary>
  11308. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  11309. /// </summary>
  11310. /// <returns></returns>
  11311. [HttpPost]
  11312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11313. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  11314. {
  11315. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11316. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11317. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11318. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  11319. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  11320. //验证查看编辑权限
  11321. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11322. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11323. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11324. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  11325. var subType = dto.SubType;
  11326. if (subType == 1) //1:境内费用
  11327. {
  11328. var oneData = new ChoiceOneMobileSubInfoView()
  11329. {
  11330. Id = eecInfo.Id,
  11331. ChoiceOne = eecInfo.ChoiceOne,
  11332. ChoiceOneTotalCost = eecInfo.InsidePay,
  11333. Visa = eecInfo.Visa,
  11334. VisaRemark = eecInfo.VisaRemark,
  11335. YiMiao = eecInfo.YiMiao,
  11336. HeSuan = eecInfo.HeSuan,
  11337. Service = eecInfo.Service,
  11338. Ticket = eecInfo.Ticket,
  11339. Safe = eecInfo.Safe,
  11340. FirstItemRemark = eecInfo.FirstItemRemark
  11341. };
  11342. return Ok(JsonView(oneData));
  11343. }
  11344. else if (subType == 2) //2:国际旅费
  11345. {
  11346. var twoData = new ChoiceTwoMobileSubInfoView()
  11347. {
  11348. Id = eecInfo.Id,
  11349. ChoiceTwoJJ = eecInfo.SumJJC,
  11350. OutsideJJPay = eecInfo.OutsideJJPay,
  11351. ChoiceTwoGW = eecInfo.SumGWC,
  11352. OutsideGWPay = eecInfo.OutsideGWPay,
  11353. ChoiceTwoTD = eecInfo.SumTDC,
  11354. OutsideTDPay = eecInfo.OutsideTDPay,
  11355. AirJJ = eecInfo.AirJJ,
  11356. AirGW = eecInfo.AirGW,
  11357. AirTD = eecInfo.AirTD,
  11358. CityTranffic = eecInfo.CityTranffic,
  11359. TwoItemRemark = eecInfo.TwoItemRemark
  11360. };
  11361. return Ok(JsonView(twoData));
  11362. }
  11363. else if (subType == 3) //3:住宿费
  11364. {
  11365. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11366. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11367. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11368. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  11369. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11370. {
  11371. ParentId = dac.ParentId,
  11372. SubId = dac.Id,
  11373. Type = dac.Type,
  11374. Days = dac.Days,
  11375. NationalTravelFeeId = dac.NationalTravelFeeId,
  11376. Arae = $"{ntf.Country}-{ntf.City}",
  11377. Cost = dac.Cost,
  11378. Currency = dac.Currency,
  11379. CurrencyName = sd.Name,
  11380. SubTotal = dac.SubTotal,
  11381. })
  11382. .ToArray();
  11383. var data = new ChoiceDraftMobileSubInfo3To6View()
  11384. {
  11385. ParentId = eecInfo.Id,
  11386. Choice = eecInfo.ChoiceThree,
  11387. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11388. Details = dayAndCostDatas
  11389. };
  11390. return Ok(JsonView(data));
  11391. }
  11392. else if (subType == 4) //4:伙食费
  11393. {
  11394. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11395. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11396. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11397. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  11398. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11399. {
  11400. ParentId = dac.ParentId,
  11401. SubId = dac.Id,
  11402. Type = dac.Type,
  11403. Days = dac.Days,
  11404. NationalTravelFeeId = dac.NationalTravelFeeId,
  11405. Arae = $"{ntf.Country}-{ntf.City}",
  11406. Cost = dac.Cost,
  11407. Currency = dac.Currency,
  11408. CurrencyName = sd.Name,
  11409. SubTotal = dac.SubTotal,
  11410. })
  11411. .ToArray();
  11412. var data = new ChoiceDraftMobileSubInfo3To6View()
  11413. {
  11414. ParentId = eecInfo.Id,
  11415. Choice = eecInfo.ChoiceFour,
  11416. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11417. Details = dayAndCostDatas
  11418. };
  11419. return Ok(JsonView(data));
  11420. }
  11421. else if (subType == 5) //5:公杂费
  11422. {
  11423. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11424. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11425. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11426. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  11427. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11428. {
  11429. ParentId = dac.ParentId,
  11430. SubId = dac.Id,
  11431. Type = dac.Type,
  11432. Days = dac.Days,
  11433. NationalTravelFeeId = dac.NationalTravelFeeId,
  11434. Arae = $"{ntf.Country}-{ntf.City}",
  11435. Cost = dac.Cost,
  11436. Currency = dac.Currency,
  11437. CurrencyName = sd.Name,
  11438. SubTotal = dac.SubTotal,
  11439. })
  11440. .ToArray();
  11441. var data = new ChoiceDraftMobileSubInfo3To6View()
  11442. {
  11443. ParentId = eecInfo.Id,
  11444. Choice = eecInfo.ChoiceFive,
  11445. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11446. Details = dayAndCostDatas
  11447. };
  11448. return Ok(JsonView(data));
  11449. }
  11450. else if (subType == 6) //6:培训费
  11451. {
  11452. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11453. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11454. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11455. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  11456. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  11457. {
  11458. ParentId = dac.ParentId,
  11459. SubId = dac.Id,
  11460. Type = dac.Type,
  11461. Days = dac.Days,
  11462. NationalTravelFeeId = dac.NationalTravelFeeId,
  11463. Arae = $"{ntf.Country}-{ntf.City}",
  11464. Cost = dac.Cost,
  11465. Currency = dac.Currency,
  11466. CurrencyName = sd.Name,
  11467. SubTotal = dac.SubTotal,
  11468. })
  11469. .ToArray();
  11470. var data = new ChoiceDraftMobileSubInfo3To6View()
  11471. {
  11472. ParentId = eecInfo.Id,
  11473. Choice = eecInfo.ChoiceSix,
  11474. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11475. Details = dayAndCostDatas
  11476. };
  11477. return Ok(JsonView(data));
  11478. }
  11479. else if (subType == 7) //7:其他
  11480. {
  11481. //其他款项
  11482. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11483. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11484. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11485. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11486. .OrderBy((dop, sd1, sd2) => dop.Index)
  11487. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11488. {
  11489. ParentId = dop.ParentId,
  11490. SubId = dop.Id,
  11491. Index = dop.Index,
  11492. SetDataId = dop.SetDataId,
  11493. SetDataName = sd1.Name,
  11494. Cost = dop.Cost,
  11495. Currency = dop.Currency,
  11496. CurrencyName = sd2.Name,
  11497. SubTotal = dop.SubTotal,
  11498. Remark = dop.Remark,
  11499. })
  11500. .ToArray();
  11501. var data = new ChoiceSevenDraftMobileSubInfoView()
  11502. {
  11503. ParentId = eecInfo.Id,
  11504. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11505. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11506. Details = otherData
  11507. };
  11508. return Ok(JsonView(data));
  11509. }
  11510. return Ok(JsonView(false));
  11511. }
  11512. #region op
  11513. ///// <summary>
  11514. ///// 移动端更新费用消息通知
  11515. ///// </summary>
  11516. ///// <param name="draftId"></param>
  11517. ///// <param name="id"></param>
  11518. ///// <param name="currUserId"></param>
  11519. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11520. //{
  11521. // try
  11522. // {
  11523. // ////生成默认文件pdf并且通知人员
  11524. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11525. // //{
  11526. // // DiId = draftId,
  11527. // // ExportType = 1,
  11528. // // SubTypeId = 1005
  11529. // //}, "pdf");
  11530. // ////发送通知
  11531. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11532. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11533. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11534. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11535. // ////汇率信息记录
  11536. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11537. // }
  11538. // catch (Exception ex)
  11539. // {
  11540. // //记录日志
  11541. // throw;
  11542. // }
  11543. //}
  11544. /// <summary>
  11545. /// 验证出入境费用数据是否存在
  11546. /// 不存在添加
  11547. /// </summary>
  11548. /// <param name="draftId"></param>
  11549. /// <param name="currUserId"></param>
  11550. /// <returns></returns>
  11551. /// <exception cref="CustomException"></exception>
  11552. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11553. {
  11554. var parentId = 0;
  11555. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11556. if (info != null) parentId = info.Id;
  11557. else
  11558. {
  11559. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11560. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11561. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11562. parentId = addId;
  11563. }
  11564. return parentId;
  11565. }
  11566. /// <summary>
  11567. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11568. /// </summary>
  11569. /// <returns></returns>
  11570. [HttpPost]
  11571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11572. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11573. {
  11574. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11575. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11576. //验证查看权限
  11577. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11578. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11579. var userIds = await _sqlSugar
  11580. .Queryable<Grp_EnterExitCostDraftPermission>()
  11581. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11582. .Select(x => x.UserId)
  11583. .ToArrayAsync();
  11584. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11585. var perUsersView = new List<dynamic>();
  11586. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11587. var viewPermissionData = new List<PermissionViewUserview>();
  11588. if (feeBasePerm.Any())
  11589. {
  11590. foreach (var item in feeBasePerm)
  11591. {
  11592. if (item.Users.Any())
  11593. {
  11594. viewPermissionData.AddRange(item.Users);
  11595. }
  11596. }
  11597. }
  11598. foreach (var item in perUsers)
  11599. {
  11600. bool isView1 = false;
  11601. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11602. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11603. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11604. }
  11605. return Ok(JsonView(perUsersView));
  11606. }
  11607. /// <summary>
  11608. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11609. /// </summary>
  11610. /// <returns></returns>
  11611. [HttpPost]
  11612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11613. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11614. {
  11615. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11616. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11617. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11618. //验证查看编辑权限
  11619. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11620. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11621. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11622. foreach (var userId in dto.UserIds)
  11623. {
  11624. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11625. }
  11626. if (permissions.Any())
  11627. {
  11628. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11629. {
  11630. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11631. }
  11632. _sqlSugar.BeginTran();
  11633. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11634. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11635. if (result < 1)
  11636. {
  11637. _sqlSugar.RollbackTran();
  11638. return Ok(JsonView(false));
  11639. }
  11640. _sqlSugar.CommitTran();
  11641. return Ok(JsonView(true));
  11642. }
  11643. return Ok(JsonView(false));
  11644. }
  11645. /// <summary>
  11646. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11647. /// </summary>
  11648. /// <returns></returns>
  11649. [HttpPost]
  11650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11651. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11652. {
  11653. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11654. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11655. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11656. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11657. int id = dto.DraftId;
  11658. if (id <= 0) //add
  11659. {
  11660. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11661. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11662. if (add < 1) return Ok(JsonView(false));
  11663. id = add;
  11664. }
  11665. else //update
  11666. {
  11667. //验证查看编辑权限
  11668. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11669. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11670. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11671. if (upd < 1) return Ok(JsonView(false));
  11672. }
  11673. return Ok(JsonView(new { parentId = id }));
  11674. }
  11675. /// <summary>
  11676. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11677. /// </summary>
  11678. /// <returns></returns>
  11679. [HttpPost]
  11680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11681. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11682. {
  11683. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11684. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11685. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11686. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11687. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11688. int id = dto.DraftId;
  11689. if (id <= 0) //add
  11690. {
  11691. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11692. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11693. if (add < 1) return Ok(JsonView(false));
  11694. id = add;
  11695. }
  11696. else //update
  11697. {
  11698. //验证查看编辑权限
  11699. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11700. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11701. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11702. if (upd < 1) return Ok(JsonView(false));
  11703. }
  11704. #region 汇率变更时更改币种相关费用
  11705. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11706. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11707. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11708. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11709. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11710. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11711. .Select((dac, sd) => new
  11712. {
  11713. dac.Id,
  11714. dac.ParentId,
  11715. CurrencyCode = sd.Name,
  11716. dac.Cost
  11717. })
  11718. .ToList();
  11719. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11720. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11721. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11722. .Select((dop, sd) => new
  11723. {
  11724. dop.Id,
  11725. dop.ParentId,
  11726. CurrencyCode = sd.Name,
  11727. dop.Cost
  11728. })
  11729. .ToList();
  11730. if (dayCosts.Count > 0)
  11731. {
  11732. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11733. foreach (var dc in new_dayCosts)
  11734. {
  11735. var thisCurrency = dc.Key.ToUpper();
  11736. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11737. if (thisRate == 0.00M) continue;
  11738. foreach (var dcSub in dc)
  11739. {
  11740. opDayCosts.Add(new Grp_DayAndCostDraft()
  11741. {
  11742. Id = dcSub.Id,
  11743. ParentId = dcSub.ParentId,
  11744. Cost = dcSub.Cost,
  11745. SubTotal = dcSub.Cost * thisRate,
  11746. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11747. });
  11748. }
  11749. }
  11750. if (opDayCosts.Count > 0)
  11751. {
  11752. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11753. }
  11754. }
  11755. if (dayOtherCosts.Count > 0)
  11756. {
  11757. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11758. foreach (var dc in new_dayOtherCosts)
  11759. {
  11760. var thisCurrency = dc.Key.ToUpper();
  11761. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11762. if (thisRate == 0.00M) continue;
  11763. foreach (var dcSub in dc)
  11764. {
  11765. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11766. {
  11767. Id = dcSub.Id,
  11768. ParentId = dcSub.ParentId,
  11769. Cost = dcSub.Cost,
  11770. SubTotal = dcSub.Cost * thisRate,
  11771. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11772. });
  11773. }
  11774. }
  11775. if (opDayOtherCosts.Count > 0)
  11776. {
  11777. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11778. }
  11779. }
  11780. #endregion
  11781. ////消息通知
  11782. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11783. ////汇率信息记录
  11784. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11785. return Ok(JsonView(new { parentId = id }));
  11786. }
  11787. /// <summary>
  11788. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11789. /// </summary>
  11790. /// <returns></returns>
  11791. [HttpPost]
  11792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11793. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11794. {
  11795. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11796. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11797. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11798. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11799. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11800. int id = dto.DraftId;
  11801. if (id <= 0) //add
  11802. {
  11803. checkboxInfo.ProvinceId = dto.ProvinceId;
  11804. checkboxInfo.CreateUserId = dto.CurrUserId;
  11805. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11806. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11807. if (add < 1) return Ok(JsonView(false));
  11808. }
  11809. else //update
  11810. {
  11811. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11812. .UpdateColumns(x => new
  11813. {
  11814. x.ChoiceOne,
  11815. x.ChoiceTwo,
  11816. x.SumJJC,
  11817. x.SumGWC,
  11818. x.SumTDC,
  11819. x.ChoiceThree,
  11820. x.ChoiceFour,
  11821. x.ChoiceFive,
  11822. x.ChoiceSix,
  11823. x.OtherExpenses_Checked
  11824. })
  11825. .Where(x => x.Id == id)
  11826. .ExecuteCommandAsync();
  11827. if (upd < 1) return Ok(JsonView(false));
  11828. }
  11829. return Ok(JsonView(new { parentId = id }));
  11830. }
  11831. /// <summary>
  11832. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11833. /// </summary>
  11834. /// <returns></returns>
  11835. [HttpPost]
  11836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11837. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11838. {
  11839. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11840. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11841. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11842. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11843. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11844. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11845. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11846. var checkboxInfo = new Grp_EnterExitCostDraft()
  11847. {
  11848. Id = draftId,
  11849. ProvinceId = dto.ProvinceId,
  11850. CreateUserId = currUserId
  11851. };
  11852. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11853. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11854. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11855. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11856. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11857. if (draftId <= 0) //add
  11858. {
  11859. checkboxInfo.CreateUserId = dto.CurrUserId;
  11860. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11861. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11862. if (add < 1) return Ok(JsonView(false));
  11863. }
  11864. else //update
  11865. {
  11866. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11867. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11868. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11869. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11870. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11871. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11872. .Where(x => x.Id == draftId)
  11873. .ExecuteCommandAsync();
  11874. if (upd < 1) return Ok(JsonView(false));
  11875. }
  11876. return Ok(JsonView(new { parentId = draftId }));
  11877. }
  11878. /// <summary>
  11879. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11880. /// </summary>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11884. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11885. {
  11886. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11887. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11888. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11889. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11890. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11891. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11892. info.ProvinceId = dto.ProvinceId;
  11893. info.FirstItemRemark = dto.FirstItemRemark;
  11894. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11895. if (id <= 0) //add
  11896. {
  11897. info.CreateUserId = dto.CurrUserId;
  11898. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11899. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11900. if (add < 1) return Ok(JsonView(false));
  11901. id = add;
  11902. }
  11903. else //update
  11904. {
  11905. var upd = await _sqlSugar.Updateable(info)
  11906. .UpdateColumns(x => new
  11907. {
  11908. x.ChoiceOne,
  11909. x.InsidePay,
  11910. x.VisaRemark,
  11911. x.Visa,
  11912. x.Service,
  11913. x.Safe,
  11914. x.Ticket,
  11915. x.HeSuan,
  11916. x.YiMiao,
  11917. x.FirstItemRemark
  11918. })
  11919. .Where(x => x.Id == id)
  11920. .ExecuteCommandAsync();
  11921. if (upd < 1) return Ok(JsonView(false));
  11922. }
  11923. ////消息通知
  11924. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11925. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11926. }
  11927. /// <summary>
  11928. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11929. /// </summary>
  11930. /// <returns></returns>
  11931. [HttpPost]
  11932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11933. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11934. {
  11935. int id = dto.DraftId;
  11936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11937. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11938. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11939. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11940. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11941. info.ProvinceId = dto.ProvinceId;
  11942. info.OutsideJJPay = dto.OutsideJJPay;
  11943. info.OutsideGWPay = dto.OutsideGWPay;
  11944. info.OutsideTDPay = dto.OutsideTDPay;
  11945. info.AirJJ = dto.AirJJ;
  11946. info.AirGW = dto.AirGW;
  11947. info.AirTD = dto.AirTD;
  11948. info.CityTranffic = dto.CityTranffic;
  11949. info.TwoItemRemark = dto.TwoItemRemark;
  11950. info.SumJJC = dto.ChoiceTwoJJ;
  11951. info.SumGWC = dto.ChoiceTwoGW;
  11952. info.SumTDC = dto.ChoiceTwoTD;
  11953. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11954. if (id <= 0) //add
  11955. {
  11956. info.CreateUserId = dto.CurrUserId;
  11957. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11958. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11959. if (addId <= 0) return Ok(JsonView(false));
  11960. id = addId;
  11961. }
  11962. else //update
  11963. {
  11964. var upd = await _sqlSugar.Updateable(info)
  11965. .UpdateColumns(x => new
  11966. {
  11967. x.SumJJC,
  11968. x.OutsideJJPay,
  11969. x.SumGWC,
  11970. x.OutsideGWPay,
  11971. x.SumTDC,
  11972. x.OutsideTDPay,
  11973. x.AirJJ,
  11974. x.AirGW,
  11975. x.AirTD,
  11976. x.CityTranffic,
  11977. x.TwoItemRemark
  11978. })
  11979. .Where(x => x.Id == id)
  11980. .ExecuteCommandAsync();
  11981. if (upd < 1) return Ok(JsonView(false));
  11982. }
  11983. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11984. gwcItemTotal = info.AirGW + info.CityTranffic;
  11985. tdcItemTotal = info.AirTD + info.CityTranffic;
  11986. ////消息通知
  11987. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11988. return Ok(JsonView(new
  11989. {
  11990. parentId = id,
  11991. choiceTwoJJ = dto.ChoiceTwoJJ,
  11992. jjcItemTotal = jjcItemTotal,
  11993. choiceTwoGW = dto.ChoiceTwoGW,
  11994. gwcItemTotal = gwcItemTotal,
  11995. choiceTwoTD = dto.ChoiceTwoTD,
  11996. tdcItemTotal = tdcItemTotal
  11997. }));
  11998. }
  11999. /// <summary>
  12000. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12001. /// </summary>
  12002. /// <returns></returns>
  12003. [HttpPost]
  12004. [ApiExplorerSettings(IgnoreApi = true)]
  12005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12006. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12007. {
  12008. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12009. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12010. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12011. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12012. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12013. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12014. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12015. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12016. {
  12017. Id = x.Id,
  12018. ParentId = dto.DraftId,
  12019. Type = dto.FeeType,
  12020. Days = x.Days,
  12021. NationalTravelFeeId = x.NationalTravelFeeId,
  12022. Cost = x.Cost,
  12023. Currency = x.Currency,
  12024. SubTotal = x.SubTotal,
  12025. CreateUserId = dto.CurrUserId
  12026. })
  12027. .ToList();
  12028. var adds = infos.Where(x => x.Id <= 0).ToList();
  12029. var upds = infos.Where(x => x.Id > 0).ToList();
  12030. if (adds.Count > 0)
  12031. {
  12032. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12033. if (add < 1) return Ok(JsonView(false));
  12034. }
  12035. if (upds.Count > 0)
  12036. {
  12037. var upd = await _sqlSugar.Updateable(adds)
  12038. .UpdateColumns(x => new
  12039. {
  12040. x.Days,
  12041. x.NationalTravelFeeId,
  12042. x.Cost,
  12043. x.Currency,
  12044. x.SubTotal
  12045. })
  12046. .WhereColumns(x => new { x.Id })
  12047. .ExecuteCommandAsync();
  12048. if (upd < 1) return Ok(JsonView(false));
  12049. }
  12050. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12051. ////消息通知
  12052. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12053. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12054. return Ok(JsonView(new { itemTotal = itemTotal }));
  12055. }
  12056. /// <summary>
  12057. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12058. /// </summary>
  12059. /// <returns></returns>
  12060. [HttpPost]
  12061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12062. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12063. {
  12064. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12065. int subId = dto.SubId, feeType = dto.FeeType;
  12066. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12067. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12068. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12069. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12070. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12071. subInfo.Id = subId;
  12072. subInfo.ParentId = dto.DraftId;
  12073. if (feeType == 3) subInfo.Type = 1;
  12074. else if (feeType == 4) subInfo.Type = 2;
  12075. else if (feeType == 5) subInfo.Type = 3;
  12076. else if (feeType == 6) subInfo.Type = 4;
  12077. subInfo.CreateUserId = dto.CurrUserId;
  12078. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12079. if (parentId < 1) return Ok(JsonView(false));
  12080. //子表op
  12081. if (subId < 1)
  12082. {
  12083. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12084. if (subAdd < 1) return Ok(JsonView(false));
  12085. }
  12086. else
  12087. {
  12088. var subUpd = await _sqlSugar.Updateable(subInfo)
  12089. .UpdateColumns(x => new
  12090. {
  12091. x.Days,
  12092. x.NationalTravelFeeId,
  12093. x.Cost,
  12094. x.Currency,
  12095. x.SubTotal
  12096. })
  12097. .WhereColumns(x => new { x.Id })
  12098. .ExecuteCommandAsync();
  12099. if (subUpd < 1) return Ok(JsonView(false));
  12100. }
  12101. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12102. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12103. }
  12104. /// <summary>
  12105. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12106. /// </summary>
  12107. /// <returns></returns>
  12108. [HttpPost]
  12109. [ApiExplorerSettings(IgnoreApi = true)]
  12110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12111. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12112. {
  12113. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12114. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12115. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12116. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12117. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12118. {
  12119. Id = x.Id,
  12120. ParentId = dto.DraftId,
  12121. SetDataId = x.SetDataId,
  12122. Index = x.Index,
  12123. Cost = x.Cost,
  12124. Currency = x.Currency,
  12125. SubTotal = x.SubTotal,
  12126. CreateUserId = dto.CurrUserId,
  12127. Remark = x.Remark
  12128. }).ToList();
  12129. var adds = infos.Where(x => x.Id <= 0).ToList();
  12130. var upds = infos.Where(x => x.Id > 0).ToList();
  12131. if (adds.Count > 0)
  12132. {
  12133. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12134. if (add < 1) return Ok(JsonView(false));
  12135. }
  12136. if (upds.Count > 0)
  12137. {
  12138. var upd = await _sqlSugar.Updateable(adds)
  12139. .UpdateColumns(x => new
  12140. {
  12141. x.Index,
  12142. x.SetDataId,
  12143. x.Cost,
  12144. x.Currency,
  12145. x.SubTotal,
  12146. x.Remark
  12147. })
  12148. .WhereColumns(x => new { x.Id })
  12149. .ExecuteCommandAsync();
  12150. if (upd < 1) return Ok(JsonView(false));
  12151. }
  12152. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12153. //消息通知
  12154. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12155. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12156. return Ok(JsonView(new { itemTotal = itemTotal }));
  12157. }
  12158. /// <summary>
  12159. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12165. {
  12166. int subId = dto.SubId, id = dto.DraftId;
  12167. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12168. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12169. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12170. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12171. subInfo.Id = subId;
  12172. subInfo.ParentId = id;
  12173. subInfo.CreateUserId = dto.CurrUserId;
  12174. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12175. if (parentId < 1) return Ok(JsonView(false));
  12176. #region 子表op
  12177. if (subId < 1)//add
  12178. {
  12179. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12180. if (subAdd < 1) return Ok(JsonView(false));
  12181. }
  12182. else //upd
  12183. {
  12184. var subUpd = await _sqlSugar.Updateable(subInfo)
  12185. .UpdateColumns(x => new
  12186. {
  12187. x.Index,
  12188. x.SetDataId,
  12189. x.Cost,
  12190. x.Currency,
  12191. x.SubTotal,
  12192. x.Remark
  12193. })
  12194. .WhereColumns(x => new { x.Id })
  12195. .ExecuteCommandAsync();
  12196. if (subUpd < 1) return Ok(JsonView(false));
  12197. }
  12198. #endregion
  12199. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12200. ////消息通知
  12201. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12202. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12203. }
  12204. /// <summary>
  12205. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12206. /// </summary>
  12207. /// <returns></returns>
  12208. [HttpPost]
  12209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12210. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12211. {
  12212. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12213. if (data.Code != 0)
  12214. {
  12215. return Ok(JsonView(false, data.Msg));
  12216. }
  12217. return Ok(JsonView(true, "操作成功!", data.Data));
  12218. }
  12219. /// <summary>
  12220. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  12221. /// </summary>
  12222. /// <param name="dto"></param>
  12223. /// <returns></returns>
  12224. [HttpPost]
  12225. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  12226. {
  12227. var data = new Grp_DayOtherPriceDraft()
  12228. {
  12229. Id = dto.Id,
  12230. IsDel = 1,
  12231. DeleteUserId = dto.DeleteUserId,
  12232. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12233. };
  12234. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12235. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  12236. return Ok(JsonView(false, "删除失败!"));
  12237. }
  12238. #endregion
  12239. #endregion
  12240. #region 团组经理模块 出入境费用报价表
  12241. /// <summary>
  12242. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  12243. /// </summary>
  12244. /// <returns></returns>
  12245. [HttpPost]
  12246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12247. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  12248. {
  12249. var initRates = await GeneralMethod.EnterExitCostInitRate();
  12250. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  12251. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  12252. initRates.Insert(0, cnyInfo);
  12253. liveRates.Insert(0, cnyInfo);
  12254. return Ok(JsonView(true, "查询成功!", new
  12255. {
  12256. InitRates = initRates,
  12257. LiveRates = liveRates
  12258. }));
  12259. }
  12260. /// <summary>
  12261. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  12262. /// </summary>
  12263. /// <returns></returns>
  12264. [HttpPost]
  12265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12266. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  12267. {
  12268. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  12269. }
  12270. /// <summary>
  12271. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  12272. /// </summary>
  12273. /// <returns></returns>
  12274. [HttpPost]
  12275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12276. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  12277. {
  12278. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  12279. }
  12280. /// <summary>
  12281. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  12282. /// </summary>
  12283. /// <returns></returns>
  12284. [HttpPost]
  12285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12286. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  12287. {
  12288. int groupId = dto.DiId,
  12289. currUserId = dto.CurrUserId;
  12290. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  12291. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  12292. //验证报价数据是否存在
  12293. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  12294. if (isNull != null)
  12295. {
  12296. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  12297. if (!info1.Rates.Any())
  12298. {
  12299. var rates = await GeneralMethod.EnterExitCostInitRate();
  12300. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12301. info1.Rates = rates.ToArray();
  12302. }
  12303. return Ok(JsonView(info1));
  12304. }
  12305. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  12306. result.GroupId = groupId;
  12307. //处理报价名称
  12308. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  12309. if (groupInfo != null)
  12310. {
  12311. var visitCountry = groupInfo.VisitCountry;
  12312. if (!string.IsNullOrEmpty(visitCountry))
  12313. {
  12314. string quoteName = string.Empty;
  12315. if (visitCountry.Contains("|"))
  12316. {
  12317. var countrys = visitCountry.Split("|");
  12318. quoteName = string.Join("、", countrys);
  12319. }
  12320. else quoteName = visitCountry;
  12321. quoteName += $"团组报价表";
  12322. result.Name = quoteName;
  12323. }
  12324. }
  12325. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12326. if (info.Code != StatusCodes.Status200OK)
  12327. {
  12328. if (!result.Rates.Any())
  12329. {
  12330. var rates = await GeneralMethod.EnterExitCostInitRate();
  12331. result.Rates = rates.ToArray();
  12332. }
  12333. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  12334. }
  12335. var infoView = info.Data as EnterExitCostInfoView;
  12336. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  12337. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  12338. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  12339. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  12340. var eecRates = infoView.Currencys;
  12341. //默认添加人名币
  12342. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  12343. {
  12344. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12345. }
  12346. //处理团组人数
  12347. int pplNum = 1;
  12348. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  12349. var views = new List<QuoteSubItemInfo>();
  12350. #region 数据填充
  12351. var intTravelCosts = new List<QuoteSubItemInfo>();
  12352. #region 机票费用 1354
  12353. int intTravelIndex = 1;
  12354. if (infoView.SumJJC == 1)
  12355. {
  12356. intTravelCosts.Add(new QuoteSubItemInfo
  12357. {
  12358. ItemId = 1354,
  12359. Index = intTravelIndex,
  12360. FeeName = "经济舱",
  12361. UnitPrice = infoView.AirJJ,
  12362. Currency = "CNY",
  12363. Quantity = 1,
  12364. PplNum = 1,
  12365. TotalAmt = infoView.AirJJ,
  12366. Remark = "",
  12367. });
  12368. intTravelIndex++;
  12369. }
  12370. if (infoView.SumGWC == 1)
  12371. {
  12372. intTravelCosts.Add(new QuoteSubItemInfo
  12373. {
  12374. ItemId = 1354,
  12375. Index = intTravelIndex,
  12376. FeeName = "公务舱",
  12377. UnitPrice = infoView.AirGW,
  12378. Currency = "CNY",
  12379. Quantity = 1,
  12380. PplNum = 1,
  12381. TotalAmt = infoView.AirGW,
  12382. Remark = "",
  12383. });
  12384. intTravelIndex++;
  12385. }
  12386. if (infoView.SumTDC == 1)
  12387. {
  12388. intTravelCosts.Add(new QuoteSubItemInfo
  12389. {
  12390. ItemId = 1354,
  12391. Index = intTravelIndex,
  12392. FeeName = "头等舱",
  12393. UnitPrice = infoView.AirTD,
  12394. Currency = "CNY",
  12395. Quantity = 1,
  12396. PplNum = 1,
  12397. TotalAmt = infoView.AirTD,
  12398. Remark = "",
  12399. });
  12400. intTravelIndex++;
  12401. }
  12402. intTravelCosts.Add(new QuoteSubItemInfo
  12403. {
  12404. ItemId = 1354,
  12405. Index = intTravelIndex,
  12406. FeeName = "城市间交通费用",
  12407. UnitPrice = infoView.CityTranffic,
  12408. Currency = "CNY",
  12409. Quantity = 1,
  12410. PplNum = pplNum,
  12411. TotalAmt = infoView.CityTranffic * pplNum,
  12412. Remark = "",
  12413. });
  12414. views.AddRange(intTravelCosts);
  12415. #endregion
  12416. var accomCosts = new List<QuoteSubItemInfo>();
  12417. #region 住宿费 1355
  12418. if (infoView.QuarterageData.Any())
  12419. {
  12420. int accomIndex = 1;
  12421. int accomItemTypeId = 1355;
  12422. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  12423. foreach (var item in groupData)
  12424. {
  12425. string feeName = string.Empty;
  12426. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12427. if (countryInfo != null)
  12428. {
  12429. feeName = countryInfo.Country;
  12430. var city = countryInfo.City;
  12431. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12432. {
  12433. feeName += $"-{city}";
  12434. }
  12435. }
  12436. var hotelInfo = item.FirstOrDefault();
  12437. if (hotelInfo == null) continue;
  12438. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  12439. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12440. int quantity = item.ToList().Count;
  12441. accomCosts.Add(new QuoteSubItemInfo
  12442. {
  12443. ItemId = accomItemTypeId,
  12444. Index = accomIndex,
  12445. FeeName = feeName,
  12446. UnitPrice = hotelInfo.Cost,
  12447. Currency = thisCurrency,
  12448. Quantity = quantity,
  12449. PplNum = pplNum,
  12450. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  12451. Remark = "",
  12452. });
  12453. accomIndex++;
  12454. }
  12455. views.AddRange(accomCosts);
  12456. }
  12457. #endregion
  12458. var mealCosts = new List<QuoteSubItemInfo>();
  12459. #region 餐饮费 1356
  12460. if (infoView.BoardWagesData.Any())
  12461. {
  12462. var mealIndex = 1;
  12463. int mealItemTypeId = 1356;
  12464. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  12465. foreach (var item in groupData)
  12466. {
  12467. string feeName = string.Empty;
  12468. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12469. if (countryInfo != null)
  12470. {
  12471. feeName = countryInfo.Country;
  12472. var city = countryInfo.City;
  12473. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12474. {
  12475. feeName += $"-{city}";
  12476. }
  12477. }
  12478. var mealInfo = item.FirstOrDefault();
  12479. if (mealInfo == null) continue;
  12480. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12481. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12482. int quantity = item.ToList().Count;
  12483. mealCosts.Add(new QuoteSubItemInfo
  12484. {
  12485. ItemId = mealItemTypeId,
  12486. Index = mealIndex,
  12487. FeeName = feeName,
  12488. UnitPrice = mealInfo.Cost,
  12489. Currency = thisCurrency,
  12490. Quantity = quantity,
  12491. PplNum = pplNum,
  12492. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12493. Remark = "",
  12494. });
  12495. mealIndex++;
  12496. }
  12497. views.AddRange(mealCosts);
  12498. }
  12499. #endregion
  12500. var miscCosts = new List<QuoteSubItemInfo>();
  12501. #region 公杂费 1364
  12502. if (infoView.MiscellaneousFeeData.Any())
  12503. {
  12504. var miscIndex = 1;
  12505. int miscItemTypeId = 1364;
  12506. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12507. foreach (var item in groupData)
  12508. {
  12509. string feeName = string.Empty;
  12510. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12511. if (countryInfo != null)
  12512. {
  12513. feeName = countryInfo.Country;
  12514. var city = countryInfo.City;
  12515. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12516. {
  12517. feeName += $"-{city}";
  12518. }
  12519. }
  12520. var miscInfo = item.FirstOrDefault();
  12521. if (miscInfo == null) continue;
  12522. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12523. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12524. int quantity = item.ToList().Count;
  12525. miscCosts.Add(new QuoteSubItemInfo
  12526. {
  12527. ItemId = miscItemTypeId,
  12528. Index = miscIndex,
  12529. FeeName = feeName,
  12530. UnitPrice = miscInfo.Cost,
  12531. Currency = thisCurrency,
  12532. Quantity = quantity,
  12533. PplNum = pplNum,
  12534. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12535. Remark = "",
  12536. });
  12537. miscIndex++;
  12538. }
  12539. views.AddRange(miscCosts);
  12540. }
  12541. #endregion
  12542. #region 签证+保险 1362
  12543. int visaInsIndex = 1;
  12544. int visaInsItemTypeId = 1362;
  12545. if (infoView.Visa > 0)
  12546. {
  12547. views.Add(new QuoteSubItemInfo()
  12548. {
  12549. ItemId = visaInsItemTypeId,
  12550. Index = visaInsIndex,
  12551. FeeName = $"签证",
  12552. UnitPrice = infoView.Visa,
  12553. Currency = $"CNY",
  12554. Quantity = 1,
  12555. PplNum = pplNum,
  12556. TotalAmt = infoView.Visa * pplNum,
  12557. Remark = "",
  12558. });
  12559. visaInsIndex++;
  12560. }
  12561. if (infoView.Safe > 0)
  12562. {
  12563. views.Add(new QuoteSubItemInfo()
  12564. {
  12565. ItemId = visaInsItemTypeId,
  12566. Index = visaInsIndex,
  12567. FeeName = $"保险",
  12568. UnitPrice = infoView.Safe,
  12569. Currency = $"CNY",
  12570. Quantity = 1,
  12571. PplNum = pplNum,
  12572. TotalAmt = infoView.Safe * pplNum,
  12573. Remark = "",
  12574. });
  12575. }
  12576. #endregion
  12577. #region 服务费 1363
  12578. int serviceFeeIndex = 1;
  12579. int serviceFeeItemTypeId = 1363;
  12580. if (infoView.Service > 0)
  12581. {
  12582. views.Add(new QuoteSubItemInfo()
  12583. {
  12584. ItemId = serviceFeeItemTypeId,
  12585. Index = serviceFeeIndex,
  12586. FeeName = $"服务费",
  12587. UnitPrice = infoView.Service,
  12588. Currency = $"CNY",
  12589. Quantity = 1,
  12590. PplNum = pplNum,
  12591. TotalAmt = infoView.Service * pplNum,
  12592. Remark = "",
  12593. });
  12594. }
  12595. #endregion
  12596. #endregion
  12597. if (result.FeeItems.Any())
  12598. {
  12599. result.FeeItems.Select(x =>
  12600. {
  12601. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12602. if (feeInfos.Any()) x.Infos = feeInfos;
  12603. return x;
  12604. }
  12605. ).OrderBy(x => x.Index)
  12606. .ToList();
  12607. if (!result.Rates.Any())
  12608. {
  12609. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12610. else
  12611. {
  12612. var rates = await GeneralMethod.EnterExitCostInitRate();
  12613. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12614. result.Rates = rates.ToArray();
  12615. }
  12616. }
  12617. }
  12618. return Ok(JsonView(result));
  12619. }
  12620. /// <summary>
  12621. /// 团组模块 - 出入境费用报价表 - Info
  12622. /// </summary>
  12623. /// <returns></returns>
  12624. [HttpPost]
  12625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12626. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12627. {
  12628. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12629. if (!info.Rates.Any())
  12630. {
  12631. var rates = await GeneralMethod.EnterExitCostInitRate();
  12632. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12633. info.Rates = rates.ToArray();
  12634. }
  12635. return Ok(JsonView(info));
  12636. }
  12637. /// <summary>
  12638. /// 团组模块 - 出入境费用报价表 - OP
  12639. /// </summary>
  12640. /// <returns></returns>
  12641. [HttpPost]
  12642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12643. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12644. {
  12645. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12646. }
  12647. /// <summary>
  12648. /// 团组模块 - 出入境费用报价表 - 删除 项
  12649. /// </summary>
  12650. /// <returns></returns>
  12651. [HttpPost]
  12652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12653. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12654. {
  12655. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12656. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12657. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12658. }
  12659. /// <summary>
  12660. /// 团组模块 - 出入境费用报价表 - 导出
  12661. /// </summary>
  12662. /// <returns></returns>
  12663. [HttpPost]
  12664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12665. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12666. {
  12667. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12668. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12669. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12670. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12671. var rates = info.Rates;
  12672. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12673. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12674. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12675. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12676. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12677. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12678. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12679. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12680. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12681. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12682. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12683. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12684. //获取模板
  12685. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12686. var designer = new WorkbookDesigner();
  12687. designer.Workbook = new Workbook(tempPath);
  12688. designer.SetDataSource("QuoteName", info.Name);
  12689. designer.SetDataSource("CompanyTitle", "公司名称");
  12690. designer.SetDataSource("CompanyLabel", "");
  12691. #region 国际旅费
  12692. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12693. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12694. {
  12695. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12696. var label = new StringBuilder();
  12697. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12698. if (infos.Any())
  12699. {
  12700. label.Append(infos.Sum(x => x.PplNum));
  12701. label.Append("人全程机票:");
  12702. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12703. label.AppendLine("元");
  12704. }
  12705. foreach (var item in intTravelCosts.Infos)
  12706. {
  12707. label.Append(item.FeeName);
  12708. label.Append(":");
  12709. label.Append(item.UnitPrice.TruncDecimals(2));
  12710. label.Append("元/人*");
  12711. label.Append(item.PplNum);
  12712. label.AppendLine("人");
  12713. }
  12714. if (label.HasValue())
  12715. {
  12716. label.Append("\r\n以上小计:");
  12717. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12718. label.Append("元");
  12719. }
  12720. designer.SetDataSource("IntTravelLabel", label.ToString());
  12721. }
  12722. #endregion
  12723. #region 住宿费
  12724. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12725. if (accomCosts != null && accomCosts.Infos.Any())
  12726. {
  12727. string currencyName = string.Empty,
  12728. countryName = string.Empty;
  12729. decimal rate = 1.0000M;
  12730. var label = new StringBuilder();
  12731. label.AppendLine("全程五星酒店,每人1间房");
  12732. foreach (var item in accomCosts.Infos)
  12733. {
  12734. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12735. string name = string.Empty, thisCountryName = string.Empty;
  12736. if (item.FeeName.Contains('-'))
  12737. {
  12738. var feeName = item.FeeName.Split('-');
  12739. thisCountryName = feeName[0];
  12740. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12741. name = feeName[1];
  12742. }
  12743. else name = item.FeeName;
  12744. string thisFeeName = string.Empty;
  12745. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12746. else thisFeeName = $"\r\n{name}:";
  12747. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12748. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12749. rate = rateInfo?.Rate ?? 1.0000M;
  12750. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12751. label.AppendLine(subLabel);
  12752. }
  12753. if (label.HasValue())
  12754. {
  12755. //以上小计:52440元(美金汇率:7.5 )
  12756. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12757. label.AppendLine(subLabel);
  12758. }
  12759. designer.SetDataSource("AccomLabel", label.ToString());
  12760. }
  12761. #endregion
  12762. #region 餐饮费
  12763. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12764. if (mealCosts != null && mealCosts.Infos.Any())
  12765. {
  12766. string currencyName = string.Empty;
  12767. decimal rate = 1.0000M;
  12768. var label = new StringBuilder();
  12769. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12770. foreach (var item in mealCosts.Infos)
  12771. {
  12772. string name = string.Empty;
  12773. if (item.FeeName.Contains('-'))
  12774. {
  12775. var feeName = item.FeeName.Split('-');
  12776. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12777. }
  12778. else name = $"\r\n{item.FeeName}:";
  12779. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12780. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12781. rate = rateInfo?.Rate ?? 1.0000M;
  12782. label.Append(name);
  12783. label.Append(item.UnitPrice.TruncDecimals(2));
  12784. label.Append(currencyName);
  12785. label.Append("/天*");
  12786. label.Append(item.Quantity.ToString("#0"));
  12787. label.Append('*');
  12788. label.Append(item.PplNum);
  12789. label.Append("人\r\n");
  12790. }
  12791. if (label.HasValue())
  12792. {
  12793. label.Append("\r\n以上小计:");
  12794. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12795. label.Append("元\r\n(");
  12796. label.Append("汇率:");
  12797. label.Append(rate.TruncDecimals(4));
  12798. label.Append(')');
  12799. }
  12800. designer.SetDataSource("MealLabel", label.ToString());
  12801. }
  12802. #endregion
  12803. #region 车辆安排
  12804. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12805. if (vehArranges != null && vehArranges.Infos.Any())
  12806. {
  12807. string currencyName = string.Empty;
  12808. //decimal rate = 1.0000M;
  12809. var label = new StringBuilder();
  12810. foreach (var item in vehArranges.Infos)
  12811. {
  12812. label.AppendLine();
  12813. label.AppendLine();
  12814. label.Append(item.FeeName);
  12815. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12816. }
  12817. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12818. }
  12819. #endregion
  12820. #region 邀请函发放对象
  12821. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12822. designer.SetDataSource("InviteToContent", "");
  12823. #endregion
  12824. #region 邀请函费
  12825. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12826. var is_label = new StringBuilder();
  12827. if (inviteCosts != null && inviteCosts.Infos.Any())
  12828. {
  12829. string currencyName = string.Empty;
  12830. decimal rate = 1.0000M;
  12831. foreach (var item in inviteCosts.Infos)
  12832. {
  12833. //乌兹别克斯坦:2000美金
  12834. currencyName = item.Currency;
  12835. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12836. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12837. is_label.AppendLine(label);
  12838. }
  12839. if (is_label.HasValue())
  12840. {
  12841. //以上小计:28500元(美金汇率:7.5)
  12842. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12843. is_label.AppendLine(label);
  12844. }
  12845. }
  12846. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12847. #endregion
  12848. #region 邀请函发放时间
  12849. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12850. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12851. #endregion
  12852. #region 公务活动(含翻译)
  12853. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12854. var oa_label = new StringBuilder();
  12855. if (officialActs != null && officialActs.Infos.Any())
  12856. {
  12857. string currencyName = string.Empty;
  12858. decimal rate = 1.0000M;
  12859. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12860. foreach (var item in officialActs.Infos)
  12861. {
  12862. //乌兹别克斯坦:1000美金/场
  12863. currencyName = item.Currency;
  12864. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12865. string label_remark = string.Empty;
  12866. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12867. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12868. }
  12869. label_content += "*总费用中未含超出公务活动价格";
  12870. //8场公务活动(以上小计:60000元)
  12871. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12872. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12873. oa_label.AppendLine(label_title);
  12874. oa_label.AppendLine(label_content);
  12875. }
  12876. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12877. #endregion
  12878. #region 签证+保险
  12879. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12880. var vi_label = new StringBuilder();
  12881. if (visaIns != null && visaIns.Infos.Any())
  12882. {
  12883. foreach (var item in visaIns.Infos)
  12884. {
  12885. //签证:500元/人
  12886. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12887. vi_label.AppendLine(label);
  12888. }
  12889. if (vi_label.HasValue())
  12890. {
  12891. //以上小计:6000元
  12892. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12893. vi_label.AppendLine(label);
  12894. }
  12895. }
  12896. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12897. #endregion
  12898. #region 服务费
  12899. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12900. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12901. #endregion
  12902. #region 公杂费
  12903. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12904. var pm_label = new StringBuilder();
  12905. if (pubMiscs != null && pubMiscs.Infos.Any())
  12906. {
  12907. string currencyName = string.Empty,
  12908. countryName = string.Empty;
  12909. decimal rate = 1.0000M;
  12910. foreach (var item in pubMiscs.Infos)
  12911. {
  12912. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12913. string name = string.Empty, thisCountryName = string.Empty;
  12914. if (item.FeeName.Contains('-'))
  12915. {
  12916. var feeName = item.FeeName.Split('-');
  12917. thisCountryName = feeName[0];
  12918. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12919. name = feeName[1];
  12920. }
  12921. else name = item.FeeName;
  12922. string thisFeeName = string.Empty;
  12923. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12924. else thisFeeName = $"\r\n{name}:";
  12925. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12926. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12927. rate = rateInfo?.Rate ?? 1.0000M;
  12928. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12929. pm_label.AppendLine(label);
  12930. }
  12931. if (pm_label.HasValue())
  12932. {
  12933. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12934. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12935. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12936. pm_label.AppendLine(string.Format("部分发放成员"));
  12937. }
  12938. }
  12939. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12940. #endregion
  12941. #region 税费
  12942. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12943. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12944. #endregion
  12945. #region 合计(单位:元)
  12946. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12947. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12948. #endregion
  12949. #region 汇率 Remark
  12950. var rate_label = new StringBuilder();
  12951. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12952. foreach (var item in rateGroups)
  12953. {
  12954. //美元汇率按\r\n1:7.5
  12955. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12956. rate_label.AppendLine(label);
  12957. }
  12958. designer.SetDataSource("RateLabel", rate_label.ToString());
  12959. #endregion
  12960. designer.Process();
  12961. //文件名
  12962. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  12963. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12964. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12965. return Ok(JsonView(true, "成功", url));
  12966. }
  12967. #endregion
  12968. #region 签证费用录入
  12969. /// <summary>
  12970. /// 根据diid查询签证费用列表
  12971. /// </summary>
  12972. /// <param name="dto"></param>
  12973. /// <returns></returns>
  12974. [HttpPost]
  12975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12976. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12977. {
  12978. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12979. if (groupData.Code != 0)
  12980. {
  12981. return Ok(JsonView(false, groupData.Msg));
  12982. }
  12983. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12984. }
  12985. /// <summary>
  12986. /// 根据签证费用Id查询单条数据及c表数据
  12987. /// </summary>
  12988. /// <param name="dto"></param>
  12989. /// <returns></returns>
  12990. [HttpPost]
  12991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12992. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12993. {
  12994. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12995. if (groupData.Code != 0)
  12996. {
  12997. return Ok(JsonView(false, groupData.Msg));
  12998. }
  12999. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13000. }
  13001. /// <summary>
  13002. /// 签证费用删除
  13003. /// </summary>
  13004. /// <param name="dto"></param>
  13005. /// <returns></returns>
  13006. [HttpPost]
  13007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13008. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13009. {
  13010. _sqlSugar.BeginTran();
  13011. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13012. if (!res)
  13013. {
  13014. _sqlSugar.RollbackTran();
  13015. return Ok(JsonView(false, "删除失败"));
  13016. }
  13017. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13018. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13019. .SetColumns(a => new Grp_CreditCardPayment()
  13020. {
  13021. IsDel = 1,
  13022. DeleteUserId = dto.DeleteUserId,
  13023. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13024. })
  13025. .ExecuteCommand();
  13026. if (resSub < 1)
  13027. {
  13028. _sqlSugar.RollbackTran();
  13029. return Ok(JsonView(false, "删除失败"));
  13030. }
  13031. _sqlSugar.CommitTran();
  13032. return Ok(JsonView(true, "删除成功!"));
  13033. }
  13034. /// <summary>
  13035. /// 签证费用录入下拉框初始化
  13036. /// </summary>
  13037. /// <returns></returns>
  13038. [HttpPost]
  13039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13040. public async Task<IActionResult> VisaPriceAddSelect()
  13041. {
  13042. //支付方式
  13043. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13044. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13045. //币种
  13046. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13047. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13048. //乘客类型
  13049. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13050. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13051. //卡类型
  13052. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13053. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13054. //代办费类型
  13055. var agencyFeeTypeData = new List<dynamic>() {
  13056. new { id = 0 , Text = "未选择" },
  13057. new { id = 1 , Text = "小公务" },
  13058. new { id = 2 , Text = "大公务" },
  13059. };
  13060. //签证费用标准国家Data
  13061. var visaSql = string.Format(@"select
  13062. id,
  13063. case
  13064. when FeeType = 0 then Country+'(因公)'
  13065. when FeeType = 1 then Country+'(因私)'
  13066. else Country+'(未设置)'
  13067. end as 'country'
  13068. from Res_VisaFeeStandard where isdel = 0");
  13069. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13070. var data = new
  13071. {
  13072. Payment = _Payment,
  13073. CurrencyList = _CurrencyList,
  13074. PassengerType = _PassengerType,
  13075. BankCard = _BankCard,
  13076. AgencyFeeType = agencyFeeTypeData,
  13077. CountryFeeData = visaCountryFeeData
  13078. };
  13079. return Ok(JsonView(true, "查询成功!", data));
  13080. }
  13081. /// <summary>
  13082. /// 签证费用录入操作(Status:1.新增,2.修改)
  13083. /// </summary>
  13084. /// <param name="dto"></param>
  13085. /// <returns></returns>
  13086. [HttpPost]
  13087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13088. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13089. {
  13090. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13091. if (groupData.Code != 0)
  13092. {
  13093. return Ok(JsonView(false, groupData.Msg));
  13094. }
  13095. #region 应用推送
  13096. try
  13097. {
  13098. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13099. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13100. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13101. //2024-10-21 新增LZ UID
  13102. var userIds = new List<int>() { 21 };
  13103. string title = $"系统通知";
  13104. string content = "";
  13105. var diId = dto.DiId;
  13106. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13107. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13108. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13109. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13110. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13111. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13112. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13113. }
  13114. catch (Exception ex)
  13115. {
  13116. }
  13117. #endregion
  13118. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13119. }
  13120. #endregion
  13121. #region 签证提成录入
  13122. /// <summary>
  13123. /// 签证提成录入
  13124. /// 基础数据
  13125. /// </summary>
  13126. /// <returns></returns>
  13127. [HttpGet]
  13128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13129. public async Task<IActionResult> VisaCommissionInit()
  13130. {
  13131. return Ok(await _visaCommissionRep.Init());
  13132. }
  13133. /// <summary>
  13134. /// 签证提成录入
  13135. /// Item
  13136. /// </summary>
  13137. /// <param name="_dto"></param>
  13138. /// <returns></returns>
  13139. [HttpPost]
  13140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13141. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13142. {
  13143. var validator = new VisaCommissionItemDtoValidator();
  13144. var validatorRes = await validator.ValidateAsync(_dto);
  13145. if (!validatorRes.IsValid)
  13146. {
  13147. var sb = new StringBuilder();
  13148. foreach (var item in validatorRes.Errors)
  13149. {
  13150. sb.AppendLine(item.ErrorMessage);
  13151. }
  13152. return Ok(JsonView(false, sb.ToString()));
  13153. }
  13154. return Ok(await _visaCommissionRep.Item(_dto));
  13155. }
  13156. /// <summary>
  13157. /// 签证提成录入
  13158. /// Save
  13159. /// </summary>
  13160. /// <param name="_dto"></param>
  13161. /// <returns></returns>
  13162. [HttpPost]
  13163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13164. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13165. {
  13166. //参数验证
  13167. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13168. foreach (var item in _dto.Items)
  13169. {
  13170. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13171. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13172. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13173. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13174. }
  13175. return Ok(await _visaCommissionRep.Save(_dto));
  13176. }
  13177. /// <summary>
  13178. /// 签证提成录入
  13179. /// Create
  13180. /// </summary>
  13181. /// <param name="_dto"></param>
  13182. /// <returns></returns>
  13183. [HttpPost]
  13184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13185. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13186. {
  13187. var validator = new VisaCommissionCreateDtoValidator();
  13188. var validatorRes = await validator.ValidateAsync(_dto);
  13189. if (!validatorRes.IsValid)
  13190. {
  13191. var sb = new StringBuilder();
  13192. foreach (var item in validatorRes.Errors)
  13193. {
  13194. sb.AppendLine(item.ErrorMessage);
  13195. }
  13196. return Ok(JsonView(false, sb.ToString()));
  13197. }
  13198. return Ok(await _visaCommissionRep.Create(_dto));
  13199. }
  13200. /// <summary>
  13201. /// 签证提成录入
  13202. /// Put(编辑)
  13203. /// </summary>
  13204. /// <param name="id"></param>
  13205. /// <param name="_dto"></param>
  13206. /// <returns></returns>
  13207. [HttpPut]
  13208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13209. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13210. {
  13211. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13212. var validator = new VisaCommissionCreateDtoValidator();
  13213. var validatorRes = await validator.ValidateAsync(_dto);
  13214. if (!validatorRes.IsValid)
  13215. {
  13216. var sb = new StringBuilder();
  13217. foreach (var item in validatorRes.Errors)
  13218. {
  13219. sb.AppendLine(item.ErrorMessage);
  13220. }
  13221. return Ok(JsonView(false, sb.ToString()));
  13222. }
  13223. return Ok(await _visaCommissionRep.Edit(id, _dto));
  13224. }
  13225. /// <summary>
  13226. /// 签证提成录入
  13227. /// Del
  13228. /// </summary>
  13229. /// <param name="id"></param>
  13230. /// <param name="currUserId"></param>
  13231. /// <returns></returns>
  13232. [HttpPost]
  13233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13234. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  13235. {
  13236. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13237. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  13238. return Ok(await _visaCommissionRep.Del(id, currUserId));
  13239. }
  13240. #endregion
  13241. #region op费用录入
  13242. /// <summary>
  13243. /// 根据diid查询op费用列表
  13244. /// </summary>
  13245. /// <param name="dto"></param>
  13246. /// <returns></returns>
  13247. [HttpPost]
  13248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13249. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  13250. {
  13251. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  13252. if (groupData.Code != 0)
  13253. {
  13254. return Ok(JsonView(false, groupData.Msg));
  13255. }
  13256. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13257. }
  13258. /// <summary>
  13259. /// 根据op费用Id查询单条数据及c表数据
  13260. /// </summary>
  13261. /// <param name="dto"></param>
  13262. /// <returns></returns>
  13263. [HttpPost]
  13264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13265. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  13266. {
  13267. try
  13268. {
  13269. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  13270. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  13271. var data = new
  13272. {
  13273. CarTouristGuideGround = _groupData,
  13274. CreditCardPayment = _creditCardPayment
  13275. };
  13276. return Ok(JsonView(true, "查询成功!", data));
  13277. }
  13278. catch (Exception ex)
  13279. {
  13280. return Ok(JsonView(false, "程序错误!"));
  13281. }
  13282. }
  13283. /// <summary>
  13284. /// op费用删除
  13285. /// </summary>
  13286. /// <param name="dto"></param>
  13287. /// <returns></returns>
  13288. [HttpPost]
  13289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13290. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  13291. {
  13292. try
  13293. {
  13294. _sqlSugar.BeginTran();
  13295. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  13296. if (!res)
  13297. {
  13298. return Ok(JsonView(false, "删除失败"));
  13299. }
  13300. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  13301. {
  13302. IsDel = 1,
  13303. DeleteUserId = dto.DeleteUserId,
  13304. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13305. }).ExecuteCommandAsync();
  13306. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  13307. {
  13308. IsDel = 1,
  13309. DeleteUserId = dto.DeleteUserId,
  13310. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13311. }).ExecuteCommandAsync();
  13312. #region 删除超支相关数据
  13313. //删除导入的超支数据
  13314. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  13315. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  13316. {
  13317. IsDel = 1,
  13318. DeleteUserId = dto.DeleteUserId,
  13319. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13320. }).ExecuteCommand();
  13321. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  13322. {
  13323. IsDel = 1,
  13324. DeleteUserId = dto.DeleteUserId,
  13325. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13326. }).ExecuteCommand();
  13327. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  13328. {
  13329. IsDel = 1,
  13330. DeleteUserId = dto.DeleteUserId,
  13331. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13332. }).ExecuteCommand();
  13333. #endregion
  13334. _sqlSugar.CommitTran();
  13335. return Ok(JsonView(true, "删除成功!"));
  13336. }
  13337. catch (Exception ex)
  13338. {
  13339. _sqlSugar.RollbackTran();
  13340. return Ok(JsonView(false, "程序错误!" + ex.Message));
  13341. }
  13342. }
  13343. /// <summary>
  13344. /// op费用录入操作(Status:1.新增,2.修改)
  13345. /// </summary>
  13346. /// <param name="dto"></param>
  13347. /// <returns></returns>
  13348. [HttpPost]
  13349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13350. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  13351. {
  13352. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  13353. if (groupData.Code != 0)
  13354. {
  13355. return Ok(JsonView(false, groupData.Msg));
  13356. }
  13357. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13358. }
  13359. /// <summary>
  13360. /// 填写费用详细页面初始化绑定
  13361. /// </summary>
  13362. /// <param name="dto"></param>
  13363. /// <returns></returns>
  13364. [HttpPost]
  13365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13366. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  13367. {
  13368. try
  13369. {
  13370. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  13371. if (groupData.Code != 0)
  13372. {
  13373. return Ok(JsonView(false, groupData.Msg));
  13374. }
  13375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13376. }
  13377. catch (Exception ex)
  13378. {
  13379. return Ok(JsonView(false, ex.Message));
  13380. }
  13381. }
  13382. /// <summary>
  13383. /// 根据op费用Id查询详细数据
  13384. /// </summary>
  13385. /// <param name="dto"></param>
  13386. /// <returns></returns>
  13387. [HttpPost]
  13388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13389. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  13390. {
  13391. try
  13392. {
  13393. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  13394. if (groupData.Code != 0)
  13395. {
  13396. return Ok(JsonView(false, groupData.Msg));
  13397. }
  13398. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13399. }
  13400. catch (Exception ex)
  13401. {
  13402. return Ok(JsonView(false, ex.Message));
  13403. }
  13404. }
  13405. /// <summary>
  13406. /// OP费用录入填写详情
  13407. /// </summary>
  13408. /// <param name="dto"></param>
  13409. /// <returns></returns>
  13410. [HttpPost]
  13411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13412. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  13413. {
  13414. try
  13415. {
  13416. #region 参数校验
  13417. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  13418. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  13419. if (di == null) return Ok(JsonView(false, "团组错误!"));
  13420. #endregion
  13421. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  13422. if (groupData.Code != 0)
  13423. {
  13424. return Ok(JsonView(false, groupData.Msg));
  13425. }
  13426. //自动审核
  13427. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  13428. #region 尾款自动审核
  13429. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13430. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  13431. if (opinfos.PriceType == 1062)
  13432. {
  13433. var isAuto = false;
  13434. //找对应的首付款
  13435. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  13436. .InnerJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 79 && a.CId == x.Id && a.DIId == x.DiId && (a.IsAuditGM == 1 || a.IsAuditGM == 3))
  13437. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  13438. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  13439. x.PriceType == 1061 && x.DiId == dto.DiId);
  13440. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  13441. {
  13442. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  13443. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  13444. //合计中排除城市税
  13445. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  13446. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  13447. .Sum(x => x.Price * x.Count);
  13448. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  13449. if (balance >= opinfos.ServiceQuotedPrice)
  13450. {
  13451. isAuto = true;
  13452. }
  13453. }
  13454. if (isAuto)
  13455. {
  13456. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13457. .SetColumns(a => new Grp_CreditCardPayment
  13458. {
  13459. IsAuditGM = 3, //自动审核通过
  13460. AuditGMOperate = 4,
  13461. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13462. })
  13463. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  13464. .ExecuteCommand();
  13465. }
  13466. }
  13467. #endregion
  13468. #region 应用推送
  13469. try
  13470. {
  13471. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13472. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13473. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13474. //2024-10-21 新增LZ UID
  13475. var userIds = new List<int>() { 21 };
  13476. string title = $"系统通知";
  13477. var diId = dto.DiId;
  13478. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13479. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13480. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  13481. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13482. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  13483. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13484. }
  13485. catch (Exception ex)
  13486. {
  13487. }
  13488. #endregion
  13489. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13490. }
  13491. catch (Exception ex)
  13492. {
  13493. return Ok(JsonView(false, ex.Message));
  13494. }
  13495. }
  13496. /// <summary>
  13497. /// 获取三公详细所有城市
  13498. /// </summary>
  13499. /// <returns></returns>
  13500. [HttpGet]
  13501. public IActionResult OpCarCityResult()
  13502. {
  13503. var jw = JsonView(false);
  13504. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  13505. {
  13506. x.Id,
  13507. x.Country,
  13508. x.City,
  13509. }).ToList();
  13510. if (data.Count > 0)
  13511. {
  13512. jw = JsonView(true, "获取成功!", data);
  13513. }
  13514. else
  13515. {
  13516. jw.Msg = "城市数据为空!";
  13517. jw.Data = Array.Empty<string>();
  13518. }
  13519. return Ok(jw);
  13520. }
  13521. /// <summary>
  13522. /// 导出地接费用明细
  13523. /// </summary>
  13524. /// <param name="dto"></param>
  13525. /// <returns></returns>
  13526. [HttpPost]
  13527. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13528. {
  13529. var jw = JsonView(false);
  13530. if (dto.Diid < 1)
  13531. {
  13532. jw.Msg = "请输入正确的diid!";
  13533. return Ok(jw);
  13534. }
  13535. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13536. if (group == null)
  13537. {
  13538. jw.Msg = "未找到团组信息!";
  13539. return Ok(jw);
  13540. }
  13541. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13542. if (localGuideArr.Count == 0)
  13543. {
  13544. jw.Msg = "该团组暂无地接信息!";
  13545. return Ok(jw);
  13546. }
  13547. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13548. var overspendSoure = new Dictionary<int, int>
  13549. {
  13550. { 91, 982 }, //车
  13551. { 92 , 1059} ,//导游
  13552. { 994 , 1073}, //翻译
  13553. { 988 , 1074 }, //早餐
  13554. { 93 , 1075 }, //午餐
  13555. { 989 , 1076 }, //晚餐
  13556. };
  13557. var Zips = new Dictionary<string, Stream>();
  13558. foreach (var groupArr in localGroup)
  13559. {
  13560. var keyValue = groupArr.Key;
  13561. if (int.TryParse(keyValue, out int cityid))
  13562. {
  13563. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13564. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13565. }
  13566. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13567. foreach (var item in groupArr)
  13568. {
  13569. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13570. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13571. new Grp_CarTouristGuideGroundReservationsContentExtend
  13572. {
  13573. Count = a.Count,
  13574. CreateTime = a.CreateTime,
  13575. CreateUserId = a.CreateUserId,
  13576. CTGGRId = a.CTGGRId,
  13577. Currency = a.Currency,
  13578. DatePrice = a.DatePrice,
  13579. DeleteTime = a.DeleteTime,
  13580. DeleteUserId = a.DeleteUserId,
  13581. DiId = a.DiId,
  13582. Id = a.Id,
  13583. IsDel = a.IsDel,
  13584. Price = a.Price,
  13585. PriceContent = a.PriceContent,
  13586. Remark = a.Remark,
  13587. SId = a.SId,
  13588. SidName = b.Name,
  13589. Units = a.Units,
  13590. }
  13591. ).ToList();
  13592. if (content.Count > 0)
  13593. {
  13594. contentArr.Add(content);
  13595. }
  13596. }
  13597. //open excel
  13598. //set excel
  13599. //save excel
  13600. try
  13601. {
  13602. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13603. IWorkbook workbook;
  13604. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13605. {
  13606. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13607. }
  13608. else
  13609. {
  13610. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13611. }
  13612. ISheet sheet = workbook.GetSheetAt(0);
  13613. var rowStartIndex = 2;
  13614. var clounmCount = 10;
  13615. var initStyleRow = sheet.GetRow(2);
  13616. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13617. //var overspendArrDetail =
  13618. var existsId = new List<CarCompare>();
  13619. var lastElem = arr.Last();
  13620. var thisSid = -1;
  13621. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13622. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13623. {
  13624. Name = "未知币种!",
  13625. Remark = "未知币种!",
  13626. };
  13627. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13628. Action cloneRowFn = () =>
  13629. {
  13630. rowStartIndex++;
  13631. var cloneRow = sheet.CreateRow(rowStartIndex);
  13632. // 复制样式
  13633. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13634. {
  13635. ICell sourceCell = initStyleRow.GetCell(i);
  13636. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13637. // 确保单元格存在样式
  13638. if (sourceCell.CellStyle != null)
  13639. {
  13640. targetCell.CellStyle = sourceCell.CellStyle;
  13641. }
  13642. }
  13643. };
  13644. var mergeRow = () =>
  13645. {
  13646. for (int i = 2; i < sheet.LastRowNum; i++)
  13647. {
  13648. var row = sheet.GetRow(i);
  13649. var cellFirst = row.GetCell(0);
  13650. var thisIndex = i + 1;
  13651. while (thisIndex < sheet.LastRowNum)
  13652. {
  13653. var nextRow = sheet.GetRow(thisIndex);
  13654. var nextCellFirst = nextRow.GetCell(0);
  13655. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13656. {
  13657. thisIndex++;
  13658. }
  13659. else
  13660. {
  13661. break;
  13662. }
  13663. }
  13664. thisIndex--;
  13665. if (thisIndex != i)
  13666. {
  13667. //合并row
  13668. var cellRangeAddress = new CellRangeAddress(
  13669. i, // 起始行索引(0-based)
  13670. thisIndex, // 结束行索引(0-based)
  13671. 0, // 起始列索引(0-based)
  13672. 0 // 结束列索引(0-based)
  13673. );
  13674. sheet.AddMergedRegion(cellRangeAddress);
  13675. i = thisIndex;
  13676. }
  13677. }
  13678. };
  13679. var chaoshiNumber = 0;
  13680. var totalNumber = 0.00M;
  13681. string lastStr = "";
  13682. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13683. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13684. {
  13685. b.IsAuditGM,
  13686. x.Id,
  13687. x.Area,
  13688. b.PayPercentage,
  13689. b.PayMoney,
  13690. }).ToList();
  13691. string yesPayment = "", noPayment = "";
  13692. foreach (var item in queryCarArrByCityAndDiid)
  13693. {
  13694. if (item.IsAuditGM == 1)
  13695. {
  13696. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13697. }
  13698. else
  13699. {
  13700. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13701. }
  13702. }
  13703. lastStr = yesPayment + noPayment;
  13704. foreach (var item in arr)
  13705. {
  13706. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  13707. {
  13708. if (thisSid != item.SId)
  13709. {
  13710. if (thisSid == -1)
  13711. {
  13712. thisSid = item.SId;
  13713. }
  13714. else
  13715. {
  13716. //合并小计行
  13717. //创建合并区域的实例
  13718. var cellRangeAddress = new CellRangeAddress(
  13719. rowStartIndex, // 起始行索引(0-based)
  13720. rowStartIndex, // 结束行索引(0-based)
  13721. 0, // 起始列索引(0-based)
  13722. 3 // 结束列索引(0-based)
  13723. );
  13724. sheet.AddMergedRegion(cellRangeAddress);
  13725. var CellStyle = workbook.CreateCellStyle();
  13726. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13727. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13728. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13729. for (int i = 0; i <= clounmCount; i++)
  13730. {
  13731. if (i > 6)
  13732. {
  13733. var CellStyle1 = workbook.CreateCellStyle();
  13734. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13735. IFont Font = workbook.CreateFont(); // 创建字体
  13736. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13737. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13738. CellStyle1.SetFont(Font);
  13739. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13740. }
  13741. else
  13742. {
  13743. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13744. }
  13745. }
  13746. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13747. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13748. //超时合计
  13749. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13750. //超时数
  13751. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13752. //超时合计费用
  13753. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13754. thisSid = item.SId;
  13755. cloneRowFn();
  13756. chaoshiNumber = 0;
  13757. totalNumber = 0;
  13758. }
  13759. }
  13760. IRow row = sheet.GetRow(rowStartIndex);
  13761. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13762. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  13763. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13764. if (isOpenOverspendSoure)
  13765. {
  13766. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13767. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13768. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13769. }
  13770. for (int i = 0; i <= clounmCount; i++)
  13771. {
  13772. var cell = row.GetCell(i);
  13773. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13774. if (cell == null)
  13775. {
  13776. cell = row.CreateCell(i);
  13777. }
  13778. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13779. fontRed.CloneStyleFrom(cell.CellStyle);
  13780. IFont Font = workbook.CreateFont(); // 创建字体
  13781. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13782. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13783. fontRed.SetFont(Font);
  13784. byte[] rgb = new byte[3] { 255, 242, 204 };
  13785. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13786. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13787. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13788. if (workbook is XSSFWorkbook)
  13789. {
  13790. BackgroundColor255_242_204.FillForegroundColor = 0;
  13791. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13792. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13793. }
  13794. else
  13795. {
  13796. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13797. }
  13798. if (i == 1 || i > 6)
  13799. {
  13800. if (i > 6)
  13801. {
  13802. fontRed.FillForegroundColor = 0;
  13803. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13804. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13805. }
  13806. cell.CellStyle = fontRed;
  13807. }
  13808. if (i > 2 && i < 7)
  13809. {
  13810. cell.CellStyle = BackgroundColor255_242_204;
  13811. }
  13812. cell.SetCellValue(setCellValue); //写入单元格
  13813. }
  13814. if (overspendSoure.ContainsKey(thisSid))
  13815. {
  13816. var overspendId = overspendSoure[thisSid];
  13817. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13818. }
  13819. cloneRowFn();
  13820. existsId.Add(new CarCompare
  13821. {
  13822. DataPrice = item.DatePrice.ObjToDate(),
  13823. Sid = item.SId
  13824. });
  13825. }
  13826. if (item.Equals(lastElem))
  13827. {
  13828. //合并小计行
  13829. //创建合并区域的实例
  13830. var cellRangeAddress = new CellRangeAddress(
  13831. rowStartIndex, // 起始行索引(0-based)
  13832. rowStartIndex, // 结束行索引(0-based)
  13833. 0, // 起始列索引(0-based)
  13834. 3 // 结束列索引(0-based)
  13835. );
  13836. sheet.AddMergedRegion(cellRangeAddress);
  13837. var CellStyle = workbook.CreateCellStyle();
  13838. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13839. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13840. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13841. for (int i = 0; i <= clounmCount; i++)
  13842. {
  13843. if (i > 6)
  13844. {
  13845. var CellStyle1 = workbook.CreateCellStyle();
  13846. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13847. IFont Font = workbook.CreateFont(); // 创建字体
  13848. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13849. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13850. CellStyle1.SetFont(Font);
  13851. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13852. }
  13853. else
  13854. {
  13855. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13856. }
  13857. }
  13858. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13859. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13860. //超时合计
  13861. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13862. //超时数
  13863. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13864. //超时合计费用
  13865. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13866. cloneRowFn();
  13867. // 创建合并区域的实例
  13868. cellRangeAddress = new CellRangeAddress(
  13869. rowStartIndex, // 起始行索引(0-based)
  13870. rowStartIndex, // 结束行索引(0-based)
  13871. 0, // 起始列索引(0-based)
  13872. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13873. );
  13874. // 添加合并区域
  13875. sheet.AddMergedRegion(cellRangeAddress);
  13876. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13877. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13878. }
  13879. }
  13880. mergeRow();
  13881. // 保存修改后的Excel文件到新文件
  13882. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13883. // new FileStream(newFilePath, FileMode.CreateNew)
  13884. using (var stream = new MemoryStream())
  13885. {
  13886. workbook.Write(stream, true);
  13887. stream.Flush();
  13888. stream.Seek(0, SeekOrigin.Begin);
  13889. var memoryStream = new MemoryStream();
  13890. stream.CopyTo(memoryStream);
  13891. memoryStream.Seek(0, SeekOrigin.Begin);
  13892. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13893. }
  13894. workbook.Close();
  13895. workbook.Dispose();
  13896. }
  13897. catch (Exception ex)
  13898. {
  13899. jw.Msg = "出现异常!" + ex.Message;
  13900. return Ok(jw);
  13901. }
  13902. }
  13903. if (Zips.Count > 0)
  13904. {
  13905. var io = new IOOperatorHelper();
  13906. var byts = io.ConvertZipStream(Zips);
  13907. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13908. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13909. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13910. }
  13911. else
  13912. {
  13913. jw.Msg = "暂无生成文件!";
  13914. }
  13915. return Ok(jw);
  13916. }
  13917. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13918. {
  13919. string outStr = string.Empty;
  13920. switch (i)
  13921. {
  13922. case 0:
  13923. outStr = arr[0].SidName;
  13924. break;
  13925. case 1:
  13926. outStr = arr[0].DataPriceStr;
  13927. break;
  13928. case 2:
  13929. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13930. break;
  13931. case 4:
  13932. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13933. break;
  13934. case 7:
  13935. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13936. {
  13937. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13938. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13939. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13940. }
  13941. break;
  13942. case 8:
  13943. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13944. {
  13945. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13946. }
  13947. break;
  13948. case 9:
  13949. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13950. {
  13951. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13952. }
  13953. break;
  13954. case 10:
  13955. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13956. {
  13957. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13958. }
  13959. break;
  13960. }
  13961. return outStr;
  13962. }
  13963. #region OP行程单
  13964. /// <summary>
  13965. /// OP行程单初始化
  13966. /// </summary>
  13967. /// <param name="dto"></param>
  13968. /// <returns></returns>
  13969. [HttpPost]
  13970. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13971. {
  13972. var jw = JsonView(false);
  13973. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13974. var group = groupList.First();
  13975. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13976. if (group == null)
  13977. {
  13978. jw.Msg = "暂无团组!";
  13979. return Ok(jw);
  13980. }
  13981. group = groupList.Find(x => x.Id == diid);
  13982. if (group == null)
  13983. {
  13984. jw.Msg = "请输入正确的团组ID!";
  13985. return Ok(jw);
  13986. }
  13987. string city = string.Empty;
  13988. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13989. if (blackCode.Count > 0)
  13990. {
  13991. var black = blackCode.First();
  13992. black.BlackCode = black.BlackCode ?? "";
  13993. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13994. if (blackSp.Length > 0)
  13995. {
  13996. try
  13997. {
  13998. var cityArrCode = new List<string>(20);
  13999. foreach (var item in blackSp)
  14000. {
  14001. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14002. var IndexSelect = itemSp[2];
  14003. var cityArrCodeLength = cityArrCode.Count - 1;
  14004. var startCity = IndexSelect.Substring(0, 3);
  14005. if (cityArrCodeLength > 0)
  14006. {
  14007. var arrEndCity = cityArrCode[cityArrCodeLength];
  14008. if (arrEndCity != startCity)
  14009. {
  14010. cityArrCode.Add(startCity.ToUpper());
  14011. }
  14012. }
  14013. else
  14014. {
  14015. cityArrCode.Add(startCity.ToUpper());
  14016. }
  14017. var endCity = IndexSelect.Substring(3, 3);
  14018. cityArrCode.Add(endCity.ToUpper());
  14019. }
  14020. var cityThree = string.Empty;
  14021. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14022. cityThree = cityThree.TrimEnd(',');
  14023. if (string.IsNullOrWhiteSpace(cityThree))
  14024. {
  14025. throw new
  14026. Exception("error");
  14027. }
  14028. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14029. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14030. foreach (var item in cityArrCode)
  14031. {
  14032. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14033. if (find != null)
  14034. {
  14035. city += find.City + "/";
  14036. }
  14037. else
  14038. {
  14039. city += item + "三字码未收入/";
  14040. }
  14041. }
  14042. city = city.TrimEnd('/');
  14043. }
  14044. catch (Exception e)
  14045. {
  14046. city = "黑屏代码格式不正确!";
  14047. }
  14048. }
  14049. }
  14050. else
  14051. {
  14052. city = "未录入黑屏代码";
  14053. }
  14054. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14055. {
  14056. Date = x.Date,
  14057. Days = x.Days,
  14058. Diffgroup = x.Diffgroup,
  14059. Diid = x.Diid,
  14060. Traffic_First = x.Traffic_First,
  14061. Traffic_Second = x.Traffic_Second,
  14062. Trip = x.Trip,
  14063. WeekDay = x.WeekDay,
  14064. Id = x.Id
  14065. }).ToList();
  14066. jw.Data = new
  14067. {
  14068. groupList = groupList.Select(x => new
  14069. {
  14070. x.Id,
  14071. x.TeamName,
  14072. x.TourCode
  14073. }).ToList(),
  14074. groupInfo = new
  14075. {
  14076. group.VisitDays,
  14077. group.TourCode,
  14078. group.VisitPNumber,
  14079. group.TeamName,
  14080. city
  14081. },
  14082. OpTravelList
  14083. };
  14084. jw.Code = 200;
  14085. jw.Msg = "操作成功!";
  14086. return Ok(jw);
  14087. }
  14088. /// <summary>
  14089. /// 删除团组行程单
  14090. /// </summary>
  14091. /// <returns></returns>
  14092. [HttpPost]
  14093. public IActionResult DelTravel(DelOpTravelDto dto)
  14094. {
  14095. var jw = JsonView(false);
  14096. if (dto.UserId <= 0 || dto.Diid <= 0)
  14097. {
  14098. jw.Msg = "请输入正确的参数!";
  14099. return Ok(jw);
  14100. }
  14101. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14102. .SetColumns(x => new Grp_TravelList
  14103. {
  14104. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14105. DeleteUserId = dto.UserId,
  14106. IsDel = 1,
  14107. }).ExecuteCommand();
  14108. jw = JsonView(true);
  14109. return Ok(jw);
  14110. }
  14111. /// <summary>
  14112. /// 行程单保存
  14113. /// </summary>
  14114. /// <returns></returns>
  14115. [HttpPost]
  14116. public IActionResult TravelSave(TravelSaveDto dto)
  14117. {
  14118. var jw = JsonView(false);
  14119. if (dto.Arr.Count > 0)
  14120. {
  14121. try
  14122. {
  14123. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14124. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14125. .ToList();
  14126. _sqlSugar.BeginTran();
  14127. foreach (var item in dto.Arr)
  14128. {
  14129. if (item.Id == 0)
  14130. {
  14131. throw new Exception("请传入正确的Id");
  14132. }
  14133. //比较上一次的差异
  14134. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14135. if (findTravel != null)
  14136. {
  14137. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14138. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14139. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14140. }
  14141. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14142. .SetColumns(x => new Grp_TravelList
  14143. {
  14144. Trip = item.Trip
  14145. }).ExecuteCommand();
  14146. }
  14147. _sqlSugar.CommitTran();
  14148. jw = JsonView(true);
  14149. }
  14150. catch (Exception ex)
  14151. {
  14152. _sqlSugar.RollbackTran();
  14153. jw.Msg = "程序异常!" + ex.Message;
  14154. }
  14155. }
  14156. else
  14157. {
  14158. jw.Msg = "请传入正确的参数!";
  14159. }
  14160. return Ok(jw);
  14161. }
  14162. private static string CheckStr(string original, string changed)
  14163. {
  14164. // 创建diff_match_patch对象
  14165. var dmp = new diff_match_patch();
  14166. // 计算差异
  14167. List<Diff> diffs = dmp.diff_main(original, changed);
  14168. // 清理和合并差异
  14169. dmp.diff_cleanupSemantic(diffs);
  14170. // 使用StringBuilder构建最终的字符串
  14171. var finalString = new StringBuilder();
  14172. // 输出差异结果,并构建变动后的字符串
  14173. foreach (Diff diff in diffs)
  14174. {
  14175. switch (diff.operation)
  14176. {
  14177. case Operation.EQUAL:
  14178. // 相等的部分,直接添加到最终字符串
  14179. finalString.Append(diff.text);
  14180. break;
  14181. case Operation.INSERT:
  14182. // 插入的部分,添加标记并添加到最终字符串
  14183. finalString.Append("[++]" + diff.text + "[++]");
  14184. break;
  14185. case Operation.DELETE:
  14186. // 删除的部分,不添加到最终字符串
  14187. //finalString.Append("[++]" + diff.text + "[++]");
  14188. break;
  14189. }
  14190. }
  14191. // 输出变动后的字符串
  14192. return finalString.ToString();
  14193. }
  14194. private class tagContent
  14195. {
  14196. public DateTime Date { get; set; }
  14197. public string StartTag { get; set; }
  14198. public string EndTag { get; set; }
  14199. public string Content { get; set; }
  14200. public static int tagLength { get { return 3; } }
  14201. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14202. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14203. public bool IsFinally { get; set; }
  14204. }
  14205. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14206. {
  14207. var results = new List<string>();
  14208. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14209. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14210. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14211. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14212. string[] strValueArr = new string[1];
  14213. foreach (System.Text.RegularExpressions.Match match in matches)
  14214. {
  14215. var strValue = match.Groups[1].Value;
  14216. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  14217. }
  14218. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  14219. return results;
  14220. }
  14221. /// <summary>
  14222. /// 导出行程单
  14223. /// </summary>
  14224. /// <param name="dto"></param>
  14225. /// <returns></returns>
  14226. [HttpPost]
  14227. public IActionResult ExportTravel(ExportTravelDto dto)
  14228. {
  14229. var jw = JsonView(false);
  14230. jw.Data = "";
  14231. int diid = 0;
  14232. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  14233. if (Find == null)
  14234. {
  14235. jw.Msg = "请选择正确的团组!";
  14236. return Ok(jw);
  14237. }
  14238. else
  14239. {
  14240. diid = Find.Id;
  14241. }
  14242. //数据源
  14243. var _travelList = new List<Grp_TravelList>();
  14244. DataTable dtBlack = null;
  14245. try
  14246. {
  14247. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  14248. }
  14249. catch (Exception)
  14250. {
  14251. jw.Msg = "机票黑屏代码有误!";
  14252. return Ok(jw);
  14253. }
  14254. string CityStr = string.Empty;
  14255. if (dtBlack.Rows.Count == 0)
  14256. {
  14257. jw.Msg = "机票黑屏代码有误!";
  14258. return Ok(jw);
  14259. }
  14260. else
  14261. {
  14262. foreach (DataRow row in dtBlack.Rows)
  14263. {
  14264. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14265. {
  14266. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  14267. return Ok(jw);
  14268. }
  14269. }
  14270. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  14271. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  14272. }
  14273. // 指定的文字
  14274. var targetTextDic = new Dictionary<string, List<string>>();
  14275. //创建数据源Table
  14276. var dtSource = new DataTable();
  14277. dtSource.Columns.Add("Days", typeof(string));
  14278. dtSource.Columns.Add("Date", typeof(string));
  14279. dtSource.Columns.Add("Week", typeof(string));
  14280. dtSource.Columns.Add("Traffic", typeof(string));
  14281. dtSource.Columns.Add("Trip", typeof(string));
  14282. //获取数据,放到datatable
  14283. foreach (var item in _travelList)
  14284. {
  14285. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  14286. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  14287. .Replace(tagContent.TagFormat.Item2, string.Empty)
  14288. .Replace("[++]", string.Empty);
  14289. DataRow dr = dtSource.NewRow();
  14290. dr["Days"] = item.Days;
  14291. dr["Date"] = item.Date;
  14292. dr["Week"] = item.WeekDay;
  14293. dr["Traffic"] = item.Traffic_First
  14294. + "\r\n"
  14295. + item.Traffic_Second;
  14296. dr["Trip"] = item.Trip;
  14297. dtSource.Rows.Add(dr);
  14298. }
  14299. var dic = new Dictionary<string, string>
  14300. {
  14301. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  14302. { "City", CityStr },
  14303. { "Days", Find.VisitDays.ToString() },
  14304. { "DeleCode", Find.TourCode },
  14305. { "Pnum", Find.VisitPNumber.ToString() }
  14306. };
  14307. //模板路径
  14308. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  14309. //载入模板
  14310. Document doc = null;
  14311. DocumentBuilder builder = null;
  14312. try
  14313. {
  14314. //载入模板
  14315. doc = new Document(tempPath);
  14316. builder = new DocumentBuilder(doc);
  14317. }
  14318. catch (Exception)
  14319. {
  14320. jw.Msg = "模板位置不存在!";
  14321. return Ok(jw);
  14322. }
  14323. foreach (var key in dic.Keys)
  14324. {
  14325. Bookmark bookmark = doc.Range.Bookmarks[key];
  14326. if (bookmark != null)
  14327. {
  14328. builder.MoveToBookmark(key);
  14329. builder.Write(dic[key]);
  14330. }
  14331. }
  14332. //获取word里所有表格
  14333. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14334. //获取所填表格的序数
  14335. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14336. try
  14337. {
  14338. //循环赋值
  14339. for (int i = 0; i < dtSource.Rows.Count; i++)
  14340. {
  14341. builder.MoveToCell(0, i + 1, 0, 0);
  14342. builder.Write(dtSource.Rows[i]["Days"].ToString());
  14343. builder.MoveToCell(0, i + 1, 1, 0);
  14344. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  14345. builder.MoveToCell(0, i + 1, 2, 0);
  14346. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  14347. var trip = dtSource.Rows[i]["Trip"].ToString();
  14348. builder.MoveToCell(0, i + 1, 3, 0);
  14349. builder.Write(trip);
  14350. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  14351. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14352. // 获取特定索引的段落
  14353. Paragraph paragraph = (Paragraph)paragraphs[0];
  14354. Run run = paragraph.Runs[0];
  14355. Aspose.Words.Font font = run.Font;
  14356. font.Name = "黑体";
  14357. //设置双休红色
  14358. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  14359. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  14360. paragraph = (Paragraph)paragraphs[1];
  14361. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  14362. {
  14363. run = paragraph.Runs[0];
  14364. font = run.Font;
  14365. font.Color = Color.Red;
  14366. }
  14367. }
  14368. }
  14369. catch (Exception ex)
  14370. {
  14371. }
  14372. //删除多余行
  14373. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  14374. {
  14375. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  14376. }
  14377. var targetTextList = new List<string>();
  14378. // 遍历文档中的表格
  14379. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14380. {
  14381. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14382. {
  14383. var cellIndex = 0;
  14384. foreach (Cell cell in row.Cells)
  14385. {
  14386. if (cellIndex == 1 && row.Cells.Count == 4)
  14387. {
  14388. foreach (var target in targetTextDic.Keys)
  14389. {
  14390. if (cell.GetText().Contains(target))
  14391. {
  14392. targetTextList = targetTextDic[target];
  14393. break;
  14394. }
  14395. }
  14396. }
  14397. // 遍历单元格中的所有段落
  14398. foreach (Paragraph paragraph in cell.Paragraphs)
  14399. {
  14400. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  14401. var runs = new List<Run>();
  14402. foreach (Run run in paragraph.Runs)
  14403. {
  14404. runs.Add(run);
  14405. }
  14406. foreach (Run run in runs)
  14407. {
  14408. foreach (var targetText in targetTextList)
  14409. {
  14410. // 检查文字是否包含指定文字
  14411. if (run.Text.Contains(targetText))
  14412. {
  14413. // 将包含的部分设置为红色
  14414. HighlightText(run, targetText, Color.Red);
  14415. }
  14416. }
  14417. }
  14418. }
  14419. cellIndex++;
  14420. }
  14421. }
  14422. }
  14423. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  14424. if (!Directory.Exists(savePath))
  14425. {
  14426. try
  14427. {
  14428. Directory.CreateDirectory(savePath);
  14429. }
  14430. catch
  14431. {
  14432. }
  14433. }
  14434. string path = savePath + Find.TeamName + "出访日程";
  14435. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  14436. try
  14437. {
  14438. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  14439. string postfix = ".docx";
  14440. if (dto.IsPDF == 1)
  14441. {
  14442. saveFormat = Aspose.Words.SaveFormat.Pdf;
  14443. postfix = ".pdf";
  14444. }
  14445. doc.Save(path + postfix, saveFormat);
  14446. jw = JsonView(true, "导出成功", ftpPath + postfix);
  14447. }
  14448. catch (Exception)
  14449. {
  14450. jw = JsonView(false);
  14451. }
  14452. return Ok(jw);
  14453. }
  14454. /// <summary>
  14455. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  14456. /// </summary>
  14457. /// <param name="num"></param>
  14458. /// <returns></returns>
  14459. static string GetNum(string num)
  14460. {
  14461. string str = "";
  14462. switch (num)
  14463. {
  14464. case "1":
  14465. str = "一";
  14466. break;
  14467. case "2":
  14468. str = "二";
  14469. break;
  14470. case "3":
  14471. str = "三";
  14472. break;
  14473. case "4":
  14474. str = "四";
  14475. break;
  14476. case "5":
  14477. str = "五";
  14478. break;
  14479. case "6":
  14480. str = "六";
  14481. break;
  14482. case "7":
  14483. str = "七";
  14484. break;
  14485. case "8":
  14486. str = "八";
  14487. break;
  14488. case "9":
  14489. str = "九";
  14490. break;
  14491. case "10":
  14492. str = "十";
  14493. break;
  14494. case "11":
  14495. str = "十一";
  14496. break;
  14497. case "12":
  14498. str = "十二";
  14499. break;
  14500. case "一":
  14501. str = "1";
  14502. break;
  14503. case "二":
  14504. str = "2";
  14505. break;
  14506. case "三":
  14507. str = "3";
  14508. break;
  14509. case "四":
  14510. str = "4";
  14511. break;
  14512. case "五":
  14513. str = "5";
  14514. break;
  14515. case "六":
  14516. str = "6";
  14517. break;
  14518. case "七":
  14519. str = "7";
  14520. break;
  14521. case "八":
  14522. str = "8";
  14523. break;
  14524. case "九":
  14525. str = "9";
  14526. break;
  14527. case "十":
  14528. str = "10";
  14529. break;
  14530. case "十一":
  14531. str = "11";
  14532. break;
  14533. case "十二":
  14534. str = "12";
  14535. break;
  14536. }
  14537. return str;
  14538. }
  14539. /// <summary>
  14540. /// 高亮包含指定文字的部分
  14541. /// </summary>
  14542. /// <param name="run"></param>
  14543. /// <param name="targetText"></param>
  14544. /// <param name="color"></param>
  14545. static void HighlightText(Run run, string targetText, Color color)
  14546. {
  14547. string text = run.Text;
  14548. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14549. if (startIndex >= 0)
  14550. {
  14551. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14552. // 前部分
  14553. if (startIndex > 0)
  14554. {
  14555. Run beforeRun = (Run)run.Clone(true);
  14556. beforeRun.Text = text.Substring(0, startIndex);
  14557. parentParagraph.InsertBefore(beforeRun, run);
  14558. }
  14559. // 匹配部分
  14560. Run matchRun = (Run)run.Clone(true);
  14561. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14562. matchRun.Font.Color = color;
  14563. parentParagraph.InsertBefore(matchRun, run);
  14564. // 后部分
  14565. if (startIndex + targetText.Length < text.Length)
  14566. {
  14567. Run afterRun = (Run)run.Clone(true);
  14568. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14569. parentParagraph.InsertBefore(afterRun, run);
  14570. }
  14571. // 删除原始Run
  14572. run.Remove();
  14573. }
  14574. }
  14575. #endregion
  14576. #endregion
  14577. #region 团组成本
  14578. /// <summary>
  14579. /// 团组成本数据初始化
  14580. /// </summary>
  14581. /// <param name="dto"></param>
  14582. /// <returns></returns>
  14583. [HttpPost]
  14584. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14585. {
  14586. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14587. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14588. WHEN COUNT(*) >= 0 THEN 'True'
  14589. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14590. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14591. ").ToList(); //团组列表
  14592. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14593. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14594. var visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14595. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14596. if (groupinfoValue != null)
  14597. {
  14598. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14599. var spArr = new string[1] { countryArr };
  14600. if (countryArr.Contains("|"))
  14601. {
  14602. spArr = countryArr.Split("|");
  14603. }
  14604. else if (countryArr.Contains("、"))
  14605. {
  14606. spArr = countryArr.Split("、");
  14607. }
  14608. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14609. {
  14610. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14611. if (dbQueryCountry != null)
  14612. {
  14613. visaCountryInfoArr.Add(dbQueryCountry);
  14614. }
  14615. }
  14616. }
  14617. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14618. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14619. #region 屏蔽黑屏代码生成
  14620. //var create = _GroupCostRepository.
  14621. // CreateGroupCostByBlackCode(dto.Diid);
  14622. //if (groupCost.Count == 0 && create.Code == 0)
  14623. //{
  14624. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14625. //}
  14626. #endregion
  14627. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14628. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14629. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14630. groupCostMap = groupCostMap.Select(x =>
  14631. {
  14632. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14633. {
  14634. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14635. }
  14636. return x;
  14637. }).ToList();
  14638. //GroupCostParameter.Add(new
  14639. // Grp_GroupCostParameter());
  14640. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14641. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14642. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  14643. return Ok(JsonView(new
  14644. {
  14645. groupList,
  14646. groupInfo,
  14647. groupChecks,
  14648. groupCost = groupCostMap,
  14649. hotelNumber,
  14650. GroupCostParameter = GroupCostParameterMap,
  14651. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14652. {
  14653. x.VisaCountry,
  14654. x.VisaPrice,
  14655. x.Id,
  14656. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14657. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14658. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14659. x.VisaTime, // 一般签证时间
  14660. x.PettyBusinessAgencyFee, //小公务代办费
  14661. x.GrandBusinessAgencyFee //大公务代办费
  14662. }).ToList(),
  14663. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14664. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14665. hotelIsTrue,
  14666. groupModuleOperators
  14667. }));
  14668. }
  14669. /// <summary>
  14670. /// 团组成本信息保存
  14671. /// </summary>
  14672. /// <param name="dto"></param>
  14673. /// <returns></returns>
  14674. [HttpPost]
  14675. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14676. {
  14677. if (dto.Diid <= 0 || dto.Userid <= 0)
  14678. {
  14679. return Ok(JsonView(false));
  14680. }
  14681. JsonView jw = null;
  14682. bool isTrue = false;
  14683. #region 复制团组成本
  14684. //if (dto.Diid == 2581)
  14685. //{
  14686. // dto.Diid = 2599;
  14687. // dto.CheckBoxs.ForEach(x =>
  14688. // {
  14689. // x.Diid = 2599;
  14690. // });
  14691. // dto.GroupCosts.ForEach(x =>
  14692. // {
  14693. // x.Diid = 2599;
  14694. // });
  14695. // dto.CostTypeHotelNumbers.ForEach(x =>
  14696. // {
  14697. // x.Diid = 2599;
  14698. // });
  14699. // dto.GroupCostParameters.ForEach(x =>
  14700. // {
  14701. // x.DiId = 2599;
  14702. // });
  14703. //}
  14704. #endregion
  14705. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14706. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14707. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14708. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14709. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14710. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14711. try
  14712. {
  14713. _sqlSugar.BeginTran();
  14714. isTrue = await _GroupCostRepository.
  14715. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14716. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14717. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14718. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14719. _sqlSugar.CommitTran();
  14720. jw = JsonView(true, "保存成功!", isTrue);
  14721. }
  14722. catch (Exception)
  14723. {
  14724. _sqlSugar.RollbackTran();
  14725. jw = JsonView(false);
  14726. }
  14727. return Ok(jw);
  14728. }
  14729. /// <summary>
  14730. /// 复制团组成本信息
  14731. /// </summary>
  14732. /// <param name="dto"></param>
  14733. /// <returns></returns>
  14734. [HttpPost]
  14735. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14736. {
  14737. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14738. {
  14739. return Ok(JsonView(false, "参数有误!"));
  14740. }
  14741. #region 复制团组成本
  14742. dto.Diid = dto.ToGroupId;
  14743. dto.CheckBoxs.ForEach(x =>
  14744. {
  14745. x.Diid = dto.ToGroupId;
  14746. });
  14747. dto.GroupCosts.ForEach(x =>
  14748. {
  14749. x.Diid = dto.ToGroupId;
  14750. });
  14751. dto.CostTypeHotelNumbers.ForEach(x =>
  14752. {
  14753. x.Diid = dto.ToGroupId;
  14754. });
  14755. dto.GroupCostParameters.ForEach(x =>
  14756. {
  14757. x.DiId = dto.ToGroupId;
  14758. });
  14759. #endregion
  14760. JsonView jw = null;
  14761. bool isTrue = false;
  14762. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14763. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14764. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14765. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14766. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14767. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14768. try
  14769. {
  14770. _sqlSugar.BeginTran();
  14771. isTrue = await _GroupCostRepository.
  14772. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14773. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14774. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14775. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14776. _sqlSugar.CommitTran();
  14777. jw = JsonView(true, "保存成功!", isTrue);
  14778. }
  14779. catch (Exception)
  14780. {
  14781. _sqlSugar.RollbackTran();
  14782. jw = JsonView(false);
  14783. }
  14784. return Ok(jw);
  14785. }
  14786. /// <summary>
  14787. /// 司兼导数据
  14788. /// </summary>
  14789. /// <param name="dto"></param>
  14790. /// <returns></returns>
  14791. [HttpPost]
  14792. public IActionResult GetCarGuides(CarGuidesDto dto)
  14793. {
  14794. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14795. return Ok(JsonView(true, "获取成功!", Data));
  14796. }
  14797. /// <summary>
  14798. /// 导游数据
  14799. /// </summary>
  14800. /// <param name="dto"></param>
  14801. /// <returns></returns>
  14802. [HttpPost]
  14803. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14804. {
  14805. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14806. // 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
  14807. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14808. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14809. return Ok(JsonView(true, "获取成功!", Data));
  14810. }
  14811. /// <summary>
  14812. /// 成本车数据
  14813. /// </summary>
  14814. /// <param name="dto"></param>
  14815. /// <returns></returns>
  14816. [HttpPost]
  14817. public IActionResult GetCarInfo(CarGuidesDto dto)
  14818. {
  14819. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14820. return Ok(JsonView(true, "获取成功!", Data));
  14821. }
  14822. /// <summary>
  14823. /// 景点数据
  14824. /// </summary>
  14825. /// <param name="dto"></param>
  14826. /// <returns></returns>
  14827. [HttpPost]
  14828. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14829. {
  14830. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14831. return Ok(JsonView(true, "获取成功!", Data));
  14832. }
  14833. /// <summary>
  14834. /// 成本通知
  14835. /// </summary>
  14836. /// <param name="dto"></param>
  14837. /// <returns></returns>
  14838. [HttpPost]
  14839. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14840. {
  14841. if (dto.Diid < 0)
  14842. {
  14843. return Ok(JsonView(false));
  14844. }
  14845. JsonView jw;
  14846. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14847. if (GroupCostParameter != null)
  14848. {
  14849. int IsShare = 0;
  14850. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14851. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14852. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14853. string msg = string.Empty;
  14854. if (isTrue)
  14855. {
  14856. if (IsShare == 0)
  14857. {
  14858. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14859. }
  14860. else
  14861. {
  14862. #region 企微通知对应岗位用户
  14863. try
  14864. {
  14865. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14866. }
  14867. catch (Exception)
  14868. {
  14869. }
  14870. #endregion
  14871. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14872. }
  14873. jw = JsonView(isTrue, msg, new { IsShare });
  14874. }
  14875. else
  14876. {
  14877. msg = "修改失败!";
  14878. jw = JsonView(isTrue, msg);
  14879. }
  14880. }
  14881. else
  14882. {
  14883. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14884. }
  14885. return Ok(jw);
  14886. }
  14887. /// <summary>
  14888. /// 导出报价单
  14889. /// </summary>
  14890. /// <param name="dto"></param>
  14891. /// <returns></returns>
  14892. [HttpPost]
  14893. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14894. {
  14895. if (dto.Diid == 0)
  14896. {
  14897. return Ok(JsonView(false, "请传递团组id"));
  14898. }
  14899. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14900. if (deleInfo.Code != 0)
  14901. {
  14902. return Ok(JsonView(false, "团组信息查询失败!"));
  14903. }
  14904. var di = deleInfo.Data as DelegationInfoWebView;
  14905. if (di != null)
  14906. {
  14907. di.TeamName = di.TeamName.Replace("|", "、");
  14908. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14909. //文件名
  14910. string strFileName = di.TeamName + "-收款账单.doc";
  14911. //获取模板
  14912. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14913. //载入模板
  14914. Document doc = new Document(tmppath);
  14915. decimal TotalPrice = 0.00M;
  14916. string itemStr = string.Empty;
  14917. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14918. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14919. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14920. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14921. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14922. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14923. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14924. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14925. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14926. foreach (var cost in groupCostType)
  14927. {
  14928. var List = cost.ToList();
  14929. if (cost.Key == "A")
  14930. {
  14931. foreach (var ListItem in List)
  14932. {
  14933. if (ListItem.number > 0)
  14934. {
  14935. if (ListItem.code.Contains("TBR"))
  14936. {
  14937. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14938. }
  14939. else
  14940. {
  14941. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14942. }
  14943. TotalPrice += (ListItem.number * ListItem.price);
  14944. }
  14945. }
  14946. }
  14947. else
  14948. {
  14949. itemStr = itemStr.Insert(0, "A段\r\n");
  14950. itemStr += "B段\r\n";
  14951. foreach (var ListItem in List)
  14952. {
  14953. if (ListItem.number > 0)
  14954. {
  14955. if (ListItem.code.Contains("TBR"))
  14956. {
  14957. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14958. }
  14959. else
  14960. {
  14961. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14962. }
  14963. TotalPrice += (ListItem.number * ListItem.price);
  14964. }
  14965. }
  14966. }
  14967. }
  14968. #region 替换Word模板书签内容
  14969. Dictionary<string, string> marks = new Dictionary<string, string>();
  14970. marks.Add("To", di.ClientUnit);//付款方
  14971. marks.Add("ToTel", di.TellPhone);//付款方电话
  14972. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14973. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14974. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14975. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14976. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14977. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14978. marks.Add("PayItemContent", itemStr);//详细信息
  14979. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14980. #endregion
  14981. ////注
  14982. //if (doc.Range.Bookmarks["Attention"] != null)
  14983. //{
  14984. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14985. // mark.Text = frList[0].Attention;
  14986. //}
  14987. foreach (var item in marks.Keys)
  14988. {
  14989. if (doc.Range.Bookmarks[item] != null)
  14990. {
  14991. Bookmark mark = doc.Range.Bookmarks[item];
  14992. mark.Text = marks[item];
  14993. }
  14994. }
  14995. byte[] bytes = null;
  14996. using (MemoryStream stream = new MemoryStream())
  14997. {
  14998. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14999. bytes = stream.ToArray();
  15000. }
  15001. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15002. return Ok(JsonView(true, "", new
  15003. {
  15004. Data = bytes,
  15005. strFileName,
  15006. }));
  15007. }
  15008. else
  15009. {
  15010. return Ok(JsonView(false, "团组信息不存在!"));
  15011. }
  15012. }
  15013. /// <summary>
  15014. /// 导出团组成本
  15015. /// </summary>
  15016. /// <param name="dto"></param>
  15017. /// <returns></returns>
  15018. [HttpPost]
  15019. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15020. {
  15021. var jw = JsonView(false);
  15022. if (dto.Diid == 0)
  15023. {
  15024. return Ok(JsonView(false, "请传递团组id"));
  15025. }
  15026. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15027. if (deleInfo.Code != 0)
  15028. {
  15029. return Ok(JsonView(false, "团组信息查询失败!"));
  15030. }
  15031. var di = deleInfo.Data as DelegationInfoWebView;
  15032. if (di == null)
  15033. {
  15034. return Ok(JsonView(false, "团组信息查询失败!"));
  15035. }
  15036. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15037. WorkbookDesigner designer = new WorkbookDesigner();
  15038. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15039. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15040. List<int> hideColumnList = new List<int>();
  15041. var ColumnSetting = new[]
  15042. {
  15043. new { tag = "VF", Index = 4, P = "CarCost" },
  15044. new { tag = "VN", Index = 5, P = "CarNumber" },
  15045. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15046. new { tag = "T/G S", Index = 7, P = "TGS" },
  15047. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15048. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15049. new { tag = "T/G M", Index = 10, P = "TGM" },
  15050. new { tag = "T/G A", Index = 11, P = "TGA" },
  15051. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15052. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15053. new { tag = "C/F S", Index = 14, P = "CFS" },
  15054. new { tag = "C/F M", Index = 15, P = "CFM" },
  15055. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15056. new { tag = "B", Index = 17, P = "B" },
  15057. new { tag = "L", Index = 18, P = "L" },
  15058. new { tag = "D", Index = 19, P = "D" },
  15059. new { tag = "TBR", Index = 20, P = "TBR" },
  15060. new { tag = "SGR", Index = 21, P = "SGR" },
  15061. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15062. new { tag = "Suite", Index = 23, P = "Suite" },
  15063. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15064. new { tag = "T/V", Index = 25, P = "TV" },
  15065. new { tag = "1/L", Index = 26, P = "iL" },
  15066. new { tag = "I/F", Index = 27, P = "IF" },
  15067. new { tag = "EF", Index = 28, P = "EF" },
  15068. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15069. new { tag = "TE", Index = 30, P = "TE" },
  15070. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15071. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15072. new { tag = "P/C", Index = 33, P = "PC" },
  15073. new { tag = "T/L F", Index = 34, P = "TLF" },
  15074. new { tag = "E/C T", Index = 35, P = "ECT" }
  15075. };
  15076. Func<string, bool> isEmpty = (str) =>
  15077. {
  15078. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15079. {
  15080. return true;
  15081. }
  15082. if (string.IsNullOrWhiteSpace(str))
  15083. {
  15084. return true;
  15085. }
  15086. return false;
  15087. };
  15088. for (int i = 0; i < List_GC.Count; i++)
  15089. {
  15090. GroupCost_Excel gc = new GroupCost_Excel();
  15091. gc.Id = List_GC[i].Id;
  15092. gc.Diid = List_GC[i].Diid.ToString();
  15093. gc.DAY = List_GC[i].DAY;
  15094. string week = "";
  15095. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15096. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15097. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15098. gc.ITIN = List_GC[i].ITIN;
  15099. gc.CarType = List_GC[i].CarType;
  15100. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15101. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15102. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15103. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15104. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15105. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15106. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15107. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15108. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15109. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15110. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15111. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15112. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15113. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15114. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15115. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15116. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15117. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15118. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15119. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15120. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15121. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15122. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15123. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15124. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15125. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15126. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15127. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15128. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15129. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15130. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15131. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15132. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15133. gc.EFR = List_GC[i].EFR;
  15134. List_GC1.Add(gc);
  15135. }
  15136. if (List_GC1.Count > 0)
  15137. {
  15138. var p = List_GC1[0];
  15139. var prs = p.GetType().GetProperties();
  15140. foreach (var item in prs)
  15141. {
  15142. var tp = item.PropertyType;
  15143. if (tp == typeof(int))
  15144. {
  15145. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15146. if (val == 0)
  15147. {
  15148. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15149. if (columnSetting != null)
  15150. {
  15151. hideColumnList.Add(columnSetting.Index);
  15152. }
  15153. }
  15154. }
  15155. if (tp == typeof(decimal))
  15156. {
  15157. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15158. if (val == 0)
  15159. {
  15160. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15161. if (columnSetting != null)
  15162. {
  15163. hideColumnList.Add(columnSetting.Index);
  15164. }
  15165. }
  15166. }
  15167. if (tp == typeof(string))
  15168. {
  15169. var val = List_GC1.Sum(x =>
  15170. {
  15171. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15172. if (decimal.TryParse(str, out decimal str_De))
  15173. {
  15174. return str_De;
  15175. }
  15176. else
  15177. {
  15178. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  15179. }
  15180. });
  15181. if (val == 0)
  15182. {
  15183. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15184. if (columnSetting != null)
  15185. {
  15186. hideColumnList.Add(columnSetting.Index);
  15187. }
  15188. }
  15189. }
  15190. }
  15191. }
  15192. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  15193. dt.TableName = "TB";
  15194. //报表标题等不用dt的值
  15195. designer.SetDataSource("TeamName", dto.title.TeamName);
  15196. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  15197. designer.SetDataSource("Tax", dto.title.Tax);
  15198. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  15199. designer.SetDataSource("Currency", dto.title.Currency);
  15200. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  15201. designer.SetDataSource("Rate", dto.title.Rate);
  15202. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  15203. var Aparams = hotels.Find(x => x.Type == "Default");
  15204. if (Aparams == null)
  15205. {
  15206. return Ok(jw);
  15207. }
  15208. //酒店数量
  15209. var txtSGRNumber = Aparams.SGR.ToString();
  15210. var txtTBRNumber = Aparams.TBR.ToString();
  15211. var txtJSESNumber = Aparams.JSES.ToString();
  15212. var txtSUITENumbe = Aparams.SUITE.ToString();
  15213. if (dto.costType == "B")
  15214. {
  15215. Aparams = hotels.Find(x => x.Type == "A");
  15216. var Bparams = hotels.Find(x => x.Type == "B");
  15217. if (Aparams == null || Bparams == null)
  15218. {
  15219. return Ok(jw);
  15220. }
  15221. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  15222. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  15223. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  15224. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  15225. }
  15226. designer.SetDataSource("SGRNumber", txtSGRNumber);
  15227. designer.SetDataSource("TBRNumber", txtTBRNumber);
  15228. designer.SetDataSource("JSESNumber", txtJSESNumber);
  15229. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  15230. var ws = designer.Workbook.Worksheets[1];
  15231. int Row = List_GC.Count;
  15232. int startIndex = 0;
  15233. int HideRows = 0;
  15234. Row = 0;
  15235. List<int> hideRowsList = new List<int>();
  15236. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  15237. #region A段left数据
  15238. var left = dto.leftInfo.Find(x => x.Type == "A");
  15239. if (left == null)
  15240. {
  15241. return Ok(jw);
  15242. }
  15243. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  15244. if (leftBindData != null)
  15245. {
  15246. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  15247. designer.SetDataSource("VisaRS", leftBindData.rs);
  15248. designer.SetDataSource("VisaXS", leftBindData.xs);
  15249. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15250. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15251. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15252. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15253. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15254. }
  15255. else
  15256. {
  15257. hideRowsList.Add(Row + startIndex + HideRows);
  15258. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15259. }
  15260. HideRows += 2;
  15261. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  15262. if (leftBindData != null)
  15263. {
  15264. designer.SetDataSource("BXDRCB", leftBindData.cb);
  15265. designer.SetDataSource("BXRS", leftBindData.rs);
  15266. designer.SetDataSource("BXXS", leftBindData.xs);
  15267. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15268. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15269. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15270. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15271. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15272. }
  15273. else
  15274. {
  15275. hideRowsList.Add(Row + startIndex + HideRows);
  15276. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15277. }
  15278. HideRows += 2;
  15279. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15280. if (leftBindData != null)
  15281. {
  15282. designer.SetDataSource("HSDRCB", leftBindData.cb);
  15283. designer.SetDataSource("HSRS", leftBindData.rs);
  15284. designer.SetDataSource("HSXS", leftBindData.xs);
  15285. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15286. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15287. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15288. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15289. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15290. }
  15291. else
  15292. {
  15293. hideRowsList.Add(Row + startIndex + HideRows);
  15294. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15295. }
  15296. HideRows += 2;
  15297. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15298. if (leftBindData != null)
  15299. {
  15300. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  15301. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  15302. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  15303. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15304. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15305. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15306. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15307. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15308. }
  15309. else
  15310. {
  15311. hideRowsList.Add(Row + startIndex + HideRows);
  15312. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15313. }
  15314. HideRows += 2;
  15315. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15316. if (leftBindData != null)
  15317. {
  15318. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  15319. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  15320. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  15321. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15322. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15323. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15324. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15325. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15326. }
  15327. else
  15328. {
  15329. hideRowsList.Add(Row + startIndex + HideRows);
  15330. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15331. }
  15332. HideRows += 2;
  15333. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15334. if (leftBindData != null)
  15335. {
  15336. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  15337. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  15338. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  15339. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15340. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15341. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15342. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15343. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15344. }
  15345. else
  15346. {
  15347. hideRowsList.Add(Row + startIndex + HideRows);
  15348. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15349. }
  15350. HideRows += 2;
  15351. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15352. if (leftBindData != null)
  15353. {
  15354. ////TBR
  15355. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  15356. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  15357. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  15358. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15359. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15360. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15361. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15362. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15363. }
  15364. else
  15365. {
  15366. hideRowsList.Add(Row + startIndex + HideRows);
  15367. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15368. }
  15369. HideRows += 2;
  15370. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15371. if (leftBindData != null)
  15372. {
  15373. ////SGR
  15374. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  15375. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  15376. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  15377. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15378. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15379. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15380. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15381. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15382. }
  15383. else
  15384. {
  15385. hideRowsList.Add(Row + startIndex + HideRows);
  15386. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15387. }
  15388. HideRows += 2;
  15389. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15390. if (leftBindData != null)
  15391. {
  15392. ////JS/ES
  15393. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  15394. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  15395. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  15396. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15397. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15398. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15399. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15400. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15401. }
  15402. else
  15403. {
  15404. hideRowsList.Add(Row + startIndex + HideRows);
  15405. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15406. }
  15407. HideRows += 2;
  15408. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15409. if (leftBindData != null)
  15410. {
  15411. ////SUITE
  15412. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  15413. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  15414. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  15415. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15416. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15417. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15418. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15419. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15420. }
  15421. else
  15422. {
  15423. hideRowsList.Add(Row + startIndex + HideRows);
  15424. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15425. }
  15426. HideRows += 2;
  15427. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15428. if (leftBindData != null)
  15429. {
  15430. designer.SetDataSource("DJDRCB", leftBindData.cb);
  15431. designer.SetDataSource("DJRS", leftBindData.rs);
  15432. designer.SetDataSource("DJXS", leftBindData.xs);
  15433. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15434. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15435. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15436. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15437. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15438. }
  15439. else
  15440. {
  15441. hideRowsList.Add(Row + startIndex + HideRows);
  15442. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15443. }
  15444. HideRows += 2;
  15445. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15446. if (leftBindData != null)
  15447. {
  15448. designer.SetDataSource("HCPCB", leftBindData.cb);
  15449. designer.SetDataSource("HCPRS", leftBindData.rs);
  15450. designer.SetDataSource("HCPXS", leftBindData.xs);
  15451. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15452. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15453. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15454. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15455. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15456. }
  15457. else
  15458. {
  15459. hideRowsList.Add(Row + startIndex + HideRows);
  15460. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15461. }
  15462. HideRows += 2;
  15463. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15464. if (leftBindData != null)
  15465. {
  15466. designer.SetDataSource("CPCB", leftBindData.cb);
  15467. designer.SetDataSource("CPRS", leftBindData.rs);
  15468. designer.SetDataSource("CPXS", leftBindData.xs);
  15469. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15470. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15471. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15472. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15473. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15474. }
  15475. else
  15476. {
  15477. hideRowsList.Add(Row + startIndex + HideRows);
  15478. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15479. }
  15480. HideRows += 2;
  15481. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15482. if (leftBindData != null)
  15483. {
  15484. designer.SetDataSource("GWDRCD", leftBindData.cb);
  15485. designer.SetDataSource("GWRS", leftBindData.rs);
  15486. designer.SetDataSource("GWXS", leftBindData.xs);
  15487. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15488. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15489. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15490. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15491. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15492. }
  15493. else
  15494. {
  15495. hideRowsList.Add(Row + startIndex + HideRows);
  15496. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15497. }
  15498. HideRows += 2;
  15499. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15500. if (leftBindData != null)
  15501. {
  15502. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  15503. designer.SetDataSource("LYJRS", leftBindData.rs);
  15504. designer.SetDataSource("LYJXS", leftBindData.xs);
  15505. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15506. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15507. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15508. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15509. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15510. }
  15511. else
  15512. {
  15513. hideRowsList.Add(Row + startIndex + HideRows);
  15514. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  15515. }
  15516. #endregion
  15517. #region A段Right信息
  15518. var right = dto.rightInfo.Find(x => x.Type == "A");
  15519. if (right == null)
  15520. {
  15521. return Ok(jw);
  15522. }
  15523. HideRows += 4;
  15524. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15525. if (rightBindData != null)
  15526. {
  15527. //经济舱 + 双人间 TBR
  15528. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  15529. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  15530. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15531. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  15532. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15533. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15534. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15535. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15536. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15537. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15538. }
  15539. else
  15540. {
  15541. hideRowsList.Add(Row + startIndex + HideRows);
  15542. }
  15543. HideRows += 2;
  15544. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15545. if (rightBindData != null)
  15546. {
  15547. //经济舱 + 单人间 SGR
  15548. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  15549. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  15550. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15551. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  15552. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15553. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15554. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15555. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15556. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15557. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15558. }
  15559. else
  15560. {
  15561. hideRowsList.Add(Row + startIndex + HideRows);
  15562. }
  15563. HideRows += 2;
  15564. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15565. if (rightBindData != null)
  15566. {
  15567. //公务舱 + 单人间 SGR
  15568. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  15569. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  15570. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15571. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  15572. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15573. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15574. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15575. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15576. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15577. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15578. }
  15579. else
  15580. {
  15581. hideRowsList.Add(Row + startIndex + HideRows);
  15582. }
  15583. HideRows += 2;
  15584. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15585. if (rightBindData != null)
  15586. {
  15587. //公务舱 + 小套房 JSES
  15588. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  15589. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  15590. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15591. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  15592. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15593. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15594. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15595. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15596. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15597. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15598. }
  15599. else
  15600. {
  15601. hideRowsList.Add(Row + startIndex + HideRows);
  15602. }
  15603. HideRows += 2;
  15604. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15605. if (rightBindData != null)
  15606. {
  15607. //公务舱 + 小套房 JSES
  15608. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  15609. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  15610. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15611. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  15612. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15613. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15614. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15615. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15616. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15617. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15618. }
  15619. else
  15620. {
  15621. hideRowsList.Add(Row + startIndex + HideRows);
  15622. }
  15623. HideRows += 2;
  15624. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15625. if (rightBindData != null)
  15626. {
  15627. //经济舱 + 大套房
  15628. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  15629. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  15630. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15631. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  15632. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15633. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15634. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15635. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15636. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15637. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15638. }
  15639. else
  15640. {
  15641. hideRowsList.Add(Row + startIndex + HideRows);
  15642. }
  15643. HideRows += 2;
  15644. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15645. if (rightBindData != null)
  15646. {
  15647. //头等舱 + 小套房 JSES
  15648. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15649. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15650. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15651. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15652. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15653. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15654. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15655. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15656. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15657. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15658. }
  15659. else
  15660. {
  15661. hideRowsList.Add(Row + startIndex + HideRows);
  15662. }
  15663. HideRows += 2;
  15664. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15665. if (rightBindData != null)
  15666. {
  15667. //头等舱 + 大套房
  15668. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15669. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15670. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15671. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15672. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15673. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15674. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15675. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15676. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15677. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15678. }
  15679. else
  15680. {
  15681. hideRowsList.Add(Row + startIndex + HideRows);
  15682. }
  15683. #endregion
  15684. #region B段标题清空
  15685. designer.SetDataSource("CostBDRCB", "");
  15686. designer.SetDataSource("CostBRS", "");
  15687. designer.SetDataSource("CostBXS", "");
  15688. designer.SetDataSource("CostBZCB", "");
  15689. designer.SetDataSource("CostBDRBJ", "");
  15690. designer.SetDataSource("CostBZBJ", "");
  15691. designer.SetDataSource("CostBDRLR", "");
  15692. designer.SetDataSource("CostBZLR", "");
  15693. designer.SetDataSource("CostBDRCBOM", "");
  15694. designer.SetDataSource("CostBRSOM", "");
  15695. designer.SetDataSource("CostBZCBOM", "");
  15696. designer.SetDataSource("CostBDRBJOM", "");
  15697. designer.SetDataSource("CostBZBJOM", "");
  15698. designer.SetDataSource("CostBDRLROM", "");
  15699. designer.SetDataSource("CostBZLROM", "");
  15700. #endregion
  15701. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15702. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15703. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15704. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15705. designer.SetDataSource("DJName", "地接(CNY)");
  15706. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15707. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15708. designer.SetDataSource("GWName", "公务(CNY)");
  15709. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15710. designer.SetDataSource("LYJName", "零用金(CNY)");
  15711. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15712. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15713. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15714. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15715. designer.SetDataSource("BXName", "保险(CNY)");
  15716. designer.SetDataSource("VisaName", "签证(CNY)");
  15717. #region B段基本数据
  15718. if (dto.costType == "B")
  15719. {
  15720. left = dto.leftInfo.Find(x => x.Type == "B");
  15721. if (left == null)
  15722. {
  15723. return Ok(jw);
  15724. }
  15725. #region B段left数据
  15726. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15727. if (leftBindData != null)
  15728. {
  15729. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15730. designer.SetDataSource("BHSRS", leftBindData.rs);
  15731. designer.SetDataSource("BHSXS", leftBindData.xs);
  15732. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15733. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15734. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15735. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15736. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15737. }
  15738. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15739. if (leftBindData != null)
  15740. {
  15741. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15742. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15743. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15744. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15745. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15746. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15747. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15748. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15749. }
  15750. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15751. if (leftBindData != null)
  15752. {
  15753. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15754. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15755. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15756. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15757. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15758. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15759. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15760. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15761. }
  15762. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15763. if (leftBindData != null)
  15764. {
  15765. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15766. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15767. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15768. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15769. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15770. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15771. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15772. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15773. }
  15774. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15775. if (leftBindData != null)
  15776. {
  15777. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15778. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15779. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15780. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15781. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15782. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15783. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15784. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15785. }
  15786. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15787. if (leftBindData != null)
  15788. {
  15789. designer.SetDataSource("BCPCB", leftBindData.cb);
  15790. designer.SetDataSource("BCPRS", leftBindData.rs);
  15791. designer.SetDataSource("BCPXS", leftBindData.xs);
  15792. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15793. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15794. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15795. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15796. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15797. }
  15798. //TBR
  15799. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15800. if (leftBindData != null)
  15801. {
  15802. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15803. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15804. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15805. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15806. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15807. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15808. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15809. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15810. }
  15811. //SGR
  15812. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15813. if (leftBindData != null)
  15814. {
  15815. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15816. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15817. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15818. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15819. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15820. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15821. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15822. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15823. }
  15824. //JS/ES
  15825. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15826. if (leftBindData != null)
  15827. {
  15828. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15829. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15830. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15831. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15832. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15833. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15834. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15835. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15836. }
  15837. //SUITE
  15838. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15839. if (leftBindData != null)
  15840. {
  15841. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15842. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15843. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15844. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15845. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15846. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15847. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15848. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15849. }
  15850. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15851. if (leftBindData != null)
  15852. {
  15853. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15854. designer.SetDataSource("BDJRS", leftBindData.rs);
  15855. designer.SetDataSource("BDJXS", leftBindData.xs);
  15856. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15857. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15858. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15859. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15860. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15861. }
  15862. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15863. if (leftBindData != null)
  15864. {
  15865. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15866. designer.SetDataSource("BGWRS", leftBindData.rs);
  15867. designer.SetDataSource("BGWXS", leftBindData.xs);
  15868. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15869. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15870. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15871. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15872. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15873. }
  15874. #region 优化方案
  15875. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15876. //excelBind.Add("零用金", new {
  15877. //cb="",
  15878. //rs="",
  15879. //xs ="",
  15880. //zcb = "",
  15881. //});
  15882. #endregion
  15883. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15884. if (leftBindData != null)
  15885. {
  15886. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15887. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15888. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15889. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15890. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15891. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15892. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15893. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15894. }
  15895. #endregion
  15896. #region B段Right信息
  15897. right = dto.rightInfo.Find(x => x.Type == "B");
  15898. if (right == null)
  15899. {
  15900. return Ok(jw);
  15901. }
  15902. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15903. if (rightBindData != null)
  15904. {
  15905. //经济舱 + 双人间 TBR
  15906. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15907. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15908. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15909. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15910. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15911. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15912. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15913. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15914. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15915. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15916. }
  15917. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15918. if (rightBindData != null)
  15919. {
  15920. //经济舱 + 单人间 SGR
  15921. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15922. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15923. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15924. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15925. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15926. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15927. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15928. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15929. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15930. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15931. }
  15932. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15933. if (rightBindData != null)
  15934. {
  15935. //公务舱 + 单人间 SGR
  15936. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15937. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15938. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15939. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15940. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15941. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15942. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15943. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15944. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15945. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15946. }
  15947. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15948. if (rightBindData != null)
  15949. {
  15950. //公务舱 + 小套房 JSES
  15951. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15952. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15953. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15954. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15955. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15956. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15957. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15958. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15959. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15960. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15961. }
  15962. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15963. if (rightBindData != null)
  15964. {
  15965. //公务舱 + 小套房 JSES
  15966. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15967. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15968. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15969. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15970. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15971. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15972. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15973. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15974. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15975. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15976. }
  15977. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15978. if (rightBindData != null)
  15979. {
  15980. //经济舱 + 大套房
  15981. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15982. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15983. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15984. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15985. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15986. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15987. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15988. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15989. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15990. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15991. }
  15992. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15993. if (rightBindData != null)
  15994. {
  15995. //头等舱 + 小套房 JSES
  15996. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15997. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15998. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15999. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16000. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16001. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16002. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16003. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16004. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16005. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16006. }
  16007. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16008. if (rightBindData != null)
  16009. {
  16010. //头等舱 + 大套房
  16011. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16012. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16013. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16014. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16015. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16016. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16017. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16018. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16019. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16020. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16021. }
  16022. #endregion
  16023. #region 标题
  16024. designer.SetDataSource("CostBDRCB", "单人成本");
  16025. designer.SetDataSource("CostBRS", "人数");
  16026. designer.SetDataSource("CostBXS", "系数");
  16027. designer.SetDataSource("CostBZCB", "总成本");
  16028. designer.SetDataSource("CostBDRBJ", "单人报价");
  16029. designer.SetDataSource("CostBZBJ", "总报价");
  16030. designer.SetDataSource("CostBDRLR", "单人利润");
  16031. designer.SetDataSource("CostBZLR", "总利润");
  16032. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16033. designer.SetDataSource("CostBRSOM", "人数");
  16034. designer.SetDataSource("CostBZCBOM", "总成本");
  16035. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16036. designer.SetDataSource("CostBZBJOM", "总报价");
  16037. designer.SetDataSource("CostBDRLROM", "单人利润");
  16038. designer.SetDataSource("CostBZLROM", "总利润");
  16039. #endregion
  16040. }
  16041. #endregion
  16042. designer.SetDataSource("TzZCB2", TzZCB2);
  16043. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16044. designer.SetDataSource("TzZLR2", TzZLR2);
  16045. string[] dataSourceKeys = new string[]
  16046. {
  16047. "VF",
  16048. "TGS",
  16049. "TGOF",
  16050. "TGM",
  16051. "TGA",
  16052. "TGTF",
  16053. "TGEF",
  16054. "CFM",
  16055. "CFOF",
  16056. "B",
  16057. "L",
  16058. "D",
  16059. "TBR",
  16060. "SGR",
  16061. "JSES",
  16062. "Suite",
  16063. "TV",
  16064. "1L",
  16065. "IF",
  16066. "EF",
  16067. "BRF",
  16068. "TE",
  16069. "TGT",
  16070. "DRVT",
  16071. "PC",
  16072. "TLF",
  16073. "ECT"
  16074. };
  16075. foreach (var item in dataSourceKeys)
  16076. {
  16077. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16078. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16079. var find = dto.titleModel.FirstOrDefault(expr);
  16080. if (find != null)
  16081. {
  16082. designer.SetDataSource(item, find.text);
  16083. }
  16084. else
  16085. {
  16086. designer.SetDataSource(item, 0);
  16087. }
  16088. }
  16089. designer.SetDataSource(dt);
  16090. //根据数据源处理生成报表内容
  16091. designer.Process();
  16092. designer.Workbook.Worksheets[0].Name = "费用明细";
  16093. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16094. Worksheet sheet = designer.Workbook.Worksheets[0];
  16095. #region 隐藏舱位
  16096. var settingAir = new[]
  16097. {
  16098. new { key = "经济舱", index = 7 },
  16099. new { key = "公务舱", index = 19 },
  16100. new { key = "头等舱", index = 11 }
  16101. };
  16102. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16103. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16104. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16105. .Select((c, s) => s.Name)
  16106. .ToList()
  16107. .GroupBy(x => x)
  16108. .Select(x => x.Key);
  16109. foreach (var item in settingAir)
  16110. {
  16111. if (!airType.Contains(item.key))
  16112. {
  16113. hideRowsList.Add(item.index);
  16114. }
  16115. }
  16116. #endregion
  16117. foreach (var Rowindex in hideRowsList)
  16118. {
  16119. ws.Cells.HideRows(Rowindex, 2);
  16120. }
  16121. ws = designer.Workbook.Worksheets[0];
  16122. foreach (var Column in hideColumnList)
  16123. {
  16124. ws.Cells.HideColumns(Column, 1);
  16125. }
  16126. byte[] bytes = null;
  16127. string strFileName = di.TeamName + "-团组-成本.xls";
  16128. using (MemoryStream stream = new MemoryStream())
  16129. {
  16130. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16131. bytes = stream.ToArray();
  16132. }
  16133. return Ok(JsonView(true, "", new
  16134. {
  16135. Data = bytes,
  16136. strFileName,
  16137. }));
  16138. }
  16139. /// <summary>
  16140. /// 导出客户报表
  16141. /// </summary>
  16142. /// <returns></returns>
  16143. [HttpPost]
  16144. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16145. {
  16146. var jw = JsonView(false);
  16147. if (dto.Diid == 0)
  16148. {
  16149. return Ok(JsonView(false, "请传递团组id"));
  16150. }
  16151. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16152. if (deleInfo.Code != 0)
  16153. {
  16154. return Ok(JsonView(false, "团组信息查询失败!"));
  16155. }
  16156. var di = deleInfo.Data as DelegationInfoWebView;
  16157. if (di == null)
  16158. {
  16159. return Ok(JsonView(false, "团组信息查询失败!"));
  16160. }
  16161. //文件名
  16162. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16163. //获取模板
  16164. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16165. //载入模板
  16166. Document doc = new Document(tmppath);
  16167. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16168. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16169. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16170. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16171. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16172. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16173. if (AParameter == null)
  16174. {
  16175. return Ok(JsonView(false, "系数不存在!"));
  16176. }
  16177. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  16178. , TzAirDesc, TzZCost;
  16179. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  16180. = TzAirDesc = TzZCost = string.Empty;
  16181. TzNumber = AParameter.CostTypenumber.ToString();
  16182. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  16183. CarGuides1 = dto.CarGuides1;
  16184. Meal = dto.Meal;
  16185. SubsidizedMeals = dto.SubsidizedMeals;
  16186. NightRepair = dto.NightRepair;
  16187. AttractionsTickets = dto.AttractionsTickets;
  16188. MiscellaneousFees = dto.MiscellaneousFees;
  16189. ATip = dto.ATip;
  16190. TzHotelDesc = "";
  16191. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  16192. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  16193. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  16194. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  16195. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  16196. TzAirDesc = "";
  16197. TzZCost = dto.TzZCost;
  16198. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  16199. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  16200. var index = 1;
  16201. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  16202. foreach (var item in TzHotelDescArr)
  16203. {
  16204. if (AinfoArr != null)
  16205. {
  16206. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16207. if (Ainfo != null)
  16208. {
  16209. if (int.Parse(Ainfo.rs) <= 0)
  16210. {
  16211. continue;
  16212. }
  16213. var hotelText = string.Empty;
  16214. switch (item)
  16215. {
  16216. case "SGR":
  16217. hotelText = "单人间";
  16218. break;
  16219. case "JSES":
  16220. hotelText = "小套房";
  16221. break;
  16222. case "SUITE":
  16223. hotelText = "套房";
  16224. break;
  16225. case "TBR":
  16226. hotelText = "双人间";
  16227. break;
  16228. }
  16229. if (item != "TBR")
  16230. {
  16231. 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";
  16232. }
  16233. else
  16234. {
  16235. 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";
  16236. }
  16237. index++;
  16238. }
  16239. }
  16240. }
  16241. index = 1;
  16242. foreach (var item in TzAirDescArr)
  16243. {
  16244. if (AinfoArr != null)
  16245. {
  16246. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16247. if (Ainfo != null)
  16248. {
  16249. if (int.Parse(Ainfo.rs) <= 0)
  16250. {
  16251. continue;
  16252. }
  16253. 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";
  16254. index++;
  16255. }
  16256. }
  16257. }
  16258. if (dto.costType == "B")
  16259. {
  16260. if (BParameter == null)
  16261. {
  16262. return Ok(JsonView(false, "B段系数不存在!"));
  16263. }
  16264. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  16265. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  16266. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  16267. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  16268. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  16269. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  16270. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  16271. foreach (var item in TzHotelDescArr)
  16272. {
  16273. if (AinfoArr != null)
  16274. {
  16275. TzHotelDesc += "B段信息 \r\n";
  16276. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16277. if (Ainfo != null)
  16278. {
  16279. if (int.Parse(Ainfo.rs) <= 0)
  16280. {
  16281. continue;
  16282. }
  16283. var hotelText = string.Empty;
  16284. switch (item)
  16285. {
  16286. case "SGR":
  16287. hotelText = "单人间";
  16288. break;
  16289. case "JSES":
  16290. hotelText = "小套房";
  16291. break;
  16292. case "SUITE":
  16293. hotelText = "套房";
  16294. break;
  16295. case "TBR":
  16296. hotelText = "双人间";
  16297. break;
  16298. }
  16299. if (item != "TBR")
  16300. {
  16301. 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";
  16302. }
  16303. else
  16304. {
  16305. 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";
  16306. }
  16307. index++;
  16308. }
  16309. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  16310. }
  16311. }
  16312. index = 1;
  16313. foreach (var item in TzAirDescArr)
  16314. {
  16315. if (AinfoArr != null)
  16316. {
  16317. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  16318. if (Ainfo != null)
  16319. {
  16320. if (int.Parse(Ainfo.rs) <= 0)
  16321. {
  16322. continue;
  16323. }
  16324. 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";
  16325. index++;
  16326. }
  16327. }
  16328. }
  16329. }
  16330. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  16331. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  16332. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  16333. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  16334. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  16335. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  16336. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  16337. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  16338. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  16339. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  16340. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  16341. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  16342. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  16343. DickeyValue.Add("Visa", Visa); // 签证单人报价
  16344. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  16345. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  16346. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  16347. DickeyValue.Add("TzZCost", TzZCost);
  16348. foreach (var key in DickeyValue.Keys)
  16349. {
  16350. if (doc.Range.Bookmarks[key] != null)
  16351. {
  16352. Bookmark mark = doc.Range.Bookmarks[key];
  16353. mark.Text = DickeyValue[key];
  16354. }
  16355. }
  16356. byte[] bytes = null;
  16357. string strFileName = di.TeamName + "-客户报价.doc";
  16358. using (MemoryStream stream = new MemoryStream())
  16359. {
  16360. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  16361. bytes = stream.ToArray();
  16362. }
  16363. return Ok(JsonView(true, "", new
  16364. {
  16365. Data = bytes,
  16366. strFileName,
  16367. }));
  16368. }
  16369. /// <summary>
  16370. /// 团组成本 各模块(酒店,地接,机票)成本提示
  16371. /// </summary>
  16372. /// <param name="dto"></param>
  16373. /// <returns></returns>
  16374. [HttpPost]
  16375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16376. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  16377. {
  16378. try
  16379. {
  16380. #region 参数验证
  16381. if (dto.DiId < 0)
  16382. {
  16383. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  16384. }
  16385. List<int> cTableIds = new List<int>() {
  16386. 76 ,//酒店预订
  16387. 77 ,//行程
  16388. 79 ,//车/导游地接
  16389. 80 ,//签证
  16390. 81 ,//邀请/公务活
  16391. 82 ,//团组客户保险
  16392. 85 ,//机票预订
  16393. 98 ,//其他款项
  16394. 285 ,//收款退还
  16395. 751 ,//酒店早餐
  16396. 1015 // 超支费用
  16397. };
  16398. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  16399. {
  16400. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  16401. }
  16402. #endregion
  16403. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  16404. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  16405. if (_GroupCostParameters.Count <= 0)
  16406. {
  16407. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  16408. }
  16409. if (_GroupCostParameters[0].IsShare == 0)
  16410. {
  16411. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  16412. }
  16413. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16414. //处理date为空问题
  16415. if (_GroupCosts.Count > 0)
  16416. {
  16417. for (int i = 0; i < _GroupCosts.Count; i++)
  16418. {
  16419. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  16420. {
  16421. if (i > 0)
  16422. {
  16423. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  16424. }
  16425. }
  16426. }
  16427. }
  16428. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  16429. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  16430. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  16431. string currCode = "";
  16432. #region currCode 验证
  16433. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  16434. if (isInt)
  16435. {
  16436. var currData = currDatas.Find(it => it.Id == intCurrency);
  16437. if (currData != null)
  16438. {
  16439. currCode = currData.Name;
  16440. }
  16441. }
  16442. else
  16443. {
  16444. currCode = _GroupCostParameters[0].Currency.Trim();
  16445. }
  16446. #endregion
  16447. //op,酒店单段模式存储
  16448. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  16449. {
  16450. CurrencyCode = currCode,
  16451. Rate = _GroupCostParameters[0].Rate,
  16452. CostType = _GroupCostParameters[0].CostType,
  16453. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  16454. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  16455. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  16456. };
  16457. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  16458. if (_GroupCostParameters.Count == 2)
  16459. {
  16460. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  16461. }
  16462. foreach (var item in _GroupCostParameters)
  16463. {
  16464. decimal _rate = 1;
  16465. decimal _rate1 = item.Rate;
  16466. decimal _scale = 1;
  16467. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  16468. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  16469. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  16470. //if (userInfo != null)
  16471. //{
  16472. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  16473. // {
  16474. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  16475. // {
  16476. // _scale = 1.00M;
  16477. // }
  16478. // }
  16479. //}
  16480. #endregion
  16481. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  16482. {
  16483. CurrencyCode = currCode,
  16484. Rate = _rate1,
  16485. CostType = item.CostType,
  16486. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  16487. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  16488. CostTypeNumber = item.CostTypenumber
  16489. };
  16490. if (_GroupCostParameters.Count > 1)
  16491. {
  16492. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  16493. }
  16494. else
  16495. {
  16496. modulePromptInfo.CostTypeNumber = item.LYJRS;
  16497. }
  16498. if (dto.CTable == 79)//
  16499. {
  16500. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  16501. modulePromptInfo.TotalCost = item.DJCB;
  16502. }
  16503. List<string> costTypes = new List<string>() { "A", "B" };
  16504. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  16505. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  16506. if (_GroupCostsDuplicates.Count() == 1)
  16507. {
  16508. _GroupCostsTypeData = _GroupCosts;
  16509. }
  16510. else
  16511. {
  16512. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  16513. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  16514. }
  16515. /*
  16516. * 76 酒店预订
  16517. * 77 行程
  16518. * 79 车/导游地接
  16519. * 80 签证
  16520. * 81 邀请/公务活动
  16521. * 82 团组客户保险
  16522. * 85 机票预订
  16523. * 98 其他款项
  16524. * 285 收款退还
  16525. * 751 酒店早餐
  16526. * 1015 超支费用
  16527. */
  16528. switch (dto.CTable)
  16529. {
  16530. case 76: // 酒店预订
  16531. _ModuleSubPromptInfo.AddRange(
  16532. _GroupCostsTypeData.Select(it => new
  16533. {
  16534. it.DAY,
  16535. it.Date,
  16536. it.ACCON,
  16537. it.ITIN,
  16538. it.SGR,
  16539. it.TBR,
  16540. it.JS_ES,
  16541. it.Suite
  16542. })
  16543. );
  16544. break;
  16545. case 79: // 车/导游地接
  16546. _ModuleSubPromptInfo.AddRange(
  16547. _GroupCostsTypeData.Select(it => new
  16548. {
  16549. Date = it.Date, //日期
  16550. CarFee = it.CarCost * _rate * _scale, //车费用
  16551. CarType = it.CarType, //车型
  16552. DriverFee = it.CFS * _rate * _scale, //司机工资
  16553. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  16554. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  16555. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  16556. GuideFee = it.TGS * _rate * _scale, //导游费用
  16557. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  16558. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  16559. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  16560. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  16561. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  16562. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  16563. Breakfast = it.B * _rate * _scale, //早餐费
  16564. Lunch = it.L * _rate * _scale, //午餐费
  16565. Dinner = it.D * _rate * _scale, //晚餐费
  16566. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  16567. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  16568. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  16569. TicketFee = it.EF * _rate * _scale, //门票费
  16570. TicketRemark = it.EFR, //门票费描述
  16571. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  16572. TravelSupplies = it.TE * _rate * _scale, //出行物资
  16573. SpentCash = it.PC * _rate * _scale, //零用金
  16574. LeadersFee = it.TLF * _rate * _scale, //领队费
  16575. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  16576. })
  16577. );
  16578. break;
  16579. case 85: // 机票
  16580. List<dynamic> datas = new List<dynamic>();
  16581. datas.Add(
  16582. new
  16583. {
  16584. AirType = "经济舱",
  16585. AirNum = item.JJCRS,
  16586. AirDRCB = item.JJCCB,
  16587. AirZCB = (item.JJCRS * item.JJCCB)
  16588. }
  16589. );
  16590. datas.Add(
  16591. new
  16592. {
  16593. AirType = "公务舱",
  16594. AirNum = item.GWCRS,
  16595. AirDRCB = item.GWCCB,
  16596. AirZCB = (item.GWCRS * item.GWCCB)
  16597. }
  16598. );
  16599. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  16600. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  16601. modulePromptInfo.Data = new
  16602. {
  16603. airFeeData = datas,
  16604. airInitData = initDatas
  16605. };
  16606. _ModulePromptInfos.Add(modulePromptInfo);
  16607. break;
  16608. default:
  16609. break;
  16610. }
  16611. }
  16612. if (dto.CTable != 85)
  16613. {
  16614. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  16615. _ModulePromptInfos.Add(_ModulePromptInfo);
  16616. }
  16617. _view.ModulePromptInfos = _ModulePromptInfos;
  16618. return Ok(JsonView(true, "操作成功!", _view));
  16619. }
  16620. catch (Exception ex)
  16621. {
  16622. return Ok(JsonView(false, ex.Message));
  16623. }
  16624. }
  16625. /// <summary>
  16626. /// 根据黑屏代码重新生成行程
  16627. /// </summary>
  16628. /// <param name="dto"></param>
  16629. /// <returns></returns>
  16630. [HttpPost]
  16631. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  16632. {
  16633. var jw = JsonView(false, "Error");
  16634. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  16635. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  16636. .Select(x => new
  16637. {
  16638. x.Id,
  16639. x.Title
  16640. })
  16641. .ToList();
  16642. if (Create.Any())
  16643. {
  16644. jw.Msg = "获取成功!";
  16645. jw.Code = 200;
  16646. jw.Data = new
  16647. {
  16648. BlackCodeListSelect = Create,
  16649. blackCodeIsTrue = true
  16650. };
  16651. }
  16652. else
  16653. {
  16654. jw.Code = 400;
  16655. jw.Data = new
  16656. {
  16657. BlackCodeListSelect = Create,
  16658. blackCodeIsTrue = false,
  16659. };
  16660. }
  16661. return Ok(jw);
  16662. }
  16663. /// <summary>
  16664. /// 根据黑屏代码Id重新生成行程
  16665. /// </summary>
  16666. /// <param name="dto"></param>
  16667. /// <returns></returns>
  16668. [HttpPost]
  16669. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16670. {
  16671. var jw = JsonView(false, "Error");
  16672. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16673. if (result.Code == 0)
  16674. {
  16675. jw.Msg = "获取成功!";
  16676. jw.Code = 200;
  16677. jw.Data = new
  16678. {
  16679. groupCost = result.Data,
  16680. blackCodeIsTrue = true
  16681. };
  16682. }
  16683. else
  16684. {
  16685. jw.Code = 400;
  16686. jw.Data = new
  16687. {
  16688. groupCost = result.Data,
  16689. blackCodeIsTrue = false,
  16690. };
  16691. }
  16692. return Ok(jw);
  16693. }
  16694. /// <summary>
  16695. /// 成本获取OP历史车费用
  16696. /// </summary>
  16697. /// <param name="dto"></param>
  16698. /// <returns></returns>
  16699. [HttpPost]
  16700. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16701. {
  16702. var jw = JsonView(false);
  16703. try
  16704. {
  16705. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16706. //获取现有所有车的数据
  16707. if (!dto.Param.IsNullOrWhiteSpace())
  16708. {
  16709. string sql = $@"
  16710. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16711. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16712. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16713. 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
  16714. AND gctggr.ServiceEndTime is not NULL
  16715. ORDER by gctggrc.id DESC
  16716. ";
  16717. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16718. var numeberResult = await Task.Run(() =>
  16719. {
  16720. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16721. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16722. return numberArr;
  16723. });
  16724. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16725. foreach (var item in numeberResult)
  16726. {
  16727. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16728. {
  16729. Country = "数据异常!",
  16730. City = string.Empty,
  16731. };
  16732. item.Area = find.Country + " " + find.City;
  16733. }
  16734. dbResult.AddRange(numeberResult);
  16735. if (dto.Param.Contains("、"))
  16736. {
  16737. var sp = dto.Param.Split("、");
  16738. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16739. .Where(x =>
  16740. {
  16741. return System.Array.Exists(sp, e =>
  16742. {
  16743. bool where = false;
  16744. if (x.Area != null)
  16745. {
  16746. where = x.Area.Contains(e);
  16747. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16748. {
  16749. return false;
  16750. }
  16751. }
  16752. if (x.PriceName != null && !where)
  16753. {
  16754. where = x.PriceName.Contains(e);
  16755. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16756. {
  16757. return false;
  16758. }
  16759. }
  16760. return where;
  16761. });
  16762. }).ToList();
  16763. }
  16764. else
  16765. {
  16766. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16767. .Where(x =>
  16768. {
  16769. bool where = false;
  16770. if (x.Area != null)
  16771. {
  16772. where = x.Area.Contains(dto.Param);
  16773. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16774. {
  16775. return false;
  16776. }
  16777. }
  16778. if (x.PriceName != null && !where)
  16779. {
  16780. where = x.PriceName.Contains(dto.Param);
  16781. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16782. {
  16783. return false;
  16784. }
  16785. }
  16786. return where;
  16787. }
  16788. )
  16789. .ToList();
  16790. }
  16791. }
  16792. var view = dbResult.Select(x =>
  16793. {
  16794. decimal dp = 0.00M;
  16795. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16796. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16797. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16798. {
  16799. if (startB && endB)
  16800. {
  16801. var timesp = endD.Subtract(startD);
  16802. if ((timesp.Days + 1) != 0)
  16803. {
  16804. dp = x.Price / (timesp.Days + 1);
  16805. }
  16806. }
  16807. }
  16808. else
  16809. {
  16810. dp = x.Price;
  16811. }
  16812. return new
  16813. {
  16814. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16815. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16816. x.Area,
  16817. x.id,
  16818. price = x.Price.ToString("F2"),
  16819. x.PriceName,
  16820. x.PriceContent,
  16821. x.TeamName,
  16822. x.DatePrice,
  16823. dayPrice = dp.ToString("F2"),
  16824. };
  16825. }).OrderByDescending(x => x.id).ToList();
  16826. jw = JsonView(true, "获取成功!", view);
  16827. }
  16828. catch (Exception e)
  16829. {
  16830. jw = JsonView(false, e.Message);
  16831. }
  16832. return Ok(jw);
  16833. }
  16834. [HttpPost]
  16835. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16836. {
  16837. var jw = JsonView(true);
  16838. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16839. #region SQL语句
  16840. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16841. //{
  16842. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16843. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16844. // WHEN COUNT(*) >= 0 THEN 'True'
  16845. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16846. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16847. // ")
  16848. // .ToList();
  16849. //}
  16850. //else
  16851. //{
  16852. // string likeKey = string.Empty;
  16853. // foreach (var item in dto.Keyword)
  16854. // {
  16855. // likeKey += "%" + item;
  16856. // }
  16857. // likeKey += "%";
  16858. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16859. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16860. // WHEN COUNT(*) >= 0 THEN 'True'
  16861. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16862. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16863. // ")
  16864. // .ToList();
  16865. //}
  16866. #endregion
  16867. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16868. {
  16869. @KeyWord = dto.Keyword
  16870. });
  16871. if (table != null && table.Rows.Count > 0)
  16872. {
  16873. foreach (DataRow row in table.Rows)
  16874. {
  16875. matches.Add(new DelegationInfoAndIsTrueView
  16876. {
  16877. Id = row.Field<int>("Id"),
  16878. GroupName = row.Field<string>("GroupName"),
  16879. isTrue = row.Field<string>("isTrue")
  16880. });
  16881. }
  16882. }
  16883. if (matches.Any())
  16884. {
  16885. jw.Data = matches;
  16886. }
  16887. else
  16888. {
  16889. jw.Code = 201;
  16890. jw.Msg = "empty list";
  16891. jw.Data = new List<string>(1);
  16892. }
  16893. return Ok(jw);
  16894. }
  16895. /// <summary>
  16896. /// 报价Word下载
  16897. /// </summary>
  16898. /// <param name="dto"></param>
  16899. /// <returns></returns>
  16900. [HttpPost]
  16901. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16902. {
  16903. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16904. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16905. if (di == null)
  16906. {
  16907. return Ok(JsonView(false, "团组不存在!"));
  16908. }
  16909. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16910. if (mainPrice == null || mainPrice.IsShare == 0)
  16911. {
  16912. return Ok(JsonView(false, "团组成本不存在!"));
  16913. }
  16914. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16915. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16916. if (costTypeHotelNumbers == null)
  16917. {
  16918. return Ok(JsonView(false, "团组成本不存在!"));
  16919. }
  16920. //文件名
  16921. string strFileName = di.TeamName + "-收款账单.doc";
  16922. //获取模板
  16923. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16924. //载入模板
  16925. Document doc = new Document(tmppath);
  16926. decimal allPrice = 0.00M;
  16927. string itemStr = string.Empty;
  16928. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16929. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16930. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16931. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16932. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16933. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16934. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16935. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16936. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16937. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16938. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16939. {
  16940. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16941. ("BXRS", "BXCB", "BXXS", "bx"),
  16942. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16943. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16944. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16945. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16946. ("CPRS", "CPCB", "CPXS", "cp"),
  16947. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16948. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16949. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16950. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16951. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16952. ("DJRS", "DJCB", "DJXS", "dj"),
  16953. ("GWRS", "GWCB", "GWXS", "gw"),
  16954. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16955. };
  16956. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16957. var rightSum = 0.00M;
  16958. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16959. {
  16960. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16961. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16962. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16963. if (prefix == "tbr")
  16964. {
  16965. rsValue *= 2;
  16966. cbValue /= 2;
  16967. }
  16968. if (OtherCostPropertyBJ.Contains(prefix))
  16969. {
  16970. rightSum += cbValue * xsValue;
  16971. }
  16972. }
  16973. var hotelRooms = new Dictionary<string, int>
  16974. {
  16975. { "SGR", costTypeHotelNumbers.SGR },
  16976. { "TBR", costTypeHotelNumbers.TBR },
  16977. { "JSES", costTypeHotelNumbers.JSES },
  16978. { "SUITE", costTypeHotelNumbers.SUITE }
  16979. };
  16980. var flights = new Dictionary<string, int>
  16981. {
  16982. { "经济舱", mainPrice.JJCRS },
  16983. { "公务舱", mainPrice.GWCRS },
  16984. { "头等舱", mainPrice.TDCRS }
  16985. };
  16986. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16987. {
  16988. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16989. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16990. { "头等舱", new[] { "SUITE", "JSES" } }
  16991. };
  16992. var result = new Dictionary<string, int>();
  16993. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16994. foreach (var flight in flights.Keys)
  16995. {
  16996. // 获取当前舱位的匹配规则
  16997. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16998. {
  16999. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17000. }
  17001. }
  17002. #region right计算
  17003. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17004. {
  17005. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17006. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17007. airHotelPriceList.Add(new
  17008. AirHotelPrice
  17009. {
  17010. Name = "经济舱TBR",
  17011. Price = rightSum + air + hotel,
  17012. Count = result["经济舱TBR"] * 2
  17013. });
  17014. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17015. }
  17016. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17017. {
  17018. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17019. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17020. airHotelPriceList.Add(new
  17021. AirHotelPrice
  17022. {
  17023. Name = "经济舱SGR",
  17024. Price = rightSum + air + hotel,
  17025. Count = result["经济舱SGR"]
  17026. });
  17027. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17028. }
  17029. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17030. {
  17031. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17032. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17033. airHotelPriceList.Add(new
  17034. AirHotelPrice
  17035. {
  17036. Name = "公务舱SGR",
  17037. Price = rightSum + air + hotel,
  17038. Count = result["公务舱SGR"]
  17039. });
  17040. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17041. }
  17042. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17043. {
  17044. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17045. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17046. airHotelPriceList.Add(new
  17047. AirHotelPrice
  17048. {
  17049. Name = "公务舱JSES",
  17050. Price = rightSum + air + hotel,
  17051. Count = result["公务舱JSES"]
  17052. });
  17053. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17054. }
  17055. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17056. {
  17057. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17058. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17059. airHotelPriceList.Add(new
  17060. AirHotelPrice
  17061. {
  17062. Name = "公务舱SUITE",
  17063. Price = rightSum + air + hotel,
  17064. Count = result["公务舱SUITE"]
  17065. });
  17066. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17067. }
  17068. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17069. {
  17070. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17071. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17072. airHotelPriceList.Add(new
  17073. AirHotelPrice
  17074. {
  17075. Name = "经济舱SUITE",
  17076. Price = rightSum + air + hotel,
  17077. Count = result["经济舱SUITE"]
  17078. });
  17079. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17080. }
  17081. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17082. {
  17083. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17084. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17085. airHotelPriceList.Add(new
  17086. AirHotelPrice
  17087. {
  17088. Name = "头等舱JSES",
  17089. Price = rightSum + air + hotel,
  17090. Count = result["头等舱JSES"]
  17091. });
  17092. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17093. }
  17094. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17095. {
  17096. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17097. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17098. airHotelPriceList.Add(new
  17099. AirHotelPrice
  17100. {
  17101. Name = "头等舱SUITE",
  17102. Price = rightSum + air + hotel,
  17103. Count = result["头等舱SUITE"]
  17104. });
  17105. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17106. }
  17107. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17108. {
  17109. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17110. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17111. airHotelPriceList.Add(new
  17112. AirHotelPrice
  17113. {
  17114. Name = "经济舱JSES",
  17115. Price = rightSum + air + hotel,
  17116. Count = result["经济舱JSES"]
  17117. });
  17118. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17119. }
  17120. #endregion
  17121. foreach (var item in airSouer.Keys)
  17122. {
  17123. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17124. if (find != null && find.Count > 0)
  17125. {
  17126. if (item.Contains("TBR"))
  17127. {
  17128. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17129. }
  17130. else
  17131. {
  17132. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17133. }
  17134. }
  17135. }
  17136. #region 替换Word模板书签内容
  17137. Dictionary<string, string> marks = new Dictionary<string, string>();
  17138. marks.Add("To", di.ClientUnit);//付款方
  17139. marks.Add("ToTel", di.TellPhone);//付款方电话
  17140. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17141. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17142. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17143. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17144. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17145. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17146. marks.Add("PayItemContent", itemStr);//详细信息
  17147. marks.Add("Total", allPrice.ToString("F2"));//合计
  17148. #endregion
  17149. foreach (var item in marks.Keys)
  17150. {
  17151. if (doc.Range.Bookmarks[item] != null)
  17152. {
  17153. Bookmark mark = doc.Range.Bookmarks[item];
  17154. mark.Text = marks[item];
  17155. }
  17156. }
  17157. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17158. doc.Save(savePaht);
  17159. var jw = new JsonView();
  17160. jw.Msg = "生成成功!";
  17161. jw.Code = 200;
  17162. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17163. return Ok(jw);
  17164. }
  17165. /// <summary>
  17166. /// 详细报价费用Excel下载
  17167. /// </summary>
  17168. /// <param name="dto"></param>
  17169. /// <returns></returns>
  17170. [HttpPost]
  17171. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17172. {
  17173. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17174. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17175. if (di == null)
  17176. {
  17177. return Ok(JsonView(false, "团组不存在!"));
  17178. }
  17179. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17180. if (mainPrice == null || mainPrice.IsShare == 0)
  17181. {
  17182. return Ok(JsonView(false, "团组成本不存在!"));
  17183. }
  17184. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17185. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17186. if (costTypeHotelNumbers == null)
  17187. {
  17188. return Ok(JsonView(false, "团组成本不存在!"));
  17189. }
  17190. WorkbookDesigner designer = new WorkbookDesigner();
  17191. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  17192. List<int> hideRowsList = new List<int>();
  17193. int conterStartIndex = 3;
  17194. int rowIndex = conterStartIndex;
  17195. designer.SetDataSource("GroupName", di.TeamName);
  17196. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17197. {
  17198. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17199. ("BXRS", "BXCB", "BXXS", "bx"),
  17200. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17201. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17202. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  17203. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  17204. ("CPRS", "CPCB", "CPXS", "cp") ,
  17205. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  17206. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  17207. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  17208. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  17209. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  17210. ("DJRS", "DJCB", "DJXS", "dj") ,
  17211. ("GWRS", "GWCB", "GWXS", "gw") ,
  17212. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  17213. };
  17214. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17215. var rightSum = 0.00M;
  17216. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17217. {
  17218. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17219. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17220. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17221. if (prefix == "tbr")
  17222. {
  17223. rsValue *= 2;
  17224. cbValue /= 2;
  17225. }
  17226. if (OtherCostPropertyBJ.Contains(prefix))
  17227. {
  17228. rightSum += cbValue * xsValue;
  17229. }
  17230. if (rsValue == 0)
  17231. {
  17232. hideRowsList.Add(rowIndex);
  17233. }
  17234. else
  17235. {
  17236. designer.SetDataSource($"{prefix}rs", rsValue);
  17237. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  17238. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  17239. }
  17240. rowIndex += 2;
  17241. }
  17242. var hotelRooms = new Dictionary<string, int>
  17243. {
  17244. { "SGR", costTypeHotelNumbers.SGR },
  17245. { "TBR", costTypeHotelNumbers.TBR },
  17246. { "JSES", costTypeHotelNumbers.JSES },
  17247. { "SUITE", costTypeHotelNumbers.SUITE }
  17248. };
  17249. var flights = new Dictionary<string, int>
  17250. {
  17251. { "经济舱", mainPrice.JJCRS },
  17252. { "公务舱", mainPrice.GWCRS },
  17253. { "头等舱", mainPrice.TDCRS }
  17254. };
  17255. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17256. {
  17257. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17258. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17259. { "头等舱", new[] { "SUITE", "JSES" } }
  17260. };
  17261. var result = new Dictionary<string, int>();
  17262. foreach (var flight in flights.Keys)
  17263. {
  17264. // 获取当前舱位的匹配规则
  17265. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17266. {
  17267. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17268. }
  17269. }
  17270. var allPrice = 0.00M;
  17271. #region right计算
  17272. int airRowIndex = 35;
  17273. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17274. {
  17275. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17276. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17277. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  17278. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  17279. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  17280. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17281. }
  17282. else
  17283. {
  17284. hideRowsList.Add(airRowIndex);
  17285. }
  17286. airRowIndex += 2;
  17287. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17288. {
  17289. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17290. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17291. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  17292. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  17293. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  17294. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17295. }
  17296. else
  17297. {
  17298. hideRowsList.Add(airRowIndex);
  17299. }
  17300. airRowIndex += 2;
  17301. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17302. {
  17303. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17304. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17305. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  17306. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  17307. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  17308. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17309. }
  17310. else
  17311. {
  17312. hideRowsList.Add(airRowIndex);
  17313. }
  17314. airRowIndex += 2;
  17315. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17316. {
  17317. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17318. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17319. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  17320. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  17321. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  17322. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17323. }
  17324. else
  17325. {
  17326. hideRowsList.Add(airRowIndex);
  17327. }
  17328. airRowIndex += 2;
  17329. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17330. {
  17331. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17332. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17333. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  17334. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  17335. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  17336. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17337. }
  17338. else
  17339. {
  17340. hideRowsList.Add(airRowIndex);
  17341. }
  17342. airRowIndex += 2;
  17343. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17344. {
  17345. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17346. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17347. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  17348. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  17349. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  17350. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17351. }
  17352. else
  17353. {
  17354. hideRowsList.Add(airRowIndex);
  17355. }
  17356. airRowIndex += 2;
  17357. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17358. {
  17359. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17360. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17361. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  17362. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  17363. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  17364. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17365. }
  17366. else
  17367. {
  17368. hideRowsList.Add(airRowIndex);
  17369. }
  17370. airRowIndex += 2;
  17371. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17372. {
  17373. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17374. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17375. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  17376. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  17377. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  17378. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17379. }
  17380. else
  17381. {
  17382. hideRowsList.Add(airRowIndex);
  17383. }
  17384. airRowIndex += 2;
  17385. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17386. {
  17387. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17388. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17389. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  17390. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  17391. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  17392. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17393. }
  17394. else
  17395. {
  17396. hideRowsList.Add(airRowIndex);
  17397. }
  17398. #endregion
  17399. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  17400. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  17401. var ws = designer.Workbook.Worksheets[0];
  17402. foreach (var Rowindex in hideRowsList)
  17403. {
  17404. ws.Cells.HideRows(Rowindex, 2);
  17405. }
  17406. designer.Process();
  17407. designer.Workbook.Save(savePaht);
  17408. return Ok(JsonView(true, "生成成功!", new
  17409. {
  17410. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  17411. }));
  17412. }
  17413. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  17414. {
  17415. foreach (var roomType in roomTypes)
  17416. {
  17417. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  17418. {
  17419. hotelRooms[roomType]--;
  17420. flights[flightType]--;
  17421. if (roomType == "TBR")
  17422. {
  17423. flights[flightType]--; // 双人间在减少1
  17424. }
  17425. string key = flightType + roomType;
  17426. if (result.Keys.Contains(key))
  17427. {
  17428. result[key]++;
  17429. }
  17430. else
  17431. {
  17432. result.Add(key, 1);
  17433. }
  17434. }
  17435. }
  17436. }
  17437. private class AirHotelPrice
  17438. {
  17439. public string Name { get; set; }
  17440. public decimal Price { get; set; }
  17441. public int Count { get; set; }
  17442. }
  17443. /// <summary>
  17444. /// 团组系数设置
  17445. /// </summary>
  17446. /// <param name="dto"></param>
  17447. /// <returns></returns>
  17448. [HttpPost]
  17449. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  17450. {
  17451. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17452. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17453. if (di == null)
  17454. {
  17455. return Ok(JsonView(false, "团组不存在!"));
  17456. }
  17457. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  17458. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  17459. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  17460. // FirstAsync(firstExpression.ToExpression());
  17461. #region JSON
  17462. string hcpJson = @"
  17463. [
  17464. {
  17465. ""min"": 1,
  17466. ""max"": 500,
  17467. ""value"": 1.50
  17468. },
  17469. {
  17470. ""min"": 501,
  17471. ""max"": 1000,
  17472. ""value"": 1.40
  17473. },
  17474. {
  17475. ""min"": 1001,
  17476. ""max"": 2000,
  17477. ""value"": 1.35
  17478. }
  17479. ]";
  17480. #endregion
  17481. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  17482. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  17483. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  17484. .ToList();
  17485. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  17486. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  17487. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  17488. // new List<(Predicate<decimal>, decimal)>()
  17489. // {
  17490. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  17491. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  17492. // }
  17493. // ));
  17494. #region 签证系数
  17495. var visaXS = 0.00M;
  17496. switch (dto.VisaCB)
  17497. {
  17498. case decimal n when (n > 1 && n < 500):
  17499. switch (dto.VisaRS)
  17500. {
  17501. case 2 or 3:
  17502. visaXS = 1.35M;
  17503. break;
  17504. case 4 or 5:
  17505. visaXS = 1.30M;
  17506. break;
  17507. case 6 or 7:
  17508. visaXS = 1.25M;
  17509. break;
  17510. case 8 or 9 or 10:
  17511. visaXS = 1.20M;
  17512. break;
  17513. case > 10:
  17514. visaXS = 1.15M;
  17515. break;
  17516. default:
  17517. visaXS = 0.00M;
  17518. break;
  17519. }
  17520. break;
  17521. case decimal n when (n >= 500 && n < 1000):
  17522. switch (dto.VisaRS)
  17523. {
  17524. case 2 or 3 or 4:
  17525. visaXS = 1.30M;
  17526. break;
  17527. case 5 or 6 or 7 or 8:
  17528. visaXS = 1.25M;
  17529. break;
  17530. case 9 or 10:
  17531. visaXS = 1.20M;
  17532. break;
  17533. case > 10:
  17534. visaXS = 1.15M;
  17535. break;
  17536. default:
  17537. visaXS = 0.00M;
  17538. break;
  17539. }
  17540. break;
  17541. default:
  17542. switch (dto.VisaRS)
  17543. {
  17544. case 2 or 3 or 4:
  17545. visaXS = 1.30M;
  17546. break;
  17547. case 5 or 6 or 7 or 8:
  17548. visaXS = 1.25M;
  17549. break;
  17550. case 9 or 10:
  17551. visaXS = 1.20M;
  17552. break;
  17553. case > 10:
  17554. visaXS = 1.15M;
  17555. break;
  17556. default:
  17557. visaXS = 0.00M;
  17558. break;
  17559. }
  17560. break;
  17561. }
  17562. #endregion
  17563. #region 火车系数
  17564. var hcpXS = 0.00M;
  17565. foreach (var (condition, result) in hcpSwitchDictionary)
  17566. {
  17567. if (condition(dto.HCPCB))
  17568. {
  17569. hcpXS = result;
  17570. break;
  17571. }
  17572. }
  17573. #endregion
  17574. #region 机票系数
  17575. #region 经济舱系数
  17576. var jjcXS = 0.00M;
  17577. switch (dto.JJCCB)
  17578. {
  17579. case decimal x when (x >= 1000 && x <= 3000):
  17580. jjcXS = 2.6M;
  17581. break;
  17582. case decimal x when (x >= 3001 && x <= 8000):
  17583. jjcXS = 2.3M;
  17584. break;
  17585. case decimal x when (x >= 8001 && x <= 15000):
  17586. jjcXS = 2.1M;
  17587. break;
  17588. case decimal x when (x >= 15001 && x <= 30000):
  17589. jjcXS = 1.95M;
  17590. break;
  17591. case > 30000:
  17592. jjcXS = 1.8M;
  17593. break;
  17594. default:
  17595. break;
  17596. }
  17597. #endregion
  17598. #region 公务舱系数
  17599. var gwcXS = 0.00M;
  17600. switch (dto.GWCCB)
  17601. {
  17602. case decimal x when (x >= 1000 && x <= 3000):
  17603. gwcXS = 2.5M;
  17604. break;
  17605. case decimal x when (x >= 3001 && x <= 8000):
  17606. gwcXS = 2.2M;
  17607. break;
  17608. case decimal x when (x >= 8001 && x <= 15000):
  17609. gwcXS = 2.0M;
  17610. break;
  17611. case decimal x when (x >= 15001 && x <= 30000):
  17612. gwcXS = 1.85M;
  17613. break;
  17614. case > 30000:
  17615. gwcXS = 1.7M;
  17616. break;
  17617. default:
  17618. break;
  17619. }
  17620. #endregion
  17621. #region 头等舱系数
  17622. var tdcXS = 0.00M;
  17623. switch (dto.TDCCB)
  17624. {
  17625. case > 70000:
  17626. tdcXS = 1.5M;
  17627. break;
  17628. default:
  17629. tdcXS = 1.9M;
  17630. break;
  17631. }
  17632. #endregion
  17633. #endregion
  17634. #region 酒店系数
  17635. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  17636. {
  17637. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  17638. {1.5M, new List<string>(){"越南社会主义共和国",
  17639. "老挝",
  17640. "柬埔寨",
  17641. "泰国",
  17642. "缅甸",
  17643. "马来西亚",
  17644. //"新加坡",
  17645. "文莱达鲁萨兰",
  17646. "印度尼西亚",
  17647. "东帝汶"}},
  17648. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  17649. };
  17650. #region SGR
  17651. var sgrXS = 1.25M;
  17652. #endregion
  17653. #region TBR
  17654. var tbrXS = 1.25M;
  17655. #endregion
  17656. #region JSES
  17657. var jsesXS = 1.25M;
  17658. #endregion
  17659. #region SUITE
  17660. var suiteXS = 1.25M;
  17661. #endregion
  17662. var countryArr = di.VisitCountry.Split("|");
  17663. foreach (var item in dic)
  17664. {
  17665. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  17666. .Count();
  17667. if (extsisCount > 0)
  17668. {
  17669. jsesXS = item.Key;
  17670. sgrXS = item.Key;
  17671. tbrXS = item.Key;
  17672. suiteXS = item.Key;
  17673. }
  17674. }
  17675. #endregion
  17676. #region 地接系数
  17677. var djXS = 0.00M;
  17678. switch (dto.DJRS)
  17679. {
  17680. case 2 or 3:
  17681. djXS = 2.65M;
  17682. break;
  17683. case 4:
  17684. djXS = 2.6M;
  17685. break;
  17686. case 5 or 6:
  17687. djXS = 2.5M;
  17688. break;
  17689. case 7 or 8:
  17690. djXS = 2.4M;
  17691. break;
  17692. case 9 or 10:
  17693. djXS = 2.3M;
  17694. break;
  17695. case 11:
  17696. djXS = 2.2M;
  17697. break;
  17698. case 12:
  17699. djXS = 2.1M;
  17700. break;
  17701. case 13 or 14:
  17702. djXS = 2M;
  17703. break;
  17704. case 15:
  17705. djXS = 1.9M;
  17706. break;
  17707. case 16 or 17 or 18:
  17708. djXS = 1.8M;
  17709. break;
  17710. case 19 or 20:
  17711. djXS = 1.7M;
  17712. break;
  17713. }
  17714. #endregion
  17715. #region 零用金系数
  17716. var lyjXS = 0.00M;
  17717. switch (dto.LYJRS)
  17718. {
  17719. case 2:
  17720. lyjXS = 1.25M;
  17721. break;
  17722. case 3 or 4 or 5:
  17723. lyjXS = 1.2M;
  17724. break;
  17725. case int number when (number > 5 && number < 10):
  17726. lyjXS = 1.15M;
  17727. break;
  17728. case > 10:
  17729. lyjXS = 1.1M;
  17730. break;
  17731. default:
  17732. break;
  17733. }
  17734. #endregion
  17735. return Ok(JsonView(true, "查询成功", new ArrayList()
  17736. {
  17737. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  17738. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  17739. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  17740. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  17741. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  17742. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  17743. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  17744. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  17745. new { label = "地接系数", value = djXS, key = "djXS" },
  17746. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  17747. new { label = "公务系数", value = 2M, key = "gwXS" }
  17748. }));
  17749. }
  17750. #endregion
  17751. #region 酒店预订 New 2023-12-28 17:45
  17752. /// <summary>
  17753. /// 酒店预订
  17754. /// 酒店费用列表 根据团组Id查询
  17755. /// </summary>
  17756. /// <param name="_dto"></param>
  17757. /// <returns></returns>
  17758. [HttpPost]
  17759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17760. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  17761. {
  17762. #region 参数验证
  17763. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17764. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17765. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17766. #region 团组操作权限验证 76 酒店预定模块
  17767. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17768. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17769. #endregion
  17770. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17771. #region 页面操作权限验证
  17772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17773. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17774. #endregion
  17775. #endregion
  17776. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  17777. }
  17778. /// <summary>
  17779. /// 酒店预订
  17780. /// 基础数据
  17781. /// </summary>
  17782. /// <param name="_dto"></param>
  17783. /// <returns></returns>
  17784. [HttpPost]
  17785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17786. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  17787. {
  17788. #region 参数验证
  17789. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17790. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17791. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17792. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17793. #region 页面操作权限验证
  17794. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17795. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17796. #endregion
  17797. #region 团组操作权限验证 76 酒店预定模块
  17798. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17799. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17800. #endregion
  17801. #endregion
  17802. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  17803. }
  17804. /// <summary>
  17805. /// 酒店预订
  17806. /// 创建 入住卷号码
  17807. /// </summary>
  17808. /// <param name="_dto"></param>
  17809. /// <returns></returns>
  17810. [HttpPost]
  17811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17812. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  17813. {
  17814. #region 参数验证
  17815. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17816. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17817. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17819. #region 页面操作权限验证
  17820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17822. #endregion
  17823. #region 团组操作权限验证 76 酒店预定模块
  17824. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17825. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17826. #endregion
  17827. #endregion
  17828. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  17829. if (data.Code != 0)
  17830. {
  17831. return Ok(JsonView(false, data.Msg));
  17832. }
  17833. return Ok(JsonView(true, data.Msg, data.Data));
  17834. }
  17835. /// <summary>
  17836. /// 酒店预订
  17837. /// 详情
  17838. /// </summary>
  17839. /// <param name="_dto"></param>
  17840. /// <returns></returns>
  17841. [HttpPost]
  17842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17843. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  17844. {
  17845. #region 参数验证
  17846. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  17847. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17848. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  17849. #region 团组操作权限验证 76 酒店预定模块
  17850. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17851. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17852. #endregion
  17853. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17854. #region 页面操作权限验证
  17855. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17856. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17857. #endregion
  17858. #endregion
  17859. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  17860. }
  17861. /// <summary>
  17862. /// 酒店预订
  17863. /// Add Or Edit
  17864. /// </summary>
  17865. /// <param name="_dto"></param>
  17866. /// <returns></returns>
  17867. [HttpPost]
  17868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17869. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  17870. {
  17871. #region 参数验证
  17872. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17873. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17874. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17875. #region 团组操作权限验证 76 酒店预定模块
  17876. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17877. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17878. #endregion
  17879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17880. #region 页面操作权限验证
  17881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17882. if (_dto.Id == 0) // Add
  17883. {
  17884. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17885. }
  17886. else if (_dto.Id > 1) // Edit
  17887. {
  17888. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17889. }
  17890. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  17891. #endregion
  17892. #endregion
  17893. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  17894. if (_view.Code != 200)
  17895. {
  17896. return Ok(_view);
  17897. }
  17898. #region 成本无酒店价格数据进入超支
  17899. _sqlSugar.BeginTran();
  17900. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  17901. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  17902. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  17903. for (int i = 0; i < groupCost.Count; i++)
  17904. {
  17905. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  17906. {
  17907. groupCost[i].Date = groupCost[i - 1].Date;
  17908. }
  17909. }
  17910. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  17911. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  17912. List<Fin_GroupExtraCostDto_OP>();
  17913. if (start_Bool && end_Bool)
  17914. {
  17915. while (start_Time < end_Time)
  17916. {
  17917. foreach (var item in groupCost_Grp)
  17918. {
  17919. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17920. {
  17921. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17922. {
  17923. extraCostList.Add(new
  17924. Fin_GroupExtraCostDto_OP
  17925. {
  17926. Area = _dto.AreaId,
  17927. coefficient = 1.5M,
  17928. createUser = _dto.UserId,
  17929. currency = _dto.CardPriceCurrency,
  17930. diId = _dto.DiId,
  17931. ManagerConfirm = 0,
  17932. SupervisorConfirm = 0,
  17933. SYsupervisorConfirm = 0,
  17934. editType = 1,
  17935. PortType = 1,
  17936. price = _dto.CardPrice,
  17937. PriceCount = 1,
  17938. priceType = 1027,
  17939. priceDetailType = 1044,
  17940. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17941. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17942. });
  17943. }
  17944. }
  17945. }
  17946. start_Time = start_Time.AddDays(1);
  17947. }
  17948. }
  17949. if (extraCostList.Any())
  17950. {
  17951. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17952. }
  17953. _sqlSugar.CommitTran();
  17954. #endregion
  17955. #region 应用推送
  17956. try
  17957. {
  17958. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17959. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17960. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17961. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17962. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17963. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17964. var diId = _dto.DiId;
  17965. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17966. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17967. #region 操作记录
  17968. var opInfo = new Crm_TableOperationRecord()
  17969. {
  17970. TableName = "Grp_HotelReservations",
  17971. PortType = _dto.PortType,
  17972. DataId = hotelId,
  17973. CreateUserId = _dto.UserId
  17974. };
  17975. //var opStatus = OperationEnum.NoOperation;
  17976. if (_dto.Id < 1) //添加操作
  17977. {
  17978. opInfo.OperationItem = OperationEnum.Add;
  17979. }
  17980. else if (_dto.Id > 0)
  17981. {
  17982. opInfo.OperationItem = OperationEnum.Edit;
  17983. }
  17984. string opRemark = string.Empty;
  17985. if (ccpInfo != null)
  17986. {
  17987. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17988. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17989. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17990. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17991. }
  17992. opInfo.Remark = opRemark;
  17993. await _tableorRep.AddAsync(opInfo);
  17994. #endregion
  17995. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17996. //2024-10-21 新增LZ UID
  17997. var userIds = new List<int>() { 21 };
  17998. string title = $"费用审核";
  17999. string content = "";
  18000. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18001. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18002. try
  18003. {
  18004. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18005. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18006. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18007. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18008. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18009. }
  18010. catch (Exception ex)
  18011. {
  18012. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18013. }
  18014. }
  18015. catch (Exception ex)
  18016. {
  18017. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18018. }
  18019. try
  18020. {
  18021. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18022. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18023. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18024. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18025. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18026. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18027. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18028. //自动审核
  18029. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18030. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18031. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18032. //2024-10-21 新增LZ UID
  18033. var userIds = new List<int>() { 21 };
  18034. string title = $"系统通知";
  18035. var diId = _dto.DiId;
  18036. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18037. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18038. string content = "";
  18039. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18040. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18041. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18042. }
  18043. catch (Exception ex)
  18044. {
  18045. }
  18046. #endregion
  18047. return Ok(_view);
  18048. }
  18049. /// <summary>
  18050. /// 酒店自动审核测试
  18051. /// Add Or Edit
  18052. /// </summary>
  18053. /// <param name="diid"></param>
  18054. /// <param name="dataId"></param>
  18055. /// <returns></returns>
  18056. [HttpPost]
  18057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18058. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18059. {
  18060. #region 应用推送
  18061. try
  18062. {
  18063. //自动审核
  18064. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18065. }
  18066. catch (Exception ex)
  18067. {
  18068. return Ok(JsonView(false, ex.Message));
  18069. }
  18070. #endregion
  18071. return Ok(JsonView(false, "操作成功"));
  18072. }
  18073. /// <summary>
  18074. /// 酒店预订
  18075. /// Del
  18076. /// </summary>
  18077. /// <param name="_dto"></param>
  18078. /// <returns></returns>
  18079. [HttpPost]
  18080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18081. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18082. {
  18083. #region 参数验证
  18084. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18085. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18086. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18087. #region 团组操作权限验证 76 酒店预定模块
  18088. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18089. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18090. #endregion
  18091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18092. #region 页面操作权限验证
  18093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18094. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18095. #endregion
  18096. #endregion
  18097. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18098. #region 操作记录
  18099. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18100. {
  18101. TableName = "Grp_HotelReservations",
  18102. PortType = _dto.PortType,
  18103. OperationItem = OperationEnum.Del,
  18104. DataId = _dto.Id,
  18105. CreateUserId = _dto.UserId
  18106. });
  18107. #endregion
  18108. return Ok(data);
  18109. }
  18110. /// <summary>
  18111. /// 酒店预订
  18112. /// 生成VOUCHER
  18113. /// 2024.05.06 之前版本
  18114. /// </summary>
  18115. /// <param name="_dto"></param>
  18116. /// <returns></returns>
  18117. [HttpPost]
  18118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18119. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18120. {
  18121. try
  18122. {
  18123. #region 参数验证
  18124. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18125. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18126. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18127. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18128. #region 团组操作权限验证 76 酒店预定模块
  18129. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18130. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18131. #endregion
  18132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18133. #region 页面操作权限验证
  18134. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18135. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18136. #endregion
  18137. #endregion
  18138. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18139. //判断数据是否完整
  18140. if (hr != null)
  18141. {
  18142. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18143. {
  18144. string strFileName = "HotelStatement/";
  18145. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18146. if (dele != null)
  18147. strFileName += dele.TourCode;
  18148. //载入模板
  18149. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18150. Document doc = new Document(sss);
  18151. DocumentBuilder builder = new DocumentBuilder(doc);
  18152. #region 替换Word模板书签内容
  18153. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18154. //入住卷预定号码
  18155. if (doc.Range.Bookmarks["VNO"] != null)
  18156. {
  18157. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18158. mark.Text = hr.CheckNumber;
  18159. }
  18160. //酒店时间
  18161. if (doc.Range.Bookmarks["Date"] != null)
  18162. {
  18163. Bookmark mark = doc.Range.Bookmarks["Date"];
  18164. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18165. }
  18166. //团号
  18167. if (doc.Range.Bookmarks["TNo"] != null)
  18168. {
  18169. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18170. mark.Text = dele.TourCode;
  18171. }
  18172. //预定号码
  18173. if (doc.Range.Bookmarks["BookingId"] != null)
  18174. {
  18175. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  18176. mark.Text = hr.ReservationsNo;
  18177. }
  18178. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  18179. {
  18180. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  18181. mark.Text = hr.DetermineNo;
  18182. }
  18183. //酒店城市
  18184. if (doc.Range.Bookmarks["City"] != null)
  18185. {
  18186. Bookmark mark = doc.Range.Bookmarks["City"];
  18187. mark.Text = hr.City;
  18188. }
  18189. //酒店名称
  18190. if (doc.Range.Bookmarks["HName"] != null)
  18191. {
  18192. Bookmark mark = doc.Range.Bookmarks["HName"];
  18193. mark.Text = hr.HotelName;
  18194. }
  18195. //酒店地址
  18196. if (doc.Range.Bookmarks["Address"] != null)
  18197. {
  18198. Bookmark mark = doc.Range.Bookmarks["Address"];
  18199. mark.Text = hr.HotelAddress;
  18200. }
  18201. //酒店电话
  18202. if (doc.Range.Bookmarks["Tel"] != null)
  18203. {
  18204. Bookmark mark = doc.Range.Bookmarks["Tel"];
  18205. mark.Text = hr.HotelTel;
  18206. }
  18207. //酒店传真
  18208. if (doc.Range.Bookmarks["Fax"] != null)
  18209. {
  18210. Bookmark mark = doc.Range.Bookmarks["Fax"];
  18211. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  18212. {
  18213. mark.Text = hr.HotelFax;
  18214. }
  18215. }
  18216. //入住时间
  18217. if (doc.Range.Bookmarks["CIn"] != null)
  18218. {
  18219. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18220. Bookmark mark = doc.Range.Bookmarks["CIn"];
  18221. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  18222. }
  18223. //退房时间
  18224. if (doc.Range.Bookmarks["COut"] != null)
  18225. {
  18226. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18227. Bookmark mark = doc.Range.Bookmarks["COut"];
  18228. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18229. }
  18230. //客户名称
  18231. if (doc.Range.Bookmarks["GName"] != null)
  18232. {
  18233. string guestName = "";
  18234. string[] clients = Array.Empty<string>();
  18235. if (hr.GuestName.Contains(","))
  18236. {
  18237. clients = hr.GuestName.Split(",");
  18238. }
  18239. else
  18240. {
  18241. clients = new string[] { hr.GuestName };
  18242. }
  18243. List<int> clientIds_int = new List<int>();
  18244. if (clients.Length > 0)
  18245. {
  18246. foreach (var item in clients)
  18247. {
  18248. if (item.IsNumeric())
  18249. {
  18250. clientIds_int.Add(int.Parse(item));
  18251. }
  18252. }
  18253. }
  18254. if (clientIds_int.Count > 0)
  18255. {
  18256. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  18257. foreach (var client in _clientDatas)
  18258. {
  18259. //男
  18260. if (client.Sex == 0) guestName += $"Mr.";
  18261. //女
  18262. else if (client.Sex == 1) guestName += $"Ms.";
  18263. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  18264. {
  18265. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  18266. }
  18267. //guestName += $"{client.Pinyin},";
  18268. }
  18269. if (guestName.Length > 0)
  18270. {
  18271. guestName = guestName.Substring(0, guestName.Length - 1);
  18272. }
  18273. }
  18274. else
  18275. {
  18276. guestName = hr.GuestName;
  18277. }
  18278. Bookmark mark = doc.Range.Bookmarks["GName"];
  18279. mark.Text = guestName;
  18280. }
  18281. //房间介绍
  18282. if (doc.Range.Bookmarks["ROOM"] != null)
  18283. {
  18284. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  18285. mark.Text = hr.RoomExplanation;
  18286. }
  18287. //报价描述
  18288. if (doc.Range.Bookmarks["NOTE"] != null)
  18289. {
  18290. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  18291. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  18292. if (ss != null)
  18293. mark.Text = ss.Name;
  18294. }
  18295. //入住时间
  18296. if (doc.Range.Bookmarks["CheckIn"] != null)
  18297. {
  18298. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  18299. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  18300. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18301. }
  18302. //退房时间
  18303. if (doc.Range.Bookmarks["CheckOut"] != null)
  18304. {
  18305. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  18306. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  18307. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  18308. }
  18309. //日期
  18310. if (doc.Range.Bookmarks["DT"] != null)
  18311. {
  18312. Bookmark mark = doc.Range.Bookmarks["DT"];
  18313. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18314. }
  18315. //名称
  18316. if (doc.Range.Bookmarks["VName"] != null)
  18317. {
  18318. Bookmark mark = doc.Range.Bookmarks["VName"];
  18319. mark.Text = hr.HotelName;
  18320. }
  18321. //号码
  18322. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  18323. {
  18324. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  18325. mark.Text = hr.CheckNumber;
  18326. }
  18327. #endregion
  18328. strFileName += "VOUCHER.doc";
  18329. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18330. doc.Save(fileDir);
  18331. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18332. return Ok(JsonView(true, "操作成功!", Url));
  18333. }
  18334. else
  18335. {
  18336. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  18337. }
  18338. }
  18339. else
  18340. {
  18341. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  18342. }
  18343. }
  18344. catch (Exception ex)
  18345. {
  18346. return Ok(JsonView(false, ex.Message));
  18347. }
  18348. }
  18349. /// <summary>
  18350. /// 酒店预订
  18351. /// 生成VOUCHER
  18352. /// 2024.05.06 之后版本
  18353. /// </summary>
  18354. /// <param name="_dto"></param>
  18355. /// <returns></returns>
  18356. [HttpPost]
  18357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18358. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  18359. {
  18360. #region 参数验证
  18361. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18362. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18363. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18364. #region 团组操作权限验证 76 酒店预定模块
  18365. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18366. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18367. #endregion
  18368. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18369. #region 页面操作权限验证
  18370. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18371. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18372. #endregion
  18373. #endregion
  18374. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  18375. //判断数据是否完整
  18376. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18377. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18378. string strFileName = "HotelStatement/";
  18379. string guestNames = ""; //格式Mr.xxx Ms.xxx
  18380. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  18381. #region 数据处理
  18382. List<int> guestIds = new List<int>();
  18383. //int index = 0;
  18384. foreach (var item in hrDtas)
  18385. {
  18386. if (item.GuestName.Contains(","))
  18387. {
  18388. string[] guestIdArr = item.GuestName.Split(',');
  18389. foreach (var guestIdStr in guestIdArr)
  18390. {
  18391. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  18392. if (guestBool)
  18393. {
  18394. guestIds.Add(guestId);
  18395. }
  18396. }
  18397. }
  18398. else guestNames += item.GuestName;
  18399. var voucherInfo = new HotelVoucherInfoView()
  18400. {
  18401. HotelName = item.HotelName,
  18402. CheckInDate = item.CheckInDate,
  18403. CheckOutDate = item.CheckOutDate,
  18404. ConfirmationNumber = item.DetermineNo.Trim(),
  18405. RoomType = item.RoomExplanation
  18406. };
  18407. vouchers.Add(voucherInfo);
  18408. }
  18409. if (guestIds.Count > 0)
  18410. {
  18411. guestIds = guestIds.Distinct().ToList();
  18412. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  18413. if (guestDatas.Count > 0)
  18414. {
  18415. guestNames = "";
  18416. foreach (var guest in guestDatas)
  18417. {
  18418. string guestName = "";
  18419. if (guest.Sex == 0) guestName += @"MR.";
  18420. else if (guest.Sex == 1) guestName += @"MS.";
  18421. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18422. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18423. guestNames += @$"{guestName.Trim()}、";
  18424. }
  18425. if (guestNames.Length > 0)
  18426. {
  18427. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18428. }
  18429. }
  18430. }
  18431. #endregion
  18432. //载入模板
  18433. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  18434. Document doc = new Document(sss);
  18435. DocumentBuilder builder = new DocumentBuilder(doc);
  18436. if (doc.Range.Bookmarks["GuestName"] != null)
  18437. {
  18438. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  18439. mark.Text = guestNames;
  18440. }
  18441. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18442. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  18443. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  18444. for (int i = 1; i <= vouchers.Count; i++)
  18445. {
  18446. HotelVoucherInfoView hviv = vouchers[i - 1];
  18447. builder.MoveToCell(0, i, 0, 0);
  18448. builder.Write(hviv.HotelName);
  18449. builder.MoveToCell(0, i, 1, 0);
  18450. builder.Write(hviv.CheckInDate);
  18451. builder.MoveToCell(0, i, 2, 0);
  18452. builder.Write(hviv.CheckOutDate);
  18453. builder.MoveToCell(0, i, 3, 0);
  18454. builder.Write(hviv.RoomType);
  18455. builder.MoveToCell(0, i, 4, 0);
  18456. builder.Write(hviv.ConfirmationNumber);
  18457. }
  18458. //删除多余行
  18459. int currRowIndex = vouchers.Count + 1;
  18460. int delRows = 21 - currRowIndex;
  18461. if (delRows > 0)
  18462. {
  18463. for (int i = 0; i < delRows; i++)
  18464. {
  18465. table.Rows.RemoveAt(currRowIndex);
  18466. //cultivateRowIndex++;
  18467. }
  18468. }
  18469. strFileName += "VOUCHER.docx";
  18470. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18471. doc.Save(fileDir);
  18472. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18473. return Ok(JsonView(true, "操作成功!", Url));
  18474. }
  18475. /// <summary>
  18476. /// 酒店预订
  18477. /// 生成VOUCHER 批量生成
  18478. /// New
  18479. /// </summary>
  18480. /// <param name="_dto"></param>
  18481. /// <returns></returns>
  18482. [HttpPost]
  18483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18484. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  18485. {
  18486. #region 参数验证
  18487. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18488. if (_dto.PageId < 1) _dto.PageId = 28;
  18489. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18490. #region 团组操作权限验证 76 酒店预定模块
  18491. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18492. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18493. #endregion
  18494. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18495. #region 页面操作权限验证
  18496. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18497. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18498. #endregion
  18499. #endregion
  18500. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  18501. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  18502. .OrderBy(x => x.CheckInDate)
  18503. .ToListAsync();
  18504. //判断数据是否完整
  18505. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  18506. string strFileName = "HotelStatement/";
  18507. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18508. if (dele != null)
  18509. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  18510. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  18511. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  18512. .Where(it => it.IsDel == 0)
  18513. .ToListAsync();
  18514. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  18515. for (int i = 0; i < hrDtas.Count; i++)
  18516. {
  18517. string guestNames = string.Empty;
  18518. List<int> guestIds = new List<int>();
  18519. var item = hrDtas[i];
  18520. //处理客户姓名
  18521. if (item.GuestName.Contains(","))
  18522. {
  18523. string[] guestIdArr = item.GuestName.Split(',');
  18524. foreach (var guestIdStr in guestIdArr)
  18525. if (int.TryParse(guestIdStr, out int guestId))
  18526. guestIds.Add(guestId);
  18527. }
  18528. else
  18529. {
  18530. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  18531. if (guestIdBool)
  18532. {
  18533. guestIds.Add(guestId);
  18534. }
  18535. //NaN
  18536. if (item.GuestName.Contains("NaN"))
  18537. {
  18538. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  18539. }
  18540. }
  18541. if (guestIds.Count > 0)
  18542. {
  18543. guestIds = guestIds.Distinct().ToList();
  18544. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  18545. if (guestDatas1.Count > 0)
  18546. {
  18547. guestNames = "";
  18548. foreach (var guest in guestDatas1)
  18549. {
  18550. string guestName = "";
  18551. if (guest.Sex == 0) guestName += @"MR.";
  18552. else if (guest.Sex == 1) guestName += @"MS.";
  18553. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  18554. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  18555. guestNames += @$"{guestName.Trim()}、";
  18556. }
  18557. if (guestNames.Length > 0)
  18558. {
  18559. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  18560. }
  18561. }
  18562. }
  18563. //if (!string.IsNullOrEmpty(guestNames))
  18564. //{
  18565. hrDtas[i].GuestName = guestNames;
  18566. //}
  18567. }
  18568. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  18569. Document doc = new Document();
  18570. DocumentBuilder builder = new DocumentBuilder(doc);
  18571. try
  18572. {
  18573. builder.MoveToDocumentStart();
  18574. foreach (var item in hrDtas)
  18575. {
  18576. //标题
  18577. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18578. builder.ParagraphFormat.LineSpacing = 1;
  18579. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18580. builder.ParagraphFormat.Style.Font.Size = 9;
  18581. builder.ParagraphFormat.Style.Font.Bold = true;
  18582. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18583. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  18584. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  18585. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18586. builder.ParagraphFormat.LineSpacing = 1;
  18587. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18588. builder.ParagraphFormat.Style.Font.Size = 9;
  18589. builder.ParagraphFormat.Style.Font.Bold = true;
  18590. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  18591. builder.StartTable();
  18592. // 设置边框颜色
  18593. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  18594. //设置边框样式
  18595. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  18596. //表格
  18597. #region 第一行
  18598. builder.InsertCell();
  18599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18600. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18601. //builder.CellFormat.AllowAutoFit = false;
  18602. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18603. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18604. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18605. builder.CellFormat.WrapText = true; //自动换行
  18606. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18607. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  18608. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18609. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18610. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18611. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18612. builder.Write("TOUR NO:");
  18613. builder.InsertCell();
  18614. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18615. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18617. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18618. builder.ParagraphFormat.Style.Font.Bold = false;
  18619. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18620. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18621. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18622. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18623. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18624. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18625. builder.Write($"{dele?.TourCode ?? "-"}");
  18626. builder.InsertCell();
  18627. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18628. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18629. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18630. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18631. builder.ParagraphFormat.Style.Font.Bold = false;
  18632. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18633. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18634. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18635. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18636. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18637. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18638. builder.Write($"CITY:");
  18639. builder.InsertCell();
  18640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18641. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18642. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18643. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18644. builder.ParagraphFormat.Style.Font.Bold = false;
  18645. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18646. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18647. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18648. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18649. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18650. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18651. builder.Write($"{item.City}");
  18652. builder.EndRow();
  18653. #endregion
  18654. #region 第二行
  18655. builder.InsertCell();
  18656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18657. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18658. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18659. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18660. builder.ParagraphFormat.Style.Font.Bold = false;
  18661. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18663. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18664. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18665. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18666. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18667. builder.Write("CONFIRMATION NO:");
  18668. builder.InsertCell();
  18669. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18670. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18671. builder.ParagraphFormat.Style.Font.Size = 8;
  18672. builder.ParagraphFormat.Style.Font.Bold = false;
  18673. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18674. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18675. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18676. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18677. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18678. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18679. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18680. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18681. builder.Write($"{item.DetermineNo}");
  18682. builder.InsertCell();
  18683. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18684. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18685. builder.InsertCell();
  18686. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18687. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18688. builder.EndRow();
  18689. #endregion
  18690. #region 第三行
  18691. builder.InsertCell();
  18692. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18693. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18694. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18695. builder.ParagraphFormat.Style.Font.Bold = false;
  18696. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18697. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18698. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18699. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18700. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18701. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18702. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18703. builder.Write($"HOTEL NAME:");
  18704. builder.InsertCell();
  18705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18706. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18707. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18708. builder.ParagraphFormat.Style.Font.Bold = false;
  18709. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18712. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18713. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18714. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18715. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18716. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18717. builder.Write($"{item.HotelName}");
  18718. builder.InsertCell();
  18719. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18720. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18721. builder.InsertCell();
  18722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18723. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18724. builder.EndRow();
  18725. #endregion
  18726. #region 第四行
  18727. builder.InsertCell();
  18728. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18729. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18730. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18731. builder.ParagraphFormat.Style.Font.Bold = false;
  18732. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18733. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18734. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18735. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18736. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18737. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18738. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18739. builder.Write($"HOTEL ADDRESS:");
  18740. builder.InsertCell();
  18741. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18742. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18743. builder.ParagraphFormat.Style.Font.Size = 8;
  18744. builder.ParagraphFormat.Style.Font.Bold = false;
  18745. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18746. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18747. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18748. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18749. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18750. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18751. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18752. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18753. builder.Write($"{item.HotelAddress}");
  18754. builder.InsertCell();
  18755. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18756. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18757. builder.InsertCell();
  18758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18759. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18760. builder.EndRow();
  18761. #endregion
  18762. #region 第五行
  18763. builder.InsertCell();
  18764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18765. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18766. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18767. builder.ParagraphFormat.Style.Font.Bold = false;
  18768. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18769. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18770. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18771. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18772. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18773. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18774. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18775. builder.Write("TEL:");
  18776. builder.InsertCell();
  18777. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18778. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18779. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18780. builder.ParagraphFormat.Style.Font.Bold = false;
  18781. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18782. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18783. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18784. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18785. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18786. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18787. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18788. builder.Write($"{item.HotelTel}");
  18789. builder.InsertCell();
  18790. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18791. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18792. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18793. builder.ParagraphFormat.Style.Font.Bold = false;
  18794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18795. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18796. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18797. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18798. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18799. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18800. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18801. builder.Write($"FAX:");
  18802. builder.InsertCell();
  18803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18805. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18806. builder.ParagraphFormat.Style.Font.Bold = false;
  18807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18810. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18811. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18812. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18813. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18814. builder.Write($"{item.HotelFax}");
  18815. builder.EndRow();
  18816. #endregion
  18817. #region 第六行
  18818. builder.InsertCell();
  18819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18820. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18821. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18822. builder.ParagraphFormat.Style.Font.Bold = false;
  18823. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18824. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18825. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18826. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18827. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18828. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18829. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18830. builder.Write("CHECK IN:");
  18831. builder.InsertCell();
  18832. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18833. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18834. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18835. builder.ParagraphFormat.Style.Font.Bold = false;
  18836. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18837. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18838. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18839. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18840. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18841. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18842. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18843. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  18844. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  18845. builder.Write($"{checkInStr}");
  18846. builder.InsertCell();
  18847. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18848. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18849. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18850. builder.ParagraphFormat.Style.Font.Bold = false;
  18851. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18852. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18853. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18854. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18855. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18856. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18857. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18858. builder.Write($"CHECK OUT:");
  18859. builder.InsertCell();
  18860. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18861. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18862. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18863. builder.ParagraphFormat.Style.Font.Bold = false;
  18864. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18865. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18866. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18867. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18868. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18869. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18870. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18871. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  18872. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  18873. builder.Write($"{checkOutStr}");
  18874. builder.EndRow();
  18875. #endregion
  18876. #region 第七行
  18877. builder.InsertCell();
  18878. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18879. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18880. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18881. builder.ParagraphFormat.Style.Font.Bold = false;
  18882. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18883. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18884. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18885. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18886. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18887. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18888. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18889. builder.Write($"GUEST NAME:");
  18890. builder.InsertCell();
  18891. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18892. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18893. builder.ParagraphFormat.Style.Font.Size = 8;
  18894. builder.ParagraphFormat.Style.Font.Bold = false;
  18895. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18896. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18897. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18898. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18899. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18900. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18901. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18902. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18903. builder.Write($"{item.GuestName.Trim()}");
  18904. builder.InsertCell();
  18905. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18906. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18907. builder.InsertCell();
  18908. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18909. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18910. builder.EndRow();
  18911. #endregion
  18912. #region 第八行
  18913. builder.InsertCell();
  18914. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18915. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18916. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18917. builder.ParagraphFormat.Style.Font.Bold = false;
  18918. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18919. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18920. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18921. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18922. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18923. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18924. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18925. builder.Write($"ROOM TYPE:");
  18926. builder.InsertCell();
  18927. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18928. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18929. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18930. builder.ParagraphFormat.Style.Font.Bold = false;
  18931. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18932. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18933. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18934. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18935. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18936. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18937. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18938. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18939. builder.Write($"{item.RoomExplanation}");
  18940. builder.InsertCell();
  18941. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18942. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18943. builder.InsertCell();
  18944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18945. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18946. builder.EndRow();
  18947. #endregion
  18948. #region 第九行
  18949. builder.InsertCell();
  18950. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18951. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18952. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18953. builder.ParagraphFormat.Style.Font.Bold = false;
  18954. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18955. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18956. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18957. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18958. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18959. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18960. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18961. builder.Write($"NOTE:");
  18962. builder.InsertCell();
  18963. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18964. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18965. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18966. builder.ParagraphFormat.Style.Font.Bold = false;
  18967. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18968. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18969. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18970. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18971. 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.");
  18972. builder.InsertCell();
  18973. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18974. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18975. builder.InsertCell();
  18976. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18977. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18978. builder.EndRow();
  18979. #endregion
  18980. builder.EndTable();
  18981. //换行
  18982. builder.Writeln("");
  18983. builder.Writeln("");
  18984. }
  18985. #region 获取文档中的所有表格 设置文字自适应
  18986. // 获取文档中的所有表格。
  18987. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18988. {
  18989. // 遍历表格中的所有行。
  18990. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18991. {
  18992. foreach (Cell cell in row.Cells)
  18993. {
  18994. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18995. cellFormat.Width = 0;
  18996. }
  18997. }
  18998. }
  18999. #endregion
  19000. #region 设置页眉
  19001. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19002. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19003. if (System.IO.File.Exists(voucherHeaderPath))
  19004. {
  19005. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19006. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19007. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19008. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19009. // 调整图片位置
  19010. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19011. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19012. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19013. shape.Left = 0; // 将图片距离页面左边缘的距离
  19014. shape.Width = 81; // 设置图片宽度
  19015. shape.Height = 36; // 设置图片高度
  19016. }
  19017. //靠右
  19018. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19019. //// 设置页脚上下边距
  19020. //builder.PageSetup.HeaderDistance = 42;
  19021. // 添加页眉线
  19022. Aspose.Words.Border borderHeader = null;
  19023. try
  19024. {
  19025. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19026. }
  19027. catch (Exception e)
  19028. {
  19029. // TODO Auto-generated catch block
  19030. //e.printStackTrace();
  19031. }
  19032. borderHeader.Shadow = true;
  19033. borderHeader.DistanceFromText = 2;
  19034. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19035. #endregion
  19036. }
  19037. catch (Exception ex)
  19038. {
  19039. }
  19040. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19041. doc.Save(fileDir);
  19042. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19043. return Ok(JsonView(true, "操作成功!", Url));
  19044. }
  19045. /// <summary>
  19046. /// 酒店预订
  19047. /// 生成 预定成本 Excel
  19048. /// </summary>
  19049. /// <param name="_dto"></param>
  19050. /// <returns></returns>
  19051. [HttpPost]
  19052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19053. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19054. {
  19055. #region 参数验证
  19056. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19057. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19058. if (!vadalitorRes.IsValid)
  19059. {
  19060. var errors = new StringBuilder();
  19061. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19062. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19063. }
  19064. #region 团组操作权限验证 76 酒店预定模块
  19065. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19066. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19067. #endregion
  19068. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19069. #region 页面操作权限验证
  19070. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19071. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19072. #endregion
  19073. #endregion
  19074. decimal _rate = 1.00M;
  19075. string _currency = string.Empty;
  19076. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19077. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19078. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19079. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19080. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19081. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19082. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19083. if (_GroupCostParameter == null)
  19084. {
  19085. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19086. bool isIntType = int.TryParse(_currency, out int currId);
  19087. if (isIntType)
  19088. {
  19089. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19090. }
  19091. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19092. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19093. if (currInfo == null)
  19094. {
  19095. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19096. }
  19097. else _rate = currInfo.Rate;
  19098. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19099. {
  19100. _rate = _GroupCostParameter.Rate;
  19101. }
  19102. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19103. //string strFileName = "HotelStatement/";
  19104. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19105. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19106. var rateDatas = new List<dynamic>();
  19107. #region 数据处理
  19108. foreach (var item in hrDtas)
  19109. {
  19110. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19111. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19112. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19113. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19114. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19115. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19116. {
  19117. continue;
  19118. }
  19119. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19120. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19121. string singleRoomFeeStr = string.Empty,
  19122. doubleRoomFeeStr = string.Empty,
  19123. suiteRoomFeeStr = string.Empty,
  19124. otherRoomFeeStr = string.Empty,
  19125. payMoneyStr = string.Empty,
  19126. cardPriceStr = string.Empty;
  19127. if (roomCurr.Equals("CNY"))
  19128. {
  19129. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19130. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19131. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19132. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19133. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19134. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19135. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19136. }
  19137. else
  19138. {
  19139. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19140. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19141. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19142. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19143. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19144. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19145. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19146. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19147. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19148. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19149. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19150. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19151. if (ccpPaymentCurrency.Equals("CNY"))
  19152. {
  19153. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19154. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19155. }
  19156. else
  19157. {
  19158. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19159. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19160. }
  19161. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19162. if (hotelcardPriceCurrency.Equals("CNY"))
  19163. {
  19164. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19165. }
  19166. else
  19167. {
  19168. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19169. }
  19170. }
  19171. string breakfastPriceStr = string.Empty,
  19172. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19173. governmentRentStr = string.Empty,
  19174. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19175. cityTaxStr = string.Empty,
  19176. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19177. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  19178. if (!string.IsNullOrEmpty(breakfastCurrency1))
  19179. {
  19180. if (breakfastCurrency1.Equals("CNY"))
  19181. {
  19182. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19183. }
  19184. else
  19185. {
  19186. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  19187. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  19188. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  19189. }
  19190. }
  19191. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  19192. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  19193. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  19194. {
  19195. if (governmentRentCurrency.Equals("CNY"))
  19196. {
  19197. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19198. }
  19199. else
  19200. {
  19201. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  19202. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  19203. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  19204. }
  19205. }
  19206. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  19207. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  19208. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  19209. {
  19210. if (cityTaxStrCurrency1.Equals("CNY"))
  19211. {
  19212. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19213. }
  19214. else
  19215. {
  19216. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  19217. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  19218. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  19219. }
  19220. }
  19221. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  19222. int payDId = roomInfo?.PayDId ?? 0;
  19223. pcfds.Add(new HotelReservations_PCFD_View()
  19224. {
  19225. City = item.City,
  19226. HotelName = item.HotelName,
  19227. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19228. // SingleRoomCount = item.SingleRoomCount,
  19229. SingleRoomPrice = singleRoomFeeStr,
  19230. // DoubleRoomCount = item.DoubleRoomCount,
  19231. DoubleRoomPrice = doubleRoomFeeStr,
  19232. //SuiteRoomCount = item.SuiteRoomCount,
  19233. SuiteRoomPrice = suiteRoomFeeStr,
  19234. OtherRoomPrice = otherRoomFeeStr,
  19235. //OtherRoomCount = item.OtherRoomCount,
  19236. BreakfastPrice = breakfastPriceStr,
  19237. GovernmentRent = governmentRentStr,
  19238. CityTax = cityTaxStr,
  19239. RoomExplanation = item.RoomExplanation,
  19240. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19241. PayTime = roomInfo?.ConsumptionDate,
  19242. BankNo = roomInfo?.BankNo,
  19243. PayMoney = payMoneyStr,
  19244. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19245. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19246. CardPrice = cardPriceStr,
  19247. Remark = ccpInfo.Remark
  19248. });
  19249. }
  19250. #endregion
  19251. //载入模板
  19252. WorkbookDesigner designer = new WorkbookDesigner();
  19253. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19254. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19255. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19256. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19257. var rateDatas1 = rateDatas.Distinct();
  19258. var rateStr = string.Empty;
  19259. foreach (var item in rateDatas1)
  19260. {
  19261. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  19262. }
  19263. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  19264. designer.SetDataSource("Opertor", userInfo.CnName);
  19265. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19266. dt.TableName = "ViewMyHotelReservations";
  19267. designer.SetDataSource(dt);
  19268. designer.Process();
  19269. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19270. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19271. designer.Workbook.Save(serverPath);
  19272. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19273. #region 删除指定行
  19274. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19275. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19276. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19277. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19278. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19279. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19280. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19281. cssIndex = dt.Columns["CityTax"].Ordinal,
  19282. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19283. remarkIndex = dt.Columns["Remark"].Ordinal;
  19284. //删除指定列
  19285. foreach (DataRow item in dt.Rows)
  19286. {
  19287. string singleStr = item["SingleRoomPrice"].ToString();
  19288. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19289. if (containsDigitButNotZero1) singleDel = false;
  19290. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19291. string doubleStr = item["DoubleRoomPrice"].ToString();
  19292. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19293. if (containsDigitButNotZero2) doubleDel = false;
  19294. string suiteStr = item["SuiteRoomPrice"].ToString();
  19295. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19296. if (containsDigitButNotZero3) suiteDel = false;
  19297. string otherStr = item["OtherRoomPrice"].ToString();
  19298. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19299. if (containsDigitButNotZero4) otherDel = false;
  19300. string zcStr = item["BreakfastPrice"].ToString();
  19301. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19302. if (containsDigitButNotZero5) zcDel = false;
  19303. string dsStr = item["GovernmentRent"].ToString();
  19304. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19305. if (containsDigitButNotZero6) dsDel = false;
  19306. string cssStr = item["CityTax"].ToString();
  19307. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19308. if (containsDigitButNotZero7) cssDel = false;
  19309. string cpStr = item["ConsumptionPatterns"].ToString();
  19310. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19311. string remarkStr = item["Remark"].ToString();
  19312. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19313. }
  19314. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19315. DeleteColumn(serverPath, cpIndex, cpDel);
  19316. DeleteColumn(serverPath, dsIndex, dsDel);
  19317. DeleteColumn(serverPath, cssIndex, cssDel);
  19318. DeleteColumn(serverPath, zcIndex, zcDel);
  19319. DeleteColumn(serverPath, otherIndex, otherDel);
  19320. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19321. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19322. DeleteColumn(serverPath, singleIndex, singleDel);
  19323. #endregion
  19324. //只保留第一个表格
  19325. DeleteSheet(serverPath);
  19326. return Ok(JsonView(true, "操作成功", url = rst));
  19327. }
  19328. else
  19329. {
  19330. _currency = _GroupCostParameter.Currency;
  19331. bool isIntType = int.TryParse(_currency, out int currId);
  19332. if (isIntType)
  19333. {
  19334. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19335. }
  19336. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19337. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19338. if (currInfo == null)
  19339. {
  19340. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19341. }
  19342. if (!_currency.ToUpper().Equals("CNY"))
  19343. {
  19344. _rate = _GroupCostParameter.Rate;
  19345. }
  19346. _rate = currInfo.Rate;
  19347. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19348. //string strFileName = "HotelStatement/";
  19349. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19350. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19351. #region 数据处理
  19352. foreach (var item in hrDtas)
  19353. {
  19354. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19355. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19356. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19357. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19358. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19359. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19360. string singleRoomFeeStr = string.Empty,
  19361. doubleRoomFeeStr = string.Empty,
  19362. suiteRoomFeeStr = string.Empty,
  19363. otherRoomFeeStr = string.Empty,
  19364. payMoneyStr = string.Empty,
  19365. cardPriceStr = string.Empty;
  19366. if (roomCurr.Equals(_currency))
  19367. {
  19368. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  19369. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  19370. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  19371. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  19372. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  19373. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  19374. }
  19375. else
  19376. {
  19377. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19378. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19379. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19380. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19381. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19382. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19383. }
  19384. string breakfastPriceStr = string.Empty,
  19385. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19386. governmentRentStr = string.Empty,
  19387. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  19388. cityTaxStrStr = string.Empty,
  19389. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  19390. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  19391. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  19392. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  19393. int payDId = roomInfo?.PayDId ?? 0;
  19394. pcfds.Add(new HotelReservations_PCFD_View()
  19395. {
  19396. City = item.City,
  19397. HotelName = item.HotelName,
  19398. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  19399. // SingleRoomCount = item.SingleRoomCount,
  19400. SingleRoomPrice = singleRoomFeeStr,
  19401. // DoubleRoomCount = item.DoubleRoomCount,
  19402. DoubleRoomPrice = doubleRoomFeeStr,
  19403. //SuiteRoomCount = item.SuiteRoomCount,
  19404. SuiteRoomPrice = suiteRoomFeeStr,
  19405. OtherRoomPrice = otherRoomFeeStr,
  19406. //OtherRoomCount = item.OtherRoomCount,
  19407. BreakfastPrice = breakfastPriceStr,
  19408. GovernmentRent = governmentRentStr,
  19409. CityTax = cityTaxStrStr,
  19410. RoomExplanation = item.RoomExplanation,
  19411. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  19412. PayTime = roomInfo?.ConsumptionDate,
  19413. BankNo = roomInfo?.BankNo,
  19414. PayMoney = payMoneyStr,
  19415. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  19416. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  19417. CardPrice = cardPriceStr,
  19418. Remark = ccpInfo.Remark
  19419. });
  19420. }
  19421. #endregion
  19422. //载入模板
  19423. WorkbookDesigner designer = new WorkbookDesigner();
  19424. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  19425. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  19426. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  19427. designer.SetDataSource("TourNo", groupInfo.TourCode);
  19428. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  19429. designer.SetDataSource("Opertor", userInfo.CnName);
  19430. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  19431. dt.TableName = "ViewMyHotelReservations";
  19432. designer.SetDataSource(dt);
  19433. designer.Process();
  19434. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  19435. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  19436. designer.Workbook.Save(serverPath);
  19437. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  19438. #region 删除指定行
  19439. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  19440. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  19441. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  19442. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  19443. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  19444. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  19445. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  19446. cssIndex = dt.Columns["CityTax"].Ordinal,
  19447. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  19448. remarkIndex = dt.Columns["Remark"].Ordinal;
  19449. //删除指定列
  19450. foreach (DataRow item in dt.Rows)
  19451. {
  19452. string singleStr = item["SingleRoomPrice"].ToString();
  19453. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  19454. if (containsDigitButNotZero1) singleDel = false;
  19455. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  19456. string doubleStr = item["DoubleRoomPrice"].ToString();
  19457. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19458. if (containsDigitButNotZero2) doubleDel = false;
  19459. string suiteStr = item["SuiteRoomPrice"].ToString();
  19460. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  19461. if (containsDigitButNotZero3) suiteDel = false;
  19462. string otherStr = item["OtherRoomPrice"].ToString();
  19463. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  19464. if (containsDigitButNotZero4) otherDel = false;
  19465. string zcStr = item["BreakfastPrice"].ToString();
  19466. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  19467. if (containsDigitButNotZero5) zcDel = false;
  19468. string dsStr = item["GovernmentRent"].ToString();
  19469. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  19470. if (containsDigitButNotZero6) dsDel = false;
  19471. string cssStr = item["CityTax"].ToString();
  19472. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  19473. if (containsDigitButNotZero7) cssDel = false;
  19474. string cpStr = item["ConsumptionPatterns"].ToString();
  19475. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  19476. string remarkStr = item["Remark"].ToString();
  19477. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  19478. }
  19479. DeleteColumn(serverPath, remarkIndex, remarkDel);
  19480. DeleteColumn(serverPath, cpIndex, cpDel);
  19481. DeleteColumn(serverPath, dsIndex, dsDel);
  19482. DeleteColumn(serverPath, cssIndex, cssDel);
  19483. DeleteColumn(serverPath, zcIndex, zcDel);
  19484. DeleteColumn(serverPath, otherIndex, otherDel);
  19485. DeleteColumn(serverPath, suiteIndex, suiteDel);
  19486. DeleteColumn(serverPath, doubleIndex, doubleDel);
  19487. DeleteColumn(serverPath, singleIndex, singleDel);
  19488. #endregion
  19489. //只保留第一个表格
  19490. DeleteSheet(serverPath);
  19491. return Ok(JsonView(true, "操作成功", url = rst));
  19492. }
  19493. //return Ok(JsonView(false));
  19494. }
  19495. /// <summary>
  19496. /// 删除指定列
  19497. /// </summary>
  19498. /// <param name="file"></param>
  19499. /// <param name="columnIndex"></param>
  19500. /// <param name="isDel"></param>
  19501. private void DeleteColumn(string file, int columnIndex, bool isDel)
  19502. {
  19503. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19504. //wb.Save(file);
  19505. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  19506. if (sheet1 != null)
  19507. {
  19508. if (isDel)
  19509. {
  19510. Cells cells = sheet1.Cells;
  19511. cells.DeleteColumn(columnIndex);
  19512. }
  19513. }
  19514. wb.Save(file);
  19515. }
  19516. /// <summary>
  19517. /// 删除sheet
  19518. /// </summary>
  19519. /// <param name="file"></param>
  19520. private void DeleteSheet(string file)
  19521. {
  19522. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  19523. //wb.Save(file);
  19524. List<string> sheets = new List<string>();
  19525. foreach (var item in wb.Worksheets)
  19526. {
  19527. sheets.Add(item.Name);
  19528. }
  19529. if (sheets.Count > 0)
  19530. {
  19531. sheets.RemoveAt(0);//不删除第一个sheet
  19532. foreach (var item in sheets)
  19533. {
  19534. wb.Worksheets.RemoveAt(item);
  19535. }
  19536. }
  19537. wb.Save(file);
  19538. }
  19539. /// <summary>
  19540. /// 酒店预订
  19541. /// 确认单
  19542. /// </summary>
  19543. /// <param name="_dto"></param>
  19544. /// <returns></returns>
  19545. [HttpPost]
  19546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19547. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  19548. {
  19549. try
  19550. {
  19551. #region 参数验证
  19552. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19553. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19554. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19555. #region 团组操作权限验证 76 酒店预定模块
  19556. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19557. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19558. #endregion
  19559. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19560. #region 页面操作权限验证
  19561. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19562. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19563. #endregion
  19564. #endregion
  19565. //团组信息
  19566. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  19567. //酒店数据
  19568. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  19569. if (listhoteldata.Count < 0)
  19570. {
  19571. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  19572. }
  19573. //利datatable存储
  19574. DataTable dt = new DataTable();
  19575. dt.Columns.Add("CheckInDate", typeof(string));
  19576. dt.Columns.Add("City", typeof(string));
  19577. dt.Columns.Add("Hotel", typeof(string));
  19578. dt.Columns.Add("Room", typeof(string));
  19579. for (int i = 0; i < listhoteldata.Count; i++)
  19580. {
  19581. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  19582. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  19583. while (dayStart < dayEnd)
  19584. {
  19585. string temp = "";
  19586. DataRow row = dt.NewRow();
  19587. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  19588. row["City"] = listhoteldata[i].City;
  19589. row["Hotel"] = listhoteldata[i].HotelName;
  19590. if (listhoteldata[i].SingleRoomCount > 0)
  19591. {
  19592. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  19593. }
  19594. if (listhoteldata[i].DoubleRoomCount > 0)
  19595. {
  19596. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  19597. }
  19598. if (listhoteldata[i].SuiteRoomCount > 0)
  19599. {
  19600. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  19601. }
  19602. if (listhoteldata[i].OtherRoomCount > 0)
  19603. {
  19604. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  19605. }
  19606. row["Room"] = temp;
  19607. dt.Rows.Add(row);
  19608. dayStart = dayStart.AddDays(1);
  19609. }
  19610. }
  19611. Dictionary<string, string> dic = new Dictionary<string, string>();
  19612. dic.Add("Dele", di.TeamName);
  19613. dic.Add("City", di.VisitCountry);
  19614. //模板路径
  19615. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  19616. //载入模板
  19617. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  19618. DocumentBuilder builder = new DocumentBuilder(doc);
  19619. foreach (var key in dic.Keys)
  19620. {
  19621. builder.MoveToBookmark(key);
  19622. builder.Write(dic[key]);
  19623. }
  19624. //获取word里所有表格
  19625. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19626. //获取所填表格的序数
  19627. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19628. var rowStart = tableOne.Rows[0]; //获取第1行
  19629. //循环赋值
  19630. for (int i = 0; i < dt.Rows.Count; i++)
  19631. {
  19632. builder.MoveToCell(0, i + 1, 0, 0);
  19633. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  19634. builder.MoveToCell(0, i + 1, 1, 0);
  19635. builder.Write(dt.Rows[i]["City"].ToString());
  19636. builder.MoveToCell(0, i + 1, 2, 0);
  19637. builder.Write(dt.Rows[i]["Hotel"].ToString());
  19638. builder.MoveToCell(0, i + 1, 3, 0);
  19639. builder.Write(dt.Rows[i]["Room"].ToString());
  19640. }
  19641. //删除多余行
  19642. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  19643. {
  19644. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  19645. }
  19646. string strFileName = di.TeamName + "酒店确认单.doc";
  19647. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  19648. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  19649. return Ok(JsonView(true, "成功", url));
  19650. }
  19651. catch (Exception ex)
  19652. {
  19653. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  19654. }
  19655. }
  19656. #endregion
  19657. #region 团组状态
  19658. /// <summary>
  19659. /// 团组状态列表 Page
  19660. /// </summary>
  19661. /// <param name="dto">团组列表请求dto</param>
  19662. /// <returns></returns>
  19663. [HttpPost]
  19664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19665. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  19666. {
  19667. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19668. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  19669. {
  19670. string sqlWhere = string.Empty;
  19671. if (dto.IsSure == 0) //未完成
  19672. {
  19673. sqlWhere += string.Format(@" And IsSure = 0");
  19674. }
  19675. else if (dto.IsSure == 1) //已完成
  19676. {
  19677. sqlWhere += string.Format(@" And IsSure = 1");
  19678. }
  19679. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  19680. {
  19681. string tj = dto.SearchCriteria;
  19682. 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}%')",
  19683. tj, tj, tj, tj, tj);
  19684. }
  19685. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  19686. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  19687. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  19688. From (
  19689. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  19690. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  19691. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  19692. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  19693. From Grp_DelegationInfo gdi
  19694. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  19695. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  19696. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  19697. Where gdi.IsDel = 0 {0}
  19698. ) temp ", sqlWhere);
  19699. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  19700. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  19701. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  19702. }
  19703. else
  19704. {
  19705. return Ok(JsonView(false, "查询失败"));
  19706. }
  19707. }
  19708. /// <summary>
  19709. /// 团组状态
  19710. /// 设置操作完成
  19711. /// </summary>
  19712. /// <param name="dto">团组列表请求dto</param>
  19713. /// <returns></returns>
  19714. [HttpPost]
  19715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19716. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  19717. {
  19718. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  19719. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  19720. {
  19721. Id = dto.Id,
  19722. IsSure = 1
  19723. };
  19724. var result = await _sqlSugar.Updateable(_DelegationInfo)
  19725. .UpdateColumns(it => new { it.IsSure })
  19726. .WhereColumns(it => new { it.Id })
  19727. .ExecuteCommandAsync();
  19728. if (result > 0)
  19729. {
  19730. return Ok(JsonView(true, "操作完成!"));
  19731. }
  19732. return Ok(JsonView(false, "操作失败!"));
  19733. }
  19734. #endregion
  19735. #region 保险费用录入
  19736. /// <summary>
  19737. /// 根据团组Id查询保险费用列表
  19738. /// </summary>
  19739. /// <param name="dto"></param>
  19740. /// <returns></returns>
  19741. [HttpPost]
  19742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19743. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  19744. {
  19745. Result groupData = await _customersRep.CustomersByDiId(dto);
  19746. if (groupData.Code != 0)
  19747. {
  19748. return Ok(JsonView(false, groupData.Msg));
  19749. }
  19750. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19751. }
  19752. /// <summary>
  19753. /// 根据保险费用Id查询保险费用详细
  19754. /// </summary>
  19755. /// <param name="dto"></param>
  19756. /// <returns></returns>
  19757. [HttpPost]
  19758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19759. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  19760. {
  19761. try
  19762. {
  19763. Result groupData = await _customersRep.CustomersById(dto);
  19764. if (groupData.Code != 0)
  19765. {
  19766. return Ok(JsonView(false, groupData.Msg));
  19767. }
  19768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19769. }
  19770. catch (Exception ex)
  19771. {
  19772. return Ok(JsonView(false, ex.Message));
  19773. }
  19774. }
  19775. /// <summary>
  19776. /// 保险费用录入页面初始化绑定
  19777. /// </summary>
  19778. /// <param name="dto"></param>
  19779. /// <returns></returns>
  19780. [HttpPost]
  19781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19782. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  19783. {
  19784. try
  19785. {
  19786. Result groupData = await _customersRep.CustomersInitialize(dto);
  19787. if (groupData.Code != 0)
  19788. {
  19789. return Ok(JsonView(false, groupData.Msg));
  19790. }
  19791. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19792. }
  19793. catch (Exception ex)
  19794. {
  19795. return Ok(JsonView(false, ex.Message));
  19796. }
  19797. }
  19798. /// <summary>
  19799. /// 保险费用操作(Status:1.新增,2.修改)
  19800. /// </summary>
  19801. /// <param name="dto"></param>
  19802. /// <returns></returns>
  19803. [HttpPost]
  19804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19805. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  19806. {
  19807. Result groupData = await _customersRep.OpCustomers(dto);
  19808. if (groupData.Code != 0)
  19809. {
  19810. return Ok(JsonView(false, groupData.Msg));
  19811. }
  19812. #region 应用推送
  19813. try
  19814. {
  19815. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  19816. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  19817. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  19818. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  19819. //自动审核
  19820. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  19821. //2024-10-21 新增LZ UID
  19822. var userIds = new List<int>() { 21 };
  19823. string title = $"系统通知";
  19824. var diId = dto.DiId;
  19825. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  19826. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  19827. string content = "";
  19828. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19829. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  19830. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  19831. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  19832. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  19833. }
  19834. catch (Exception ex)
  19835. {
  19836. }
  19837. #endregion
  19838. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  19839. }
  19840. /// <summary>
  19841. /// 保险文件上传
  19842. /// </summary>
  19843. /// <param name="file"></param>
  19844. /// <returns></returns>
  19845. [HttpPost]
  19846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19847. public async Task<IActionResult> UploadCus(IFormFile file)
  19848. {
  19849. try
  19850. {
  19851. if (file != null)
  19852. {
  19853. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19854. //文件名称
  19855. string projectFileName = file.FileName;
  19856. //上传的文件的路径
  19857. string filePath = "";
  19858. if (!Directory.Exists(fileDir))
  19859. {
  19860. Directory.CreateDirectory(fileDir);
  19861. }
  19862. //上传的文件的路径
  19863. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  19864. using (FileStream fs = System.IO.File.Create(filePath))
  19865. {
  19866. file.CopyTo(fs);
  19867. fs.Flush();
  19868. }
  19869. return Ok(JsonView(true, "上传成功!", projectFileName));
  19870. }
  19871. else
  19872. {
  19873. return Ok(JsonView(false, "上传失败!"));
  19874. }
  19875. }
  19876. catch (Exception ex)
  19877. {
  19878. return Ok(JsonView(false, ex.Message));
  19879. }
  19880. }
  19881. /// <summary>
  19882. /// 保险删除指定文件
  19883. /// </summary>
  19884. /// <param name="dto"></param>
  19885. /// <returns></returns>
  19886. [HttpPost]
  19887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19888. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  19889. {
  19890. try
  19891. {
  19892. string filePath = "";
  19893. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  19894. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  19895. //int id = 0;
  19896. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  19897. // 删除该文件
  19898. try
  19899. {
  19900. System.IO.File.Delete(filePath);
  19901. 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()
  19902. {
  19903. Attachment = "",
  19904. }).ExecuteCommandAsync();
  19905. if (result != 0)
  19906. {
  19907. return Ok(JsonView(true, "成功!"));
  19908. }
  19909. else
  19910. {
  19911. return Ok(JsonView(false, "失败!"));
  19912. }
  19913. }
  19914. catch (Exception)
  19915. {
  19916. 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()
  19917. {
  19918. Attachment = "",
  19919. }).ExecuteCommandAsync();
  19920. if (result != 0)
  19921. {
  19922. return Ok(JsonView(true, "成功!"));
  19923. }
  19924. else
  19925. {
  19926. return Ok(JsonView(false, "失败!"));
  19927. }
  19928. }
  19929. }
  19930. catch (Exception ex)
  19931. {
  19932. return Ok(JsonView(false, "程序错误!"));
  19933. throw;
  19934. }
  19935. }
  19936. /// <summary>
  19937. /// 保险费用操作(删除)
  19938. /// </summary>
  19939. /// <param name="dto"></param>
  19940. /// <returns></returns>
  19941. [HttpPost]
  19942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19943. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19944. {
  19945. try
  19946. {
  19947. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19948. if (!res)
  19949. {
  19950. return Ok(JsonView(false, "删除失败"));
  19951. }
  19952. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19953. {
  19954. IsDel = 1,
  19955. DeleteUserId = dto.DeleteUserId,
  19956. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19957. }).ExecuteCommandAsync();
  19958. return Ok(JsonView(true, "删除成功!"));
  19959. }
  19960. catch (Exception ex)
  19961. {
  19962. return Ok(JsonView(false, "程序错误!"));
  19963. throw;
  19964. }
  19965. }
  19966. #endregion
  19967. #region 接团客户名单 PageId 104
  19968. /// <summary>
  19969. /// 接团客户名单
  19970. /// 迁移数据(慎用!)
  19971. /// </summary>
  19972. /// <returns></returns>
  19973. [HttpPost]
  19974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19975. public async Task<IActionResult> PostTourClientListChange()
  19976. {
  19977. try
  19978. {
  19979. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19980. //var groupClinetData1
  19981. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19982. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19983. int updateCount = 0;
  19984. if (oldOAClientList.Count > 0)
  19985. {
  19986. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19987. _sqlSugar.BeginTran();
  19988. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19989. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19990. foreach (var item in oldOAClientList)
  19991. {
  19992. int comId = 0;
  19993. string format = "yyyy-MM-dd HH:mm:ss";
  19994. string data11 = "1990-01-01 00:00";
  19995. var data1 = IsValidDate(item.OPdate, format);
  19996. if (data1) data11 = item.OPdate;
  19997. //客户公司验证
  19998. if (!string.IsNullOrEmpty(item.Company))
  19999. {
  20000. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20001. if (clientComInfo == null) // add
  20002. {
  20003. var addInfo = new Crm_CustomerCompany()
  20004. {
  20005. CompanyAbbreviation = "",
  20006. CompanyFullName = item.Company,
  20007. Address = "",
  20008. PostCodes = "",
  20009. LastedOpUserId = item.OPer,
  20010. LastedOpDt = Convert.ToDateTime(data11),
  20011. CreateUserId = item.OPer,
  20012. CreateTime = Convert.ToDateTime(data11),
  20013. IsDel = 0
  20014. };
  20015. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20016. if (comId1 > 0) comId = comId1;
  20017. }
  20018. else comId = clientComInfo.Id;
  20019. }
  20020. //客户人员验证
  20021. int clientId = 0;
  20022. string name = item.LastName + item.Name;
  20023. if (!string.IsNullOrEmpty(name))
  20024. {
  20025. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20026. if (clientInfo == null)
  20027. {
  20028. DateTime? dateTime = null;
  20029. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20030. if (isDt) dateTime = birthDayDt;
  20031. var addInfo1 = new Crm_DeleClient()
  20032. {
  20033. CrmCompanyId = comId,
  20034. DiId = -1,
  20035. LastName = item.LastName,
  20036. FirstName = item.Name,
  20037. OldName = "",
  20038. Pinyin = item.Pinyin,
  20039. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20040. Marriage = 0,
  20041. Phone = item.Phone,
  20042. Job = item.Job,
  20043. BirthDay = dateTime
  20044. };
  20045. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20046. if (clientId1 > 0) clientId = clientId1;
  20047. }
  20048. else clientId = clientInfo.Id;
  20049. }
  20050. if (clientId < 1)
  20051. {
  20052. continue;
  20053. }
  20054. int airType = 0;
  20055. if (item.AirType == "超经舱") airType = 459;
  20056. else if (item.AirType == "公务舱") airType = 458;
  20057. else if (item.AirType == "经济舱") airType = 460;
  20058. else if (item.AirType == "其他") airType = 565;
  20059. else if (item.AirType == "头等舱") airType = 457;
  20060. var _TourClientListEntity = new Grp_TourClientList()
  20061. {
  20062. DiId = item.Diid,
  20063. ClientId = clientId,
  20064. CreateUserId = item.OPer,
  20065. CreateTime = Convert.ToDateTime(data11),
  20066. Remark = item.Remark,
  20067. IsDel = item.Isdel,
  20068. ShippingSpaceTypeId = airType,
  20069. ShippingSpaceSpecialNeeds = item.AirRemark,
  20070. HotelSpecialNeeds = item.RoomType
  20071. };
  20072. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20073. if (_TourClientList > 0)
  20074. {
  20075. updateCount++;
  20076. }
  20077. }
  20078. _sqlSugar.CommitTran();
  20079. }
  20080. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20081. }
  20082. catch (Exception ex)
  20083. {
  20084. _sqlSugar.RollbackTran();
  20085. return Ok(JsonView(false, ex.Message));
  20086. }
  20087. //return Ok(JsonView(true));
  20088. }
  20089. private bool IsValidDate(string dateString, string format)
  20090. {
  20091. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20092. }
  20093. /// <summary>
  20094. /// 接团客户名单
  20095. /// 根据团组Id查询List
  20096. /// </summary>
  20097. /// <param name="_dto"></param>
  20098. /// <returns></returns>
  20099. [HttpPost]
  20100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20101. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20102. {
  20103. #region 参数验证
  20104. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20105. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20106. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20108. #region 页面操作权限验证
  20109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20110. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20111. #endregion
  20112. #endregion
  20113. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20114. if (viewData.Code != 0)
  20115. {
  20116. return Ok(JsonView(false, viewData.Msg));
  20117. }
  20118. return Ok(JsonView(viewData.Data));
  20119. }
  20120. /// <summary>
  20121. /// 接团客户名单
  20122. /// 基础数据 Init
  20123. /// </summary>
  20124. /// <param name="_dto"></param>
  20125. /// <returns></returns>
  20126. [HttpPost]
  20127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20128. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20129. {
  20130. #region 参数验证
  20131. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20132. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20133. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20134. #region 页面操作权限验证
  20135. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20136. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20137. #endregion
  20138. #endregion
  20139. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20140. }
  20141. /// <summary>
  20142. /// 接团客户名单
  20143. /// 根据 Id查询 Details
  20144. /// </summary>
  20145. /// <param name="_dto"></param>
  20146. /// <returns></returns>
  20147. [HttpPost]
  20148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20149. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20150. {
  20151. #region 参数验证
  20152. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20153. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20154. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20155. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20156. #region 页面操作权限验证
  20157. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20158. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20159. #endregion
  20160. #endregion
  20161. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20162. if (viewData.Code != 0)
  20163. {
  20164. return Ok(JsonView(false, viewData.Msg));
  20165. }
  20166. return Ok(JsonView(viewData.Data));
  20167. }
  20168. /// <summary>
  20169. /// 接团客户名单
  20170. /// Add Or Edit
  20171. /// </summary>
  20172. /// <param name="_dto"></param>
  20173. /// <returns></returns>
  20174. [HttpPost]
  20175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20176. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  20177. {
  20178. #region 参数验证
  20179. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20180. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20181. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20182. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20183. #region 页面操作权限验证
  20184. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20185. if (_dto.Id == 0) //添加
  20186. {
  20187. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20188. }
  20189. else if (_dto.Id >= 0) //修改
  20190. {
  20191. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20192. }
  20193. #endregion
  20194. #endregion
  20195. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  20196. if (viewData.Code != 0)
  20197. {
  20198. return Ok(JsonView(false, viewData.Msg));
  20199. }
  20200. return Ok(JsonView(true));
  20201. }
  20202. /// <summary>
  20203. /// 接团客户名单
  20204. /// json字符串 AddMultiple(添加多个)
  20205. /// </summary>
  20206. /// <param name="_dto"></param>
  20207. /// <returns></returns>
  20208. [HttpPost]
  20209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20210. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  20211. {
  20212. #region 参数验证
  20213. string jsonLabel = _dto.JsonLabel;
  20214. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20215. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20216. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20217. #region 页面操作权限验证
  20218. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20219. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20220. #endregion
  20221. #endregion
  20222. var request = new TourClientListAddMultipleDto();
  20223. request.DiId = _dto.DiId;
  20224. request.UserId = _dto.UserId;
  20225. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  20226. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  20227. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  20228. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  20229. var infos = new List<TourClientListInfo>();
  20230. foreach (var data in datas)
  20231. {
  20232. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  20233. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  20234. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  20235. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  20236. {
  20237. continue;
  20238. }
  20239. infos.Add(new TourClientListInfo()
  20240. {
  20241. IsAccompany = 1,
  20242. LastName = lastName,
  20243. FirstName = firstName,
  20244. Pinyin = lastNameEn + @"/" + firstNameEn,
  20245. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  20246. CompanyFullName = data.CompanyFullName,
  20247. Job = data.Job
  20248. });
  20249. }
  20250. if (infos.Any())
  20251. {
  20252. var viewData = await _tourClientListRep._AddMultiple(request);
  20253. if (viewData.Code != 0)
  20254. {
  20255. return Ok(JsonView(false, viewData.Msg));
  20256. }
  20257. return Ok(JsonView(true));
  20258. }
  20259. return Ok(JsonView(false));
  20260. }
  20261. /// <summary>
  20262. /// 接团客户名单
  20263. /// AddMultiple(添加多个)
  20264. /// </summary>
  20265. /// <param name="_dto"></param>
  20266. /// <returns></returns>
  20267. [HttpPost]
  20268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20269. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  20270. {
  20271. #region 参数验证
  20272. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20273. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20274. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20275. #region 页面操作权限验证
  20276. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20277. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20278. #endregion
  20279. #endregion
  20280. var viewData = await _tourClientListRep._AddMultiple(_dto);
  20281. if (viewData.Code != 0)
  20282. {
  20283. return Ok(JsonView(false, viewData.Msg));
  20284. }
  20285. return Ok(JsonView(true));
  20286. }
  20287. /// <summary>
  20288. /// 接团客户名单
  20289. /// Del
  20290. /// </summary>
  20291. /// <param name="_dto"></param>
  20292. /// <returns></returns>
  20293. [HttpPost]
  20294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20295. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  20296. {
  20297. #region 参数验证
  20298. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20299. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20300. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20301. #region 页面操作权限验证
  20302. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20303. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20304. #endregion
  20305. #endregion
  20306. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  20307. if (viewData.Code != 0)
  20308. {
  20309. return Ok(JsonView(false, viewData.Msg));
  20310. }
  20311. return Ok(JsonView(true));
  20312. }
  20313. /// <summary>
  20314. /// 接团客户名单
  20315. /// 文件下载 客户名单
  20316. /// </summary>
  20317. /// <param name="_dto"></param>
  20318. /// <returns></returns>
  20319. [HttpPost]
  20320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20321. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  20322. {
  20323. #region 参数验证
  20324. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20325. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20326. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  20327. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20328. #region 页面操作权限验证
  20329. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20330. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20331. #endregion
  20332. #endregion
  20333. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  20334. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  20335. From Grp_TourClientList tcl
  20336. Left Join
  20337. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  20338. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  20339. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  20340. From Crm_DeleClient dc
  20341. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  20342. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  20343. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  20344. Where dc.IsDel = 0) temp
  20345. On temp.DcId =tcl.ClientId
  20346. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  20347. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  20348. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  20349. //载入模板
  20350. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  20351. if (_dto.Language == 1)
  20352. {
  20353. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  20354. }
  20355. //载入模板
  20356. var doc = new Document(tempPath);
  20357. DocumentBuilder builder = new DocumentBuilder(doc);
  20358. //获取word里所有表格
  20359. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20360. //获取所填表格的序数
  20361. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20362. var rowStart = tableOne.Rows[0]; //获取第1行
  20363. if (_dto.Language == 0)
  20364. {
  20365. //循环赋值
  20366. for (int i = 0; i < DcList.Count; i++)
  20367. {
  20368. EncryptionProcessor.DecryptProperties(DcList[i]);
  20369. builder.MoveToCell(0, i + 1, 0, 0);
  20370. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  20371. builder.MoveToCell(0, i + 1, 1, 0);
  20372. int sex = DcList[i].Sex;
  20373. string sexStr = string.Empty;
  20374. if (sex == 0) sexStr = "男";
  20375. else if (sex == 1) sexStr = "女";
  20376. else sexStr = "未设置";
  20377. builder.Write(sexStr);
  20378. builder.MoveToCell(0, i + 1, 2, 0);
  20379. string birthDay = DcList[i].BirthDay;
  20380. string birthDayStr = string.Empty;
  20381. if (!string.IsNullOrEmpty(birthDay))
  20382. {
  20383. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  20384. }
  20385. builder.Write(birthDayStr);
  20386. builder.MoveToCell(0, i + 1, 3, 0);
  20387. string company = "";
  20388. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20389. {
  20390. company = DcList[i].CompanyFullName.ToString();
  20391. }
  20392. builder.Write(company);
  20393. builder.MoveToCell(0, i + 1, 4, 0);
  20394. builder.Write(DcList[i].Job);
  20395. }
  20396. }
  20397. else if (_dto.Language == 1)
  20398. {
  20399. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  20400. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  20401. List<string> transArrayStr = new List<string>();
  20402. string transStrRes1 = "";
  20403. for (int i = 0; i < DcList.Count; i++)
  20404. {
  20405. var dc = DcList[i];
  20406. EncryptionProcessor.DecryptProperties(dc);
  20407. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  20408. if (dc.Job.Equals("暂无")) dc.Job = "-";
  20409. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  20410. if (DcList.Count - 1 == i) transStrRes1 += str1;
  20411. else transStrRes1 += $"{str1}|";
  20412. }
  20413. #region AI转英文
  20414. string jsonValue = JsonConvert.SerializeObject(DcList);
  20415. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  20416. List<SeedMessages> messages = new List<SeedMessages>()
  20417. {
  20418. new SeedMessages
  20419. {
  20420. Role = KimiRole.user,
  20421. Content = jsonValue + text
  20422. }
  20423. };
  20424. KiMiApiClient client = new KiMiApiClient();
  20425. var kimiApiResult = await client.SeedMessage(messages);
  20426. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20427. string clients = kimiApiResult_JObject["content"].ToString();
  20428. string startStr = "```json", endStr = "```";
  20429. // 判断并清除开头部分
  20430. if (clients.StartsWith(startStr))
  20431. {
  20432. clients = clients.Remove(0, startStr.Length);
  20433. }
  20434. // 判断并清除结尾部分
  20435. if (clients.EndsWith(endStr))
  20436. {
  20437. clients = clients.Remove(clients.Length - endStr.Length);
  20438. }
  20439. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  20440. //循环赋值
  20441. for (int i = 0; i < en_Json.Count; i++)
  20442. {
  20443. var dc = en_Json[i];
  20444. var dc1 = DcList.Find(x => x.Id == dc.Id);
  20445. string PYName = dc.FirstName + " " + dc.LastName;
  20446. builder.MoveToCell(0, i + 1, 0, 0);
  20447. builder.Write(PYName);
  20448. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  20449. builder.MoveToCell(0, i + 1, 1, 0);
  20450. builder.Write(sex);
  20451. DateTime birthDt;
  20452. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  20453. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20454. builder.MoveToCell(0, i + 1, 2, 0);
  20455. builder.Write(birthday);
  20456. string company = string.Empty, job = string.Empty;
  20457. company = dc.CompanyFullName;
  20458. job = dc.Job;
  20459. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  20460. {
  20461. //查询对照表
  20462. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  20463. if (tempCec != null)
  20464. {
  20465. company = tempCec.enName;
  20466. }
  20467. }
  20468. builder.MoveToCell(0, i + 1, 3, 0);
  20469. builder.Write(company);
  20470. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  20471. {
  20472. //查询对照表
  20473. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  20474. if (tempPec != null)
  20475. {
  20476. job = tempPec.enName;
  20477. }
  20478. }
  20479. builder.MoveToCell(0, i + 1, 4, 0);
  20480. builder.Write(job);
  20481. }
  20482. #endregion
  20483. #region 旧翻译英文处理
  20484. ////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";
  20485. //string transStrRes = "";
  20486. //if (transStrRes1.Length > 0)
  20487. //{
  20488. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  20489. //}
  20490. ////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
  20491. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  20492. ////List<string> transArray = new List<string> { };
  20493. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  20494. //if (transStrRes.Contains("|"))
  20495. //{
  20496. // string[] transArray1 = transStrRes.Split('|');
  20497. // if (transArray1.Length > 0)
  20498. // {
  20499. // foreach (var item in transArray1)
  20500. // {
  20501. // if (item.Contains("&"))
  20502. // {
  20503. // string[] transArray2 = item.Split('&');
  20504. // int index = 0;
  20505. // string companyName = "", job = "";
  20506. // if (transArray2.Length > 0)
  20507. // {
  20508. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  20509. // if (1 < transArray2.Length) companyName = transArray2[1];
  20510. // if (2 < transArray2.Length) job = transArray2[2];
  20511. // }
  20512. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  20513. // }
  20514. // }
  20515. // }
  20516. //}
  20517. ////循环赋值
  20518. //for (int i = 0; i < DcList.Count; i++)
  20519. //{
  20520. // string PYName = "";
  20521. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  20522. // {
  20523. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  20524. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  20525. // PYName = PY_First + " " + PY_Last;
  20526. // }
  20527. // else
  20528. // {
  20529. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  20530. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  20531. // PYName = PY_First + " " + PY_Last;
  20532. // }
  20533. // builder.MoveToCell(0, i + 1, 0, 0);
  20534. // builder.Write(PYName);
  20535. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  20536. // builder.MoveToCell(0, i + 1, 1, 0);
  20537. // builder.Write(sex);
  20538. // DateTime birthDt;
  20539. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  20540. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  20541. // builder.MoveToCell(0, i + 1, 2, 0);
  20542. // builder.Write(birthday);
  20543. // string company = string.Empty, job = string.Empty;
  20544. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  20545. // if (dcTransInfo != null)
  20546. // {
  20547. // company = dcTransInfo.CompanyName;
  20548. // job = dcTransInfo.Job;
  20549. // }
  20550. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  20551. // {
  20552. // //查询对照表
  20553. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  20554. // if (tempCec != null)
  20555. // {
  20556. // company = tempCec.enName;
  20557. // }
  20558. // //翻译
  20559. // else
  20560. // {
  20561. // }
  20562. // }
  20563. // builder.MoveToCell(0, i + 1, 3, 0);
  20564. // builder.Write(company);
  20565. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  20566. // {
  20567. // //查询对照表
  20568. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  20569. // if (tempPec != null)
  20570. // {
  20571. // job = tempPec.enName;
  20572. // }
  20573. // //翻译
  20574. // else
  20575. // {
  20576. // }
  20577. // }
  20578. // builder.MoveToCell(0, i + 1, 4, 0);
  20579. // builder.Write(job);
  20580. //}
  20581. #endregion
  20582. }
  20583. //删除多余行
  20584. while (tableOne.Rows.Count > DcList.Count + 1)
  20585. {
  20586. tableOne.Rows.RemoveAt(DcList.Count + 1);
  20587. }
  20588. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  20589. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  20590. doc.Save(fileDir);
  20591. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  20592. return Ok(JsonView(true, "操作成功!", Url));
  20593. }
  20594. private class TranslateInfo
  20595. {
  20596. public int Index { get; set; }
  20597. public string CompanyName { get; set; }
  20598. public string Job { get; set; }
  20599. }
  20600. [HttpPost]
  20601. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  20602. {
  20603. if (files.Count == 0)
  20604. {
  20605. return Ok(JsonView(false, "文件为空"));
  20606. }
  20607. KiMiApiClient KiMiApi = new KiMiApiClient();
  20608. var seedConter = await KiMiApi.UploadFilesAsync(files);
  20609. if (seedConter.Count == 0)
  20610. {
  20611. return Ok(JsonView(false, "上传结果为空!"));
  20612. }
  20613. var messages = new List<SeedMessages>
  20614. {
  20615. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  20616. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  20617. };
  20618. messages.InsertRange(1, seedConter);
  20619. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  20620. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  20621. string clients = kimiApiResult_JObject["content"].ToString();
  20622. string startStr = "```json", endStr = "```";
  20623. // 判断并清除开头部分
  20624. if (clients.StartsWith(startStr))
  20625. {
  20626. clients = clients.Remove(0, startStr.Length);
  20627. }
  20628. // 判断并清除结尾部分
  20629. if (clients.EndsWith(endStr))
  20630. {
  20631. clients = clients.Remove(clients.Length - endStr.Length);
  20632. }
  20633. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  20634. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  20635. {
  20636. {"姓", "LastName" },
  20637. {"名", "FirstName" },
  20638. {"姓名拼音", "Pinyin" },
  20639. {"性别", "Sex" },
  20640. {"单位", "CompanyFullName" },
  20641. {"职务", "Job" },
  20642. {"出生日期", "Birthday" },
  20643. };
  20644. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  20645. foreach (var item in clients_JObject)
  20646. {
  20647. BaiduClientOCRView cdc = new BaiduClientOCRView();
  20648. foreach (var field in clientFieldMap.Keys)
  20649. {
  20650. if (item.TryGetValue(field, out JToken value))
  20651. {
  20652. var getValue = value.ToString();
  20653. System.Type type = cdc.GetType();
  20654. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  20655. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  20656. propertyInfo.SetValue(cdc, propertyValue);
  20657. }
  20658. }
  20659. crmClients.Add(cdc);
  20660. }
  20661. return Ok(JsonView(new
  20662. {
  20663. fileCount = files.Count,
  20664. UploadCount = seedConter.Count,
  20665. ApiResult = clients,
  20666. CrmClients = crmClients
  20667. }));
  20668. }
  20669. #endregion
  20670. #region 团组倒推表
  20671. /// <summary>
  20672. /// 倒推表基础数据
  20673. /// Init
  20674. /// </summary>
  20675. /// <returns></returns>
  20676. [HttpPost]
  20677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20678. public async Task<IActionResult> PostInvertedListInit()
  20679. {
  20680. var viewData = await _invertedListRep._Init();
  20681. if (viewData.Code != 0)
  20682. {
  20683. return Ok(JsonView(false, viewData.Msg));
  20684. }
  20685. return Ok(JsonView(viewData.Data));
  20686. }
  20687. /// <summary>
  20688. /// 倒推表
  20689. /// Info
  20690. /// </summary>
  20691. /// <param name="dto"></param>
  20692. /// <returns></returns>
  20693. [HttpPost]
  20694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20695. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  20696. {
  20697. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  20698. if (viewData.Code != 0)
  20699. {
  20700. return Ok(JsonView(false, viewData.Msg));
  20701. }
  20702. return Ok(JsonView(viewData.Data));
  20703. }
  20704. /// <summary>
  20705. /// 倒推表
  20706. /// Create
  20707. /// </summary>
  20708. /// <param name="dto"></param>
  20709. /// <returns></returns>
  20710. [HttpPost]
  20711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20712. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  20713. {
  20714. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  20715. if (viewData.Code != 0)
  20716. {
  20717. return Ok(JsonView(false, viewData.Msg));
  20718. }
  20719. return Ok(JsonView(viewData.Data));
  20720. }
  20721. /// <summary>
  20722. /// 倒推表
  20723. /// Update
  20724. /// </summary>
  20725. /// <param name="dto"></param>
  20726. /// <returns></returns>
  20727. [HttpPost]
  20728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20729. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  20730. {
  20731. var viewData = await _invertedListRep._Update(dto);
  20732. if (viewData.Code != 0)
  20733. {
  20734. return Ok(JsonView(false, viewData.Msg));
  20735. }
  20736. return Ok(JsonView(viewData.Data));
  20737. }
  20738. /// <summary>
  20739. /// 倒推表
  20740. /// File Download
  20741. /// </summary>
  20742. /// <param name="dto"></param>
  20743. /// <returns></returns>
  20744. [HttpPost]
  20745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20746. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  20747. {
  20748. var info2 = await _invertedListRep._Info(1, dto.DiId);
  20749. if (info2.Code != 0)
  20750. {
  20751. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  20752. }
  20753. var info1 = info2.Data as InvertedListInfoView;
  20754. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  20755. string teamName = "";
  20756. if (info != null) teamName = info.TeamName;
  20757. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  20758. var doc = new Document();
  20759. var builder = new DocumentBuilder(doc);
  20760. #region old insert
  20761. ////载入模板
  20762. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  20763. //Document doc = new Document(tempPath);
  20764. //DocumentBuilder builder = new DocumentBuilder(doc);
  20765. //利用键值对存放数据
  20766. //Dictionary<string, string> dic = new Dictionary<string, string>();
  20767. //dic.Add("TeamName", teamName);
  20768. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  20769. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  20770. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  20771. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  20772. //dic.Add("SQRemark", info1.ApprovalRemark);
  20773. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  20774. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  20775. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  20776. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  20777. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  20778. //dic.Add("QZRemark", info1.VisaInformationRemark);
  20779. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  20780. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  20781. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  20782. //dic.Add("CQRemark", info1.IssueVisaRemark);
  20783. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  20784. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  20785. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  20786. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  20787. //#region 填充word模板书签内容
  20788. //foreach (var key in dic.Keys)
  20789. //{
  20790. // builder.MoveToBookmark(key);
  20791. // builder.Write(dic[key]);
  20792. //}
  20793. //#endregion
  20794. #endregion
  20795. #region New Insert
  20796. string titleFont = $"仿宋",
  20797. contentFont = $"仿宋";
  20798. var fontColor = Color.FromArgb(64, 64, 64);
  20799. //设置标题 团组名称
  20800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20801. builder.Font.Name = titleFont;
  20802. builder.Font.Color = fontColor;
  20803. builder.Font.Size = 12;
  20804. builder.Font.Bold = true;
  20805. builder.Writeln(teamName);
  20806. //设置副标题 团组出访时间
  20807. builder.Font.Size = 12;
  20808. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  20809. builder.Writeln();
  20810. var backgroundColor = Color.FromArgb(199, 199, 199);
  20811. var table = builder.StartTable();
  20812. builder.InsertCell();
  20813. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  20814. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  20815. builder.CellFormat.Borders.LineWidth = 1;
  20816. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  20817. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  20818. builder.RowFormat.Height = 40;
  20819. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20820. builder.Font.Name = contentFont;
  20821. builder.Font.Size = 12;
  20822. builder.Font.Bold = true;
  20823. builder.Font.Color = fontColor;
  20824. builder.Write("时间");
  20825. builder.InsertCell();
  20826. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  20827. builder.Write("流程");
  20828. builder.InsertCell();
  20829. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  20830. builder.Write("说明");
  20831. builder.EndRow();
  20832. //报批资料准备
  20833. if (info1.IsSelectedAirportd)
  20834. {
  20835. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  20836. }
  20837. //报批/提供送签资料
  20838. if (info1.IsSelectedApprovalData)
  20839. {
  20840. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  20841. }
  20842. //出批件护照办理
  20843. if (info1.IsSelectedIssueApproval)
  20844. {
  20845. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  20846. }
  20847. //签证资料准备
  20848. if (info1.IsSelectedVisaInfo)
  20849. {
  20850. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  20851. }
  20852. //送签
  20853. if (info1.IsSelectedSendVisa)
  20854. {
  20855. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  20856. }
  20857. //出签
  20858. if (info1.IsSelectedIssueVisa)
  20859. {
  20860. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  20861. }
  20862. //机票
  20863. if (info1.IsSelectedAirTicket)
  20864. {
  20865. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  20866. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  20867. }
  20868. //酒店
  20869. if (info1.IsSelectedHotel)
  20870. {
  20871. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  20872. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  20873. }
  20874. //开行前会
  20875. if (info1.IsSelectedPreTripMeeting)
  20876. {
  20877. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  20878. }
  20879. //送机
  20880. if (info1.IsSelectedAirportdDropOff)
  20881. {
  20882. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  20883. }
  20884. builder.EndTable();
  20885. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  20886. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  20887. for (int i = 0; i < table.Rows.Count; i++)
  20888. {
  20889. var row = table.Rows[i];
  20890. //设置宽度
  20891. row.Cells[0].CellFormat.Width = 20.00;
  20892. row.Cells[1].CellFormat.Width = 30.00;
  20893. row.Cells[2].CellFormat.Width = 50.00;
  20894. if (i != 0)
  20895. {
  20896. //边框设置
  20897. InvertedListFileDownloadSetBorders(row.Cells, 0);
  20898. InvertedListFileDownloadSetBorders(row.Cells, 1);
  20899. InvertedListFileDownloadSetBorders(row.Cells, 2);
  20900. }
  20901. }
  20902. #region 页脚插入图片
  20903. // 创建页脚
  20904. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  20905. doc.FirstSection.HeadersFooters.Add(footer);
  20906. Paragraph para = new Paragraph(doc);
  20907. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  20908. footer.AppendChild(para);
  20909. builder.MoveTo(para);
  20910. string imagePath = "./Images/FMGJ_Log.png";
  20911. builder.InsertImage(imagePath);
  20912. #endregion
  20913. #endregion
  20914. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20915. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20916. string filePath = fileDir + $@"InvertedList/{fileName}";
  20917. doc.Save(filePath);
  20918. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20919. return Ok(JsonView(true, "操作成功!", Url));
  20920. }
  20921. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20922. {
  20923. var fontColor = Color.FromArgb(64, 64, 64);
  20924. builder.InsertCell();
  20925. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20926. builder.RowFormat.Height = 40;
  20927. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20928. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20929. builder.Font.Name = fontName;
  20930. builder.Font.Size = 8;
  20931. builder.Font.Bold = true;
  20932. builder.Font.Color = fontColor;
  20933. builder.Write(dateTime);
  20934. builder.InsertCell();
  20935. builder.Font.Size = 9;
  20936. builder.Font.Bold = true;
  20937. builder.Font.Color = fontColor;
  20938. builder.Write(content);
  20939. builder.InsertCell();
  20940. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20941. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20942. builder.Font.Size = 9;
  20943. builder.Font.Bold = false;
  20944. builder.Font.Color = fontColor;
  20945. builder.Write(reamrk);
  20946. builder.EndRow();
  20947. }
  20948. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20949. {
  20950. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20951. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20952. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20953. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20954. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20955. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20956. }
  20957. #endregion
  20958. #region 会务倒推表
  20959. /// <summary>
  20960. /// 会务倒推表
  20961. /// Init
  20962. /// </summary>
  20963. /// <returns></returns>
  20964. [HttpPost]
  20965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20966. public async Task<IActionResult> InforRetrogressTableInit()
  20967. {
  20968. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20969. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20970. return Ok(JsonView(false, groupData.Msg));
  20971. }
  20972. /// <summary>
  20973. /// 会务倒推表
  20974. /// ExcelDownload
  20975. /// </summary>
  20976. /// <param name="dto"></param>
  20977. /// <returns></returns>
  20978. [HttpPost]
  20979. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20981. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20982. {
  20983. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20984. var validatorRes = await validator.ValidateAsync(dto);
  20985. if (!validatorRes.IsValid)
  20986. {
  20987. StringBuilder sb = new StringBuilder();
  20988. foreach (var item in validatorRes.Errors)
  20989. {
  20990. sb.AppendLine(item.ErrorMessage);
  20991. }
  20992. return Ok(JsonView(false, sb.ToString()));
  20993. }
  20994. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20995. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20996. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20997. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20998. #region Excel
  20999. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21000. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21001. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21002. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21003. var fileNamePrefix = string.Empty;
  21004. if (days >= 30)
  21005. {
  21006. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21007. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21008. }
  21009. else if (days < 30 && days > 7)
  21010. {
  21011. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21012. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21013. }
  21014. else if (days <= 7)
  21015. {
  21016. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21017. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21018. }
  21019. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21020. fileName = CommonFun.ValidFileName(fileName);
  21021. //载入模板
  21022. WorkbookDesigner designer = new WorkbookDesigner();
  21023. designer.Workbook = new Workbook(tempPath);
  21024. designer.Process();
  21025. if (!Directory.Exists(savePath))
  21026. {
  21027. Directory.CreateDirectory(savePath);
  21028. }
  21029. string serverPath = $"{savePath}{fileName}";
  21030. designer.Workbook.Save(serverPath);
  21031. string rst = $"{servicePath}{ftpPath}{fileName}";
  21032. #endregion
  21033. return Ok(JsonView(new { url = rst }));
  21034. }
  21035. #endregion
  21036. #region 三公签证费用(签证费、代办费)
  21037. /// <summary>
  21038. /// 三公签证费用(签证费、代办费)
  21039. /// List
  21040. /// </summary>
  21041. /// <returns></returns>
  21042. [HttpPost]
  21043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21044. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21045. {
  21046. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21047. }
  21048. /// <summary>
  21049. /// 三公签证费用(签证费、代办费)
  21050. /// Add Or Update
  21051. /// </summary>
  21052. /// <returns></returns>
  21053. [HttpPost]
  21054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21055. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21056. {
  21057. var _view = await _visaFeeInfoRep.Update(_dto);
  21058. if (_view.Code != 0)
  21059. {
  21060. return Ok(JsonView(false, _view.Msg));
  21061. }
  21062. return Ok(JsonView(true, _view.Msg));
  21063. }
  21064. #endregion
  21065. #region 酒店询价
  21066. /// <summary>
  21067. /// 酒店询价
  21068. /// Init
  21069. /// </summary>
  21070. /// <returns></returns>
  21071. [HttpPost]
  21072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21073. public async Task<IActionResult> PostHotelInquiryInit()
  21074. {
  21075. var res = await _hotelInquiryRep._Init();
  21076. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21077. return Ok(JsonView(true, res.Msg, res.Data));
  21078. }
  21079. /// <summary>
  21080. /// 酒店询价
  21081. /// page Item
  21082. /// </summary>
  21083. /// <param name="_dto"></param>
  21084. /// <returns></returns>
  21085. [HttpPost]
  21086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21087. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21088. {
  21089. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21090. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21091. var view = res.Data as PageDataViewBase;
  21092. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21093. }
  21094. /// <summary>
  21095. /// 酒店询价
  21096. /// info
  21097. /// </summary>
  21098. /// <param name="_dto"></param>
  21099. /// <returns></returns>
  21100. [HttpPost]
  21101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21102. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21103. {
  21104. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21105. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21106. return Ok(JsonView(true, res.Msg, res.Data));
  21107. }
  21108. /// <summary>
  21109. /// 酒店询价
  21110. /// Add Or Edit
  21111. /// </summary>
  21112. /// <param name="_dto"></param>
  21113. /// <returns></returns>
  21114. [HttpPost]
  21115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21116. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21117. {
  21118. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21119. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21120. return Ok(JsonView(true, res.Msg, res.Data));
  21121. }
  21122. /// <summary>
  21123. /// 酒店询价
  21124. /// Del
  21125. /// </summary>
  21126. /// <param name="_dto"></param>
  21127. /// <returns></returns>
  21128. [HttpPost]
  21129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21130. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21131. {
  21132. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21133. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21134. return Ok(JsonView(true, res.Msg, res.Data));
  21135. }
  21136. #endregion
  21137. #region 下载匹配op行程单
  21138. /// <summary>
  21139. /// 匹配op行程单
  21140. /// Init
  21141. /// </summary>
  21142. /// <param name="dto">团组列表请求dto</param>
  21143. /// <returns></returns>
  21144. [HttpPost]
  21145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21146. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21147. {
  21148. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21149. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21150. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21151. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21152. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21153. .Where(it => it.IsDel == 0)
  21154. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21155. .OrderByDescending(it => it.VisitStartDate)
  21156. .ToList();
  21157. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21158. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21159. var diids = groupInfos.Select(it => it.Id).ToList();
  21160. List<string> countrys = new List<string>();
  21161. foreach (var item in country)
  21162. {
  21163. var data = _groupRepository.FormartTeamName(item);
  21164. var dataArray = _groupRepository.GroupSplitCountry(data);
  21165. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21166. }
  21167. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  21168. List<string> areaArray = new List<string>(); //GetGroupCityLine
  21169. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  21170. foreach (var item in areaItem)
  21171. {
  21172. string areaStr = item.Value;
  21173. if (!string.IsNullOrEmpty(areaStr))
  21174. {
  21175. string[] str1 = areaStr.Split("-");
  21176. if (str1.Length > 0)
  21177. {
  21178. areaArray.AddRange(str1);
  21179. }
  21180. }
  21181. }
  21182. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  21183. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  21184. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  21185. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  21186. .ToList();
  21187. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  21188. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  21189. .Where(it => countriesIds.Contains(it.Id))
  21190. .Select(it => new { it.Id, Name = it.Name_CN })
  21191. .ToList();
  21192. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  21193. .Select(it => it.TeamName).ToList();
  21194. stopwatch.Stop();
  21195. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  21196. }
  21197. ///// <summary>
  21198. ///// 匹配op行程单
  21199. ///// Init 查询区域数据
  21200. ///// </summary>
  21201. ///// <param name="dto">团组列表请求dto</param>
  21202. ///// <returns></returns>
  21203. //[HttpPost]
  21204. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21205. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  21206. //{
  21207. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21208. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  21209. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  21210. // if (string.IsNullOrEmpty(countriesDataStr))
  21211. // {
  21212. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  21213. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  21214. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  21215. // }
  21216. // else
  21217. // {
  21218. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  21219. // }
  21220. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  21221. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  21222. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  21223. // List<dynamic> childList = new List<dynamic>();
  21224. // int parentId = dto.CountriesId;
  21225. // if (provinceData.Count > 1)
  21226. // {
  21227. // foreach (var item1 in provinceData)
  21228. // {
  21229. // List<dynamic> childList1 = new List<dynamic>();
  21230. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  21231. // foreach (var item2 in citiesData1)
  21232. // {
  21233. // List<dynamic> childList2 = new List<dynamic>();
  21234. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21235. // foreach (var item3 in countiesData1)
  21236. // {
  21237. // childList2.Add(new
  21238. // {
  21239. // id = item3.Id,
  21240. // parentId = item2.Id,
  21241. // level = "district",
  21242. // name = item3.Name_CN,
  21243. // });
  21244. // }
  21245. // childList1.Add(new
  21246. // {
  21247. // id = item2.Id,
  21248. // parentId = item1.Id,
  21249. // level = "city",
  21250. // name = item2.Name_CN,
  21251. // childList = childList2
  21252. // });
  21253. // }
  21254. // childList.Add(new
  21255. // {
  21256. // id = item1.Id,
  21257. // parentId = parentId,
  21258. // level = "province",
  21259. // name = item1.Name_CN,
  21260. // childList = childList1
  21261. // });
  21262. // }
  21263. // //城市
  21264. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  21265. // foreach (var item2 in citiesData2)
  21266. // {
  21267. // List<dynamic> childList22 = new List<dynamic>();
  21268. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21269. // foreach (var item3 in countiesData1)
  21270. // {
  21271. // childList22.Add(new
  21272. // {
  21273. // id = item3.Id,
  21274. // parentId = item2.Id,
  21275. // level = "district",
  21276. // name = item3.Name_CN,
  21277. // });
  21278. // }
  21279. // childList.Add(new
  21280. // {
  21281. // id = item2.Id,
  21282. // parentId = parentId,
  21283. // level = "city",
  21284. // name = item2.Name_CN,
  21285. // childList = childList22
  21286. // });
  21287. // }
  21288. // }
  21289. // else
  21290. // {
  21291. // foreach (var item2 in citiesData)
  21292. // {
  21293. // string cname = item2.Name_CN;
  21294. // List<dynamic> childList1 = new List<dynamic>();
  21295. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  21296. // foreach (var item3 in countiesData1)
  21297. // {
  21298. // childList1.Add(new
  21299. // {
  21300. // Id = item3.Id,
  21301. // parentId = item2.Id,
  21302. // level = "district",
  21303. // name = item3.Name_CN
  21304. // });
  21305. // }
  21306. // childList.Add(new
  21307. // {
  21308. // id = item2.Id,
  21309. // parentId = parentId,
  21310. // level = "city",
  21311. // name = item2.Name_CN,
  21312. // childList = childList1
  21313. // });
  21314. // }
  21315. // }
  21316. // stopwatch.Stop();
  21317. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  21318. //}
  21319. /// <summary>
  21320. /// 匹配op行程单
  21321. /// 接团信息列表 Page
  21322. /// </summary>
  21323. /// <param name="dto">团组列表请求dto</param>
  21324. /// <returns></returns>
  21325. [HttpPost]
  21326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21327. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  21328. {
  21329. var swatch = new Stopwatch();
  21330. swatch.Start();
  21331. #region 参数验证
  21332. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21333. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21335. #region 页面操作权限验证
  21336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21337. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  21338. #endregion
  21339. #endregion
  21340. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21341. {
  21342. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  21343. //string sqlWhere = "";
  21344. if (!string.IsNullOrEmpty(dto.Country))
  21345. {
  21346. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  21347. }
  21348. if (!string.IsNullOrEmpty(dto.Area))
  21349. {
  21350. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  21351. }
  21352. if (!string.IsNullOrEmpty(dto.TeamName))
  21353. {
  21354. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  21355. }
  21356. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  21357. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  21358. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  21359. swatch.Stop();
  21360. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  21361. }
  21362. else
  21363. {
  21364. return Ok(JsonView(false, "查询失败"));
  21365. }
  21366. }
  21367. /// <summary>
  21368. /// 匹配op行程单
  21369. /// 行程单下载
  21370. /// </summary>
  21371. /// <param name="dto">团组列表请求dto</param>
  21372. /// <returns></returns>
  21373. [HttpPost]
  21374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21375. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  21376. {
  21377. #region 参数验证
  21378. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  21379. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  21380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21381. #region 页面操作权限验证
  21382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  21383. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  21384. #endregion
  21385. #endregion
  21386. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  21387. {
  21388. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  21389. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  21390. }
  21391. else
  21392. {
  21393. return Ok(JsonView(false, "下载失败!"));
  21394. }
  21395. }
  21396. #endregion
  21397. #region 国家信息 数据 注释
  21398. //[HttpPost]
  21399. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  21400. //{
  21401. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  21402. // foreach (var item in dto)
  21403. // {
  21404. // infos.Add(new Grp_GroupsTaskAssignment()
  21405. // {
  21406. // DIId = item,
  21407. // CTId = 82,
  21408. // UId = 248,
  21409. // IsEnable = 1,
  21410. // CreateUserId = 233,
  21411. // CreateTime = DateTime.Now,
  21412. // IsDel = 0
  21413. // });
  21414. // infos.Add(new Grp_GroupsTaskAssignment()
  21415. // {
  21416. // DIId = item,
  21417. // CTId = 82,
  21418. // UId = 286,
  21419. // IsEnable = 1,
  21420. // CreateUserId = 233,
  21421. // CreateTime = DateTime.Now,
  21422. // IsDel = 0
  21423. // });
  21424. // }
  21425. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  21426. // return Ok("操作成功");
  21427. //}
  21428. //public class paramJsonDto
  21429. //{
  21430. // public List<CountriesInfo> str { get; set; }
  21431. //}
  21432. //[HttpPost]
  21433. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  21434. //{
  21435. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  21436. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  21437. // List<Sys_Cities> cities = new List<Sys_Cities>();
  21438. // List<Sys_Cities> districts = new List<Sys_Cities>();
  21439. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21440. // _sqlSugar.BeginTran();
  21441. // int countitiesIndex = 0;
  21442. // foreach (var item in dto.str)
  21443. // {
  21444. // dynamic data = item.c;
  21445. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  21446. // if (data != null)
  21447. // {
  21448. // countitiesIndex++;
  21449. // foreach (var item1 in data)
  21450. // {
  21451. // string cnname = item1.cn;
  21452. // string enname = item1.en;
  21453. // Sys_Cities provinceInfo = new Sys_Cities()
  21454. // {
  21455. // CountriesId = countriesId,
  21456. // Name_CN = cnname,
  21457. // Name_EN = enname,
  21458. // ParentId = 0,
  21459. // IsCapital = 1,
  21460. // CreateUserId = 208,
  21461. // CreateTime = DateTime.Now,
  21462. // IsDel = 0
  21463. // };
  21464. // if (item1.lv == "province") //省份
  21465. // {
  21466. // provinceInfo.Level = 1;
  21467. // int provinceId = 0;
  21468. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  21469. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  21470. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21471. // var data1 = item1.c;
  21472. // foreach (var item2 in data1)
  21473. // {
  21474. // if (item2.lv == "city")
  21475. // {
  21476. // string citycnname = item2.cn;
  21477. // string cityenname = item2.en;
  21478. // Sys_Cities cityInfo = new Sys_Cities()
  21479. // {
  21480. // CountriesId = countriesId,
  21481. // ParentId = provinceId,
  21482. // Level = 2,
  21483. // Name_CN = citycnname,
  21484. // Name_EN = cityenname,
  21485. // IsCapital = 1,
  21486. // CreateUserId = 208,
  21487. // CreateTime = DateTime.Now,
  21488. // IsDel = 0
  21489. // };
  21490. // if (item2.c != null)
  21491. // {
  21492. // int cityId = 0;
  21493. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  21494. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21495. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  21496. // foreach (var item3 in item2.c)
  21497. // {
  21498. // if (item3.lv == "district")
  21499. // {
  21500. // var districtInfo = new Sys_Cities()
  21501. // {
  21502. // CountriesId = countriesId,
  21503. // Name_CN = item3.cn,
  21504. // Name_EN = item3.en,
  21505. // Level = 3,
  21506. // ParentId = cityId,
  21507. // IsCapital = 1,
  21508. // CreateUserId = 208,
  21509. // CreateTime = DateTime.Now,
  21510. // IsDel = 0
  21511. // };
  21512. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21513. // //{
  21514. // districts.Add(districtInfo);
  21515. // //}
  21516. // }
  21517. // }
  21518. // }
  21519. // else
  21520. // {
  21521. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  21522. // //{
  21523. // cities.Add(cityInfo);
  21524. // //}
  21525. // }
  21526. // }
  21527. // }
  21528. // }
  21529. // else if (item1.lv == "city")//城市
  21530. // {
  21531. // provinceInfo.Level = 2;
  21532. // if (item1.c != null)
  21533. // {
  21534. // int cityId = 0;
  21535. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  21536. // if (citiesInfo != null) cityId = citiesInfo.Id;
  21537. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  21538. // foreach (var item3 in item1.c)
  21539. // {
  21540. // if (item3.lv == "district")
  21541. // {
  21542. // var districtInfo = new Sys_Cities()
  21543. // {
  21544. // CountriesId = countriesId,
  21545. // Name_CN = item3.cn,
  21546. // Name_EN = item3.en,
  21547. // Level = 3,
  21548. // ParentId = cityId,
  21549. // IsCapital = 1,
  21550. // CreateUserId = 208,
  21551. // CreateTime = DateTime.Now,
  21552. // IsDel = 0
  21553. // };
  21554. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  21555. // //{
  21556. // districts.Add(districtInfo);
  21557. // //}
  21558. // }
  21559. // }
  21560. // }
  21561. // else
  21562. // {
  21563. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  21564. // //{
  21565. // cities.Add(provinceInfo);
  21566. // //}
  21567. // }
  21568. // }
  21569. // }
  21570. // }
  21571. // }
  21572. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  21573. // cities = cities.Distinct().ToList();
  21574. // districts = districts.Distinct().ToList();
  21575. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  21576. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  21577. // cities.AddRange(districts);
  21578. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  21579. // //_sqlSugar.RollbackTran();
  21580. // _sqlSugar.CommitTran();
  21581. // return Ok(JsonView(false, "操作成功!"));
  21582. //}
  21583. //[HttpPost]
  21584. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  21585. //{
  21586. // List<CountitiesInfo> infos = dto.MyProperty;
  21587. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  21588. // _sqlSugar.BeginTran();
  21589. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  21590. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  21591. // foreach (var item in infos)
  21592. // {
  21593. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  21594. // if (countryInfo != null)
  21595. // {
  21596. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  21597. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  21598. // if (cityInfo1 != null)
  21599. // {
  21600. // cityInfo1.IsCapital = 0;
  21601. // cityInfos.Add(cityInfo1);
  21602. // }
  21603. // }
  21604. // }
  21605. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  21606. // .UpdateColumns(it => it.IsCapital)
  21607. // .WhereColumns(it => it.Id)
  21608. // .ExecuteCommand();
  21609. // //_sqlSugar.RollbackTran();
  21610. // _sqlSugar.CommitTran();
  21611. // return Ok(JsonView(false, "操作成功!"));
  21612. //}
  21613. //public class CounrtiesDto
  21614. //{
  21615. // public List<CountitiesInfo> MyProperty { get; set; }
  21616. //}
  21617. //public class CountitiesInfo
  21618. //{
  21619. // /// <summary>
  21620. // /// 圣约翰
  21621. // /// </summary>
  21622. // public string capital_name_chinese { get; set; }
  21623. // /// <summary>
  21624. // ///
  21625. // /// </summary>
  21626. // public string capital_name { get; set; }
  21627. // /// <summary>
  21628. // ///
  21629. // /// </summary>
  21630. // public string country_type { get; set; }
  21631. // /// <summary>
  21632. // /// 安提瓜和巴布达
  21633. // /// </summary>
  21634. // public string country_name_chinese { get; set; }
  21635. // /// <summary>
  21636. // /// 安提瓜和巴布达
  21637. // /// </summary>
  21638. // public string country_name_chinese_short { get; set; }
  21639. // /// <summary>
  21640. // /// 安提瓜和巴布达
  21641. // /// </summary>
  21642. // public string country_name_chinese_UN { get; set; }
  21643. // /// <summary>
  21644. // ///
  21645. // /// </summary>
  21646. // public string country_name_english_abbreviation { get; set; }
  21647. // /// <summary>
  21648. // ///
  21649. // /// </summary>
  21650. // public string country_name_english_formal { get; set; }
  21651. // /// <summary>
  21652. // ///
  21653. // /// </summary>
  21654. // public string country_name_english_UN { get; set; }
  21655. // /// <summary>
  21656. // ///
  21657. // /// </summary>
  21658. // public string continent_name { get; set; }
  21659. // /// <summary>
  21660. // ///
  21661. // /// </summary>
  21662. // public string subregion_name { get; set; }
  21663. // /// <summary>
  21664. // ///
  21665. // /// </summary>
  21666. // public string country_code2 { get; set; }
  21667. // /// <summary>
  21668. // ///
  21669. // /// </summary>
  21670. // public string country_code3 { get; set; }
  21671. // /// <summary>
  21672. // ///
  21673. // /// </summary>
  21674. // public string phone_code { get; set; }
  21675. //}
  21676. //public class CountriesInfo : BasicInfo
  21677. //{
  21678. // public List<CitiesInfo> c { get; set; }
  21679. //}
  21680. //public class CitiesInfo : BasicInfo
  21681. //{
  21682. // public List<AreaInfo> c { get; set; }
  21683. //}
  21684. //public class AreaInfo : BasicInfo
  21685. //{
  21686. // public List<AreaInfo> c { get; set; }
  21687. //}
  21688. //public class BasicInfo
  21689. //{
  21690. // public string code { get; set; }
  21691. // public string cn { get; set; }
  21692. // public string lv { get; set; }
  21693. // public string en { get; set; }
  21694. //}
  21695. #endregion
  21696. #region 查看邀请方
  21697. /// <summary>
  21698. /// 查看邀请方
  21699. /// 邀请方信息 Init
  21700. /// </summary>
  21701. /// <param name="dto"></param>
  21702. /// <returns></returns>
  21703. [HttpPost]
  21704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21705. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  21706. {
  21707. string sqlWhere = string.Empty;
  21708. if (!string.IsNullOrEmpty(dto.Search))
  21709. {
  21710. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  21711. }
  21712. string sql = string.Format($@"Select
  21713. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  21714. Id,
  21715. UnitName
  21716. From Res_InvitationOfficialActivityData
  21717. Where IsDel = 0
  21718. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  21719. RefAsync<int> total = 0;
  21720. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21721. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  21722. }
  21723. /// <summary>
  21724. /// 查看邀请方
  21725. /// 国家信息 Init
  21726. /// </summary>
  21727. /// <param name="dto"></param>
  21728. /// <returns></returns>
  21729. [HttpPost]
  21730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21731. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  21732. {
  21733. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  21734. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21735. var diids = groupInfos.Select(it => it.Id).ToList();
  21736. List<string> countrys = new List<string>();
  21737. foreach (var item in country)
  21738. {
  21739. var data = _groupRepository.FormartTeamName(item);
  21740. var dataArray = _groupRepository.GroupSplitCountry(data);
  21741. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  21742. }
  21743. countrys = countrys.Distinct().ToList();
  21744. for (int i = 0; i < countrys.Count; i++)
  21745. {
  21746. string item = countrys[i];
  21747. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  21748. {
  21749. countrys.Remove(item);
  21750. i--;
  21751. }
  21752. }
  21753. RefAsync<int> total = 0;
  21754. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  21755. .Where(it => countrys.Contains(it.Name_CN))
  21756. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21757. .Select(it => new { id = it.Id, name = it.Name_CN })
  21758. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21759. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21760. }
  21761. /// <summary>
  21762. /// 查看邀请方
  21763. /// 城市信息 Init
  21764. /// </summary>
  21765. /// <param name="dto"></param>
  21766. /// <returns></returns>
  21767. [HttpPost]
  21768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21769. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  21770. {
  21771. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  21772. RefAsync<int> total = 0;
  21773. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  21774. .Where(it => it.CountriesId == dto.CountiesId)
  21775. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  21776. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  21777. .Select(it => new { id = it.Id, name = it.Name_CN })
  21778. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21779. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  21780. }
  21781. /// <summary>
  21782. /// 查看邀请方
  21783. /// 团组名称 Init
  21784. /// </summary>
  21785. /// <param name="dto"></param>
  21786. /// <returns></returns>
  21787. [HttpPost]
  21788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21789. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  21790. {
  21791. var watch = new Stopwatch();
  21792. watch.Start();
  21793. RefAsync<int> total = 0;
  21794. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  21795. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  21796. .Where((oa, di) => oa.IsDel == 0)
  21797. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  21798. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  21799. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  21800. .Distinct()
  21801. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21802. watch.Stop();
  21803. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  21804. }
  21805. /// <summary>
  21806. /// 查看邀请方
  21807. /// 团组 & 邀请方信息
  21808. /// </summary>
  21809. /// <param name="dto"></param>
  21810. /// <returns></returns>
  21811. [HttpPost]
  21812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21813. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  21814. {
  21815. var watch = new Stopwatch();
  21816. watch.Start();
  21817. RefAsync<int> total = 0;
  21818. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  21819. .AS("Grp_DelegationInfo")
  21820. .Includes(x => x.InvitingInfos)
  21821. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  21822. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  21823. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  21824. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  21825. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  21826. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  21827. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  21828. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  21829. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  21830. infos.ForEach(x =>
  21831. {
  21832. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  21833. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  21834. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  21835. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  21836. });
  21837. watch.Stop();
  21838. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  21839. }
  21840. #endregion
  21841. #region 报批行程
  21842. /// <summary>
  21843. /// 报批行程初始化
  21844. /// </summary>
  21845. /// <param name="dto"></param>
  21846. /// <returns></returns>
  21847. [HttpPost]
  21848. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  21849. {
  21850. const int chiNumber = 5;
  21851. var jw = JsonView(false);
  21852. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  21853. var group = groupList.First();
  21854. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  21855. group = groupList.First(x => x.Id == diid);
  21856. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21857. .Where(x => x.DiId == diid && x.IsDel == 0)
  21858. .ToArray();
  21859. var count = 1;
  21860. foreach (var item in blackCodeList)
  21861. {
  21862. if (string.IsNullOrWhiteSpace(item.Title))
  21863. {
  21864. item.Title = "未设置名称数据" + count;
  21865. }
  21866. count++;
  21867. }
  21868. ;
  21869. if (group == null)
  21870. {
  21871. jw.Msg = "暂无团组!";
  21872. return Ok(jw);
  21873. }
  21874. var data = new
  21875. {
  21876. groupList = groupList.Select(x => new
  21877. {
  21878. x.TeamName,
  21879. x.Id
  21880. }),
  21881. content = new ArrayList(),
  21882. groupInfo = new
  21883. {
  21884. group.VisitDays,
  21885. group.TourCode,
  21886. group.VisitPNumber,
  21887. group.TeamName,
  21888. group.Id,
  21889. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  21890. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  21891. group.ClientUnit
  21892. },
  21893. blackCodeList = blackCodeList.Select(x => new
  21894. {
  21895. x.Title,
  21896. x.Id
  21897. }),
  21898. FileTempList = new ArrayList()
  21899. {
  21900. new { Index = 1,FileName = "旧模板" },
  21901. new { Index = 2,FileName = "省外办" },
  21902. new { Index = 3,FileName = "市外办" },
  21903. }
  21904. };
  21905. var resultArr = new ArrayList();
  21906. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21907. #region 默认不生成行程
  21908. //if (content.Count == 0)
  21909. //{
  21910. // var stay = "-";
  21911. // var cityPath = "-";
  21912. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21913. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21914. // .ToList();
  21915. // //添加城市路径以及住宿地
  21916. // //黑屏代码数据
  21917. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21918. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21919. // {
  21920. // jw = JsonView(true, "黑屏代码有误!", data);
  21921. // return Ok(jw);
  21922. // }
  21923. // data = data with
  21924. // {
  21925. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21926. // {
  21927. // x.Title,
  21928. // x.Id,
  21929. // }).ToArray())
  21930. // };
  21931. // foreach (DataRow row in dtBlack.Rows)
  21932. // {
  21933. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21934. // {
  21935. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21936. // return Ok(jw);
  21937. // }
  21938. // }
  21939. // //黑屏代码获取时间区间
  21940. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21941. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21942. // _sqlSugar.BeginTran();
  21943. // for (int i = 0; i < timeArr.Count; i++)
  21944. // {
  21945. // stay = "-";
  21946. // cityPath = "-";
  21947. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21948. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21949. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21950. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21951. // if (tbSelect.Length > 0)
  21952. // {
  21953. // List<string> threeCodeStr = new List<string>();
  21954. // foreach (var item in tbSelect)
  21955. // {
  21956. // var threeCode = item["Three"].ToString() ?? "";
  21957. // if (threeCode.Length == 6)
  21958. // {
  21959. // var start = threeCode.Substring(0, 3);
  21960. // var end = threeCode.Substring(3, 3);
  21961. // if (threeCodeStr.Count == 0)
  21962. // {
  21963. // threeCodeStr.Add(start);
  21964. // threeCodeStr.Add(end);
  21965. // }
  21966. // else
  21967. // {
  21968. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21969. // {
  21970. // threeCodeStr.Add(end);
  21971. // }
  21972. // else
  21973. // {
  21974. // threeCodeStr.Add(start);
  21975. // threeCodeStr.Add(end);
  21976. // }
  21977. // }
  21978. // }
  21979. // }
  21980. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21981. // var last = threeCodeStr.Last();
  21982. // foreach (var item in threeCodeStr)
  21983. // {
  21984. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21985. // if (item.Equals(last))
  21986. // {
  21987. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21988. // }
  21989. // }
  21990. // cityPath = cityPath.Trim('-');
  21991. // }
  21992. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21993. // appro.Diid = diid ?? -1;
  21994. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21995. // appro.Id = thisId;
  21996. // appro.CreateUserId = dto.UserId;
  21997. // appro.CreateTime = DateTime.Now;
  21998. // content.Add(appro);
  21999. // }
  22000. // _sqlSugar.CommitTran();
  22001. //}
  22002. #endregion
  22003. foreach (var x in content)
  22004. {
  22005. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22006. if (chiList.Count < chiNumber)
  22007. {
  22008. for (int i = chiList.Count; i < chiNumber; i++)
  22009. {
  22010. chiList.Add(new Grp_ApprovalTravelDetails());
  22011. }
  22012. }
  22013. resultArr.Add(new
  22014. {
  22015. x.Id,
  22016. x.Date,
  22017. x.Diid,
  22018. chiList = chiList.Select(x1 => new
  22019. {
  22020. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22021. x1.Details,
  22022. x1.ParentId,
  22023. x1.Id
  22024. })
  22025. });
  22026. }
  22027. data = data with
  22028. {
  22029. content = resultArr,
  22030. };
  22031. jw = JsonView(true, "获取成功!", data);
  22032. return Ok(jw);
  22033. }
  22034. /// <summary>
  22035. /// 报批行程删除
  22036. /// </summary>
  22037. /// <param name="dto"></param>
  22038. /// <returns></returns>
  22039. [HttpPost]
  22040. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22041. {
  22042. var jw = JsonView(false);
  22043. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22044. if (group == null)
  22045. {
  22046. jw.Msg = "团组参数有误!";
  22047. return Ok(jw);
  22048. }
  22049. try
  22050. {
  22051. _sqlSugar.BeginTran();
  22052. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22053. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22054. {
  22055. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22056. DeleteUserId = dto.uesrId,
  22057. IsDel = 1
  22058. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22059. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22060. {
  22061. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22062. DeleteUserId = dto.uesrId,
  22063. IsDel = 1
  22064. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22065. _sqlSugar.CommitTran();
  22066. jw = JsonView(true, "删除成功");
  22067. }
  22068. catch (Exception ex)
  22069. {
  22070. jw = JsonView(false, ex.Message);
  22071. }
  22072. return Ok(jw);
  22073. }
  22074. /// <summary>
  22075. /// 报批行程保存
  22076. /// </summary>
  22077. /// <param name="dto"></param>
  22078. /// <returns></returns>
  22079. [HttpPost]
  22080. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22081. {
  22082. var jw = JsonView(false);
  22083. var Find = dto.Arr.Find(x => x.id == 0);
  22084. if (Find != null)
  22085. {
  22086. jw.Msg = "生成的ID为0!";
  22087. return Ok(jw);
  22088. }
  22089. foreach (var item in dto.Arr)
  22090. {
  22091. foreach (var chi in item.chiList)
  22092. {
  22093. if (chi.parentId == 0)
  22094. {
  22095. chi.parentId = item.id;
  22096. }
  22097. }
  22098. }
  22099. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22100. _sqlSugar.BeginTran();
  22101. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22102. {
  22103. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22104. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22105. {
  22106. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22107. DeleteUserId = dto.UserId,
  22108. IsDel = 1
  22109. }).ExecuteCommand();
  22110. }
  22111. try
  22112. {
  22113. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22114. {
  22115. CreateTime = DateTime.Now,
  22116. CreateUserId = dto.UserId,
  22117. Details = x.details,
  22118. ParentId = x.parentId,
  22119. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22120. Remark = "",
  22121. IsDel = 0
  22122. }).ToList()).ExecuteCommand();
  22123. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22124. {
  22125. Id = x.id,
  22126. Details = x.details,
  22127. ParentId = x.parentId,
  22128. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22129. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22130. {
  22131. Details = x.Details,
  22132. ParentId = x.ParentId,
  22133. Time = x.Time
  22134. }).ExecuteCommand();
  22135. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22136. {
  22137. Id = x.id,
  22138. Date = x.date,
  22139. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22140. {
  22141. Date = x.Date
  22142. }).ExecuteCommand();
  22143. _sqlSugar.CommitTran();
  22144. jw = JsonView(true, "保存成功!");
  22145. }
  22146. catch (Exception ex)
  22147. {
  22148. _sqlSugar.RollbackTran();
  22149. jw = JsonView(false, "保存失败!" + ex.Message);
  22150. }
  22151. return Ok(jw);
  22152. }
  22153. /// <summary>
  22154. /// 报批行程生成
  22155. /// </summary>
  22156. /// <param name="dto"></param>
  22157. /// <returns></returns>
  22158. [HttpPost]
  22159. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22160. {
  22161. var jw = JsonView(false);
  22162. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22163. if (group == null)
  22164. {
  22165. jw.Msg = "暂无该团组!";
  22166. return Ok(jw);
  22167. }
  22168. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  22169. //黑屏代码数据
  22170. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  22171. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22172. {
  22173. jw.Msg = "黑屏代码有误!";
  22174. return Ok(jw);
  22175. }
  22176. foreach (DataRow row in dtBlack.Rows)
  22177. {
  22178. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22179. {
  22180. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  22181. return Ok(jw);
  22182. }
  22183. }
  22184. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  22185. var resultArr = new ArrayList();
  22186. //if (officialActivitiesArr.Count == 0)
  22187. //{
  22188. // jw.Msg = "暂无公务出访信息!";
  22189. // return Ok(jw);
  22190. //}
  22191. try
  22192. {
  22193. _sqlSugar.BeginTran();
  22194. DeleteApprovalJourney(new
  22195. Domain.Dtos.Groups.DeleteApprovalJourney
  22196. {
  22197. Diid = dto.Diid,
  22198. uesrId = dto.Userid
  22199. });
  22200. var stay = "-";
  22201. var cityPath = "-";
  22202. var arriveCountry = string.Empty;
  22203. //添加城市路径以及住宿地
  22204. //黑屏代码获取时间区间
  22205. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22206. var empty = "【未收入该三字码!请机票同事录入】";
  22207. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22208. #region 配置公务活动时间
  22209. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  22210. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  22211. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  22212. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  22213. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  22214. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22215. {
  22216. 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" }),
  22217. 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"}),
  22218. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22219. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  22220. };
  22221. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  22222. {
  22223. 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" }),
  22224. 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"}),
  22225. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  22226. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  22227. };
  22228. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  22229. {
  22230. 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" }),
  22231. 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"}),
  22232. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  22233. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  22234. };
  22235. #endregion
  22236. var nextDayNum = 0;
  22237. for (int i = 0; i < timeArr.Count; i++)
  22238. {
  22239. stay = "-";
  22240. cityPath = "-";
  22241. var chiarr = new List<Grp_ApprovalTravelDetails>();
  22242. DateTime NewData = DateTime.Parse(timeArr[i]);
  22243. //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();
  22244. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22245. if (nextDayNum > 0)
  22246. {
  22247. nextDayNum--;
  22248. }
  22249. if (tbSelect.Length > 0)
  22250. {
  22251. List<string> threeCodeStr = new List<string>();
  22252. bool isTrade = false;
  22253. string trip = string.Empty;
  22254. foreach (var item in tbSelect)
  22255. {
  22256. if (nextDayNum == 0)
  22257. {
  22258. nextDayNum = Convert.ToInt32(item["Sign"]);
  22259. }
  22260. var airStartTime = item["StartTime"].ToString() ?? "0000";
  22261. var airEndTime = item["EndTime"].ToString() ?? "0000";
  22262. var takeOffTime = DateTime.Parse(timeArr[i]);
  22263. var fallToTime = DateTime.Parse(timeArr[i]);
  22264. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  22265. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  22266. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  22267. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  22268. if (nextDayNum > 0)
  22269. {
  22270. fallToTime = fallToTime.AddDays(nextDayNum);
  22271. }
  22272. trip = string.Empty;
  22273. var start = string.Empty;
  22274. var end = string.Empty;
  22275. var threeCode = item["Three"].ToString() ?? "";
  22276. if (threeCode.Length == 6)
  22277. {
  22278. start = threeCode.Substring(0, 3);
  22279. end = threeCode.Substring(3, 3);
  22280. if (threeCodeStr.Count == 0)
  22281. {
  22282. threeCodeStr.Add(start);
  22283. threeCodeStr.Add(end);
  22284. }
  22285. else
  22286. {
  22287. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22288. {
  22289. threeCodeStr.Add(end);
  22290. }
  22291. else
  22292. {
  22293. threeCodeStr.Add(start);
  22294. threeCodeStr.Add(end);
  22295. }
  22296. }
  22297. }
  22298. //处理机票信息
  22299. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  22300. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  22301. if (start_Object == null)
  22302. {
  22303. start_Object = new Res_ThreeCode()
  22304. {
  22305. AirPort = empty,
  22306. AirPort_En = empty,
  22307. City = empty,
  22308. Country = empty,
  22309. Four = empty,
  22310. Three = empty,
  22311. };
  22312. }
  22313. if (end_Object == null)
  22314. {
  22315. end_Object = new Res_ThreeCode()
  22316. {
  22317. AirPort = empty,
  22318. AirPort_En = empty,
  22319. City = empty,
  22320. Country = empty,
  22321. Four = empty,
  22322. Three = empty,
  22323. };
  22324. }
  22325. //机型判断
  22326. string airModel = item["AirModel"].ToString();
  22327. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  22328. string flightTime = item["FlightTime"].ToString();
  22329. flightTime = ParseBlackTime(flightTime);
  22330. //航班号
  22331. string flightcode = item["Fliagtcode"].ToString();
  22332. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  22333. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  22334. if (aircompany == null)
  22335. {
  22336. aircompany = new Res_AirCompany
  22337. {
  22338. CnName = hsEmpty,
  22339. EnName = hsEmpty,
  22340. ShortCode = hsEmpty,
  22341. };
  22342. }
  22343. //航班前公务安排
  22344. if (tbSelect.First().Equals(item) && i != 0)
  22345. {
  22346. foreach (var takeoff in takeoffTimes)
  22347. {
  22348. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  22349. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  22350. {
  22351. foreach (var addTime in takeoff.Item2)
  22352. {
  22353. chiarr.Add(new Grp_ApprovalTravelDetails
  22354. {
  22355. Time = addTime,
  22356. CreateTime = DateTime.Now,
  22357. CreateUserId = dto.Userid,
  22358. ParentId = 0,
  22359. Details = "公务活动"
  22360. });
  22361. }
  22362. break;
  22363. }
  22364. }
  22365. }
  22366. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  22367. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  22368. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  22369. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  22370. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  22371. if (isTrade)
  22372. {
  22373. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  22374. trip += "(转机不出机场)。";
  22375. }
  22376. //else
  22377. //{
  22378. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  22379. //}
  22380. chiarr.Add(new Grp_ApprovalTravelDetails
  22381. {
  22382. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  22383. CreateTime = DateTime.Now,
  22384. CreateUserId = dto.Userid,
  22385. ParentId = 0,
  22386. Details = trip
  22387. });
  22388. //最后一条到达的时间安排公务
  22389. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  22390. {
  22391. bool isCheckCountry = false;
  22392. if (end_Object.Country != arriveCountry)
  22393. {
  22394. arriveCountry = end_Object.Country;
  22395. isCheckCountry = true;
  22396. }
  22397. if (nextDayNum == 0)
  22398. {
  22399. //需要入境的情况
  22400. if (isCheckCountry)
  22401. {
  22402. foreach (var fallTime in fallTimesCheckCountry)
  22403. {
  22404. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22405. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22406. {
  22407. foreach (var addTime in fallTime.Item2)
  22408. {
  22409. chiarr.Add(new Grp_ApprovalTravelDetails
  22410. {
  22411. Time = addTime,
  22412. CreateTime = DateTime.Now,
  22413. CreateUserId = dto.Userid,
  22414. ParentId = 0,
  22415. Details = "公务活动"
  22416. });
  22417. }
  22418. break;
  22419. }
  22420. }
  22421. }
  22422. else
  22423. {
  22424. foreach (var fallTime in fallTimesNotCheckCountry)
  22425. {
  22426. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  22427. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  22428. {
  22429. foreach (var addTime in fallTime.Item2)
  22430. {
  22431. chiarr.Add(new Grp_ApprovalTravelDetails
  22432. {
  22433. Time = addTime,
  22434. CreateTime = DateTime.Now,
  22435. CreateUserId = dto.Userid,
  22436. ParentId = 0,
  22437. Details = "公务活动"
  22438. });
  22439. }
  22440. break;
  22441. }
  22442. }
  22443. }
  22444. }
  22445. }
  22446. }
  22447. //添加乘车语句
  22448. //chiarr.Add(new Grp_ApprovalTravelDetails
  22449. //{
  22450. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  22451. // CreateTime = DateTime.Now,
  22452. // CreateUserId = dto.Userid,
  22453. // ParentId = 0,
  22454. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  22455. //});
  22456. //if (i != timeArr.Count - 1)
  22457. //{
  22458. // fallToTime = fallToTime.AddHours(2.5);
  22459. // foreach (var item in Times)
  22460. // {
  22461. // //排列公务时间
  22462. // if (fallToTime.Hour < item.Item1)
  22463. // {
  22464. // chiarr.Add(new Grp_ApprovalTravelDetails
  22465. // {
  22466. // Time = $"{item.Item2} - {item.Item3}",
  22467. // CreateTime = DateTime.Now,
  22468. // CreateUserId = dto.Userid,
  22469. // ParentId = 0,
  22470. // Details = "公务活动"
  22471. // });
  22472. // }
  22473. // }
  22474. //}
  22475. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22476. var last = threeCodeStr.Last();
  22477. foreach (var item in threeCodeStr)
  22478. {
  22479. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22480. if (item.Equals(last))
  22481. {
  22482. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22483. }
  22484. }
  22485. cityPath = cityPath.Trim('-');
  22486. }
  22487. else
  22488. {
  22489. foreach (var item in Times)
  22490. {
  22491. chiarr.Add(new Grp_ApprovalTravelDetails
  22492. {
  22493. Time = $"{item.Item2} - {item.Item3}",
  22494. CreateTime = DateTime.Now,
  22495. CreateUserId = dto.Userid,
  22496. ParentId = 0,
  22497. Details = "公务活动"
  22498. });
  22499. }
  22500. }
  22501. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22502. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22503. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  22504. appro.Diid = dto.Diid;
  22505. appro.CreateUserId = dto.Userid;
  22506. appro.CreateTime = DateTime.Now;
  22507. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22508. appro.Id = thisId;
  22509. //foreach (var item in gwinfo)
  22510. //{
  22511. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  22512. // chi.Details = "拜访" + item.Client;
  22513. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  22514. // {
  22515. // chi.Details += "," + item.ReqSample;
  22516. // }
  22517. // chi.ParentId = thisId;
  22518. // chi.Time = item.Time;
  22519. // chiarr.Add(chi);
  22520. //}
  22521. if (chiarr.Count < 6)
  22522. {
  22523. for (int j = chiarr.Count; j < 6; j++)
  22524. {
  22525. chiarr.Add(new
  22526. Grp_ApprovalTravelDetails());
  22527. }
  22528. }
  22529. resultArr.Add(new
  22530. {
  22531. appro.Id,
  22532. appro.Date,
  22533. appro.Diid,
  22534. chiList = chiarr.Select(x1 => new
  22535. {
  22536. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22537. x1.Details,
  22538. x1.ParentId,
  22539. x1.Id
  22540. })
  22541. });
  22542. }
  22543. _sqlSugar.CommitTran();
  22544. jw = JsonView(true, "生成成功!", resultArr);
  22545. }
  22546. catch (Exception ex)
  22547. {
  22548. jw.Code = 400;
  22549. jw.Msg = "生成失败!" + ex.Message;
  22550. }
  22551. return Ok(jw);
  22552. }
  22553. /// <summary>
  22554. /// 报批行程word导出
  22555. /// </summary>
  22556. /// <param name="dto"></param>
  22557. /// <returns></returns>
  22558. [HttpPost]
  22559. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  22560. {
  22561. var jw = JsonView(false);
  22562. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22563. if (group == null)
  22564. {
  22565. jw.Msg = "暂无该团组!";
  22566. return Ok(jw);
  22567. }
  22568. //模板路径
  22569. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  22570. var fileName = string.Empty;
  22571. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  22572. bool bold = false;
  22573. if (dto.FileIndex == 1)
  22574. {
  22575. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  22576. }
  22577. else if (dto.FileIndex == 2)
  22578. {
  22579. fileName = "省外办-报批.docx";
  22580. bold = false;
  22581. titleFont = "方正黑体简体";
  22582. timeFont = "Times New Roman";
  22583. contentFont = "方正仿宋_GBK";
  22584. }
  22585. else if (dto.FileIndex == 3)
  22586. {
  22587. fileName = "市外办-报批.docx";
  22588. titleFont = "方正黑体简体";
  22589. timeFont = "Times New Roman";
  22590. contentFont = "方正仿宋简体";
  22591. }
  22592. tempPath = tempPath + fileName;
  22593. //载入模板
  22594. Document doc = new Document(tempPath);
  22595. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22596. //获取所填表格的序数
  22597. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22598. Aspose.Words.Tables.Row titleRowClone = null;
  22599. Aspose.Words.Tables.Row CenterRowClone = null;
  22600. int index = 0;
  22601. int indexChi = 0;
  22602. int SetIndex = 0;
  22603. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  22604. //获取数据,放到datatable
  22605. foreach (var item in ApprovalTravelArr)
  22606. {
  22607. if (index > 0)
  22608. {
  22609. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  22610. tableOne.AppendChild(titleRowClone);
  22611. }
  22612. var textTime = item.Date;
  22613. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  22614. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  22615. SetIndex++;
  22616. if (ChiRep.Count > 0)
  22617. {
  22618. foreach (var itemChi in ChiRep)
  22619. {
  22620. var txtTime = itemChi.Time;
  22621. var txtDetail = itemChi.Details;
  22622. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  22623. {
  22624. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  22625. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22626. //indexChi++;
  22627. //SetIndex++;
  22628. break;
  22629. }
  22630. if (indexChi > 0)
  22631. {
  22632. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22633. tableOne.AppendChild(CenterRowClone);
  22634. }
  22635. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  22636. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  22637. indexChi++;
  22638. SetIndex++;
  22639. }
  22640. }
  22641. //else
  22642. //{
  22643. // if (indexChi > 0)
  22644. // {
  22645. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  22646. // tableOne.AppendChild(CenterRowClone);
  22647. // }
  22648. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  22649. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  22650. // indexChi++;
  22651. // SetIndex++;
  22652. //}
  22653. index++;
  22654. }
  22655. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  22656. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22657. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  22658. jw.Code = 200;
  22659. jw.Msg = "";
  22660. return Ok(jw);
  22661. }
  22662. private string ParseBlackTime(string time)
  22663. {
  22664. // 匹配可能只有分钟的情况
  22665. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  22666. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  22667. if (match.Success)
  22668. {
  22669. string hours = match.Groups[1].Value;
  22670. string minutes = match.Groups[2].Value;
  22671. // 如果小时部分为空,则只显示分钟
  22672. if (string.IsNullOrEmpty(hours))
  22673. {
  22674. return $"{minutes}分钟";
  22675. }
  22676. // 如果分钟部分为空,则只显示小时
  22677. else if (string.IsNullOrEmpty(minutes))
  22678. {
  22679. return $"{hours}小时";
  22680. }
  22681. // 否则显示完整格式
  22682. else
  22683. {
  22684. return $"{hours}小时{minutes}分钟";
  22685. }
  22686. }
  22687. else
  22688. {
  22689. return "未知时长";
  22690. }
  22691. }
  22692. private string intToString(int numberVal)
  22693. {
  22694. string numberval = numberVal.ToString();
  22695. Dictionary<char, string> Number = new Dictionary<char, string>();
  22696. Number.Add('1', "一");
  22697. Number.Add('2', "二");
  22698. Number.Add('3', "三");
  22699. Number.Add('4', "四");
  22700. Number.Add('5', "五");
  22701. Number.Add('6', "六");
  22702. Number.Add('7', "七");
  22703. Number.Add('8', "八");
  22704. Number.Add('9', "九");
  22705. string stringNumberVal = string.Empty;
  22706. for (int i = 0; i < numberval.Length; i++)
  22707. {
  22708. if (i == 0)
  22709. {
  22710. stringNumberVal += Number[numberval[i]];
  22711. }
  22712. else if (i >= 1)
  22713. {
  22714. if (numberval[i] == '0')
  22715. {
  22716. stringNumberVal = "十";
  22717. }
  22718. else
  22719. {
  22720. stringNumberVal += "十" + Number[numberval[i]];
  22721. }
  22722. }
  22723. }
  22724. return stringNumberVal;
  22725. }
  22726. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  22727. {
  22728. //获取table中的某个单元格,从0开始
  22729. Cell lshCell = table.Rows[rows].Cells[cells];
  22730. //将单元格中段落移除
  22731. foreach (Paragraph item in lshCell.Paragraphs)
  22732. {
  22733. lshCell.Paragraphs.Remove(item);
  22734. }
  22735. if (val.Contains("\r\n"))
  22736. {
  22737. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  22738. foreach (var item in spArr)
  22739. {
  22740. //新建一个段落
  22741. Paragraph p = new Paragraph(doc);
  22742. var r = new Run(doc, item);
  22743. //设置字体
  22744. if (!string.IsNullOrEmpty(font))
  22745. {
  22746. r.Font.Name = font;
  22747. }
  22748. r.Font.Bold = bold;
  22749. //把设置的值赋给之前新建的段落
  22750. p.AppendChild(r);
  22751. //将此段落加到单元格内
  22752. lshCell.AppendChild(p);
  22753. }
  22754. }
  22755. else
  22756. {
  22757. //新建一个段落
  22758. Paragraph p = new Paragraph(doc);
  22759. var r = new Run(doc, val);
  22760. //设置字体
  22761. if (!string.IsNullOrEmpty(font))
  22762. {
  22763. r.Font.Name = font;
  22764. }
  22765. r.Font.Bold = bold;
  22766. //把设置的值赋给之前新建的段落
  22767. p.AppendChild(r);
  22768. //将此段落加到单元格内
  22769. lshCell.AppendChild(p);
  22770. }
  22771. }
  22772. /// <summary>
  22773. /// 报批行程AI续写
  22774. /// </summary>
  22775. /// <returns></returns>
  22776. [HttpPost]
  22777. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  22778. {
  22779. var jw = JsonView(false);
  22780. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  22781. {
  22782. jw.Msg = "参数有误!";
  22783. return Ok(jw);
  22784. }
  22785. KiMiApiClient kiMi = new KiMiApiClient();
  22786. List<SeedMessages> messages = new List<SeedMessages>() {
  22787. new SeedMessages
  22788. {
  22789. Role = KimiRole.system,
  22790. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  22791. },
  22792. new SeedMessages
  22793. {
  22794. Role = KimiRole.user,
  22795. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  22796. }
  22797. };
  22798. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  22799. string data = kimi_result.Choices[0]?.Message.Content;
  22800. if (string.IsNullOrWhiteSpace(data))
  22801. {
  22802. jw.Data = "Ai续写失败!";
  22803. }
  22804. else
  22805. {
  22806. jw = JsonView(true, "success!", data);
  22807. }
  22808. return Ok(jw);
  22809. }
  22810. #endregion
  22811. #region 团组接待意见调查
  22812. /// <summary>
  22813. /// 团组接待意见调查 - 信息管理
  22814. /// 基础数据(团组)
  22815. /// </summary>
  22816. /// <returns></returns>
  22817. [HttpGet]
  22818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22819. public async Task<IActionResult> OpinionaireInit()
  22820. {
  22821. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  22822. .Select(x => new
  22823. {
  22824. x.Id,
  22825. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  22826. })
  22827. .OrderByDescending(x => x.Id)
  22828. .ToListAsync();
  22829. return Ok(JsonView(groupData, groupData.Count));
  22830. }
  22831. /// <summary>
  22832. /// 团组接待意见调查 - 信息管理
  22833. /// 列表
  22834. /// </summary>
  22835. /// <param name="groupId"></param>
  22836. /// <returns></returns>
  22837. [HttpGet("{groupId}")]
  22838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22839. public async Task<IActionResult> OpinionaireManageList(int groupId)
  22840. {
  22841. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22842. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  22843. .Select(x => new
  22844. {
  22845. x.Id,
  22846. x.TourGuideName,
  22847. x.CityName,
  22848. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  22849. x.CreateTime
  22850. })
  22851. .OrderBy(x => x.Id)
  22852. .ToListAsync();
  22853. return Ok(JsonView(data));
  22854. }
  22855. /// <summary>
  22856. /// 团组接待意见调查 - 信息管理
  22857. /// 保存
  22858. /// </summary>
  22859. /// <param name="dto"></param>
  22860. /// <returns></returns>
  22861. [HttpPost]
  22862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22863. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  22864. {
  22865. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22866. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22867. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22868. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  22869. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  22870. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  22871. _opinionaireRep.BeginTran();
  22872. if (addData != null && addData.Count > 0)
  22873. {
  22874. foreach (var item in addData)
  22875. {
  22876. item.CreateUserId = currUserInfo.UserId;
  22877. item.DiId = dto.DiId;
  22878. }
  22879. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  22880. }
  22881. if (updData != null && updData.Count > 0)
  22882. {
  22883. var upd = await _opinionaireRep._sqlSugar
  22884. .Updateable(updData)
  22885. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  22886. .WhereColumns(x => new { x.Id })
  22887. .ExecuteCommandAsync();
  22888. }
  22889. _opinionaireRep.CommitTran();
  22890. return Ok(JsonView("操作成功!"));
  22891. }
  22892. /// <summary>
  22893. /// 团组接待意见调查 - 信息管理
  22894. /// 删除
  22895. /// </summary>
  22896. /// <param name="id"></param>
  22897. /// <returns></returns>
  22898. [HttpDelete("{id}")]
  22899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22900. public async Task<IActionResult> OpinionaireManageDel(int id)
  22901. {
  22902. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  22903. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  22904. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22905. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22906. if (!del) return Ok(JsonView("操作失败!"));
  22907. return Ok(JsonView("操作成功!"));
  22908. }
  22909. /// <summary>
  22910. /// 团组接待意见调查 - 用户
  22911. /// 列表
  22912. /// </summary>
  22913. /// <param name="diId"></param>
  22914. /// <returns></returns>
  22915. [HttpGet("{diId}")]
  22916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22917. public async Task<IActionResult> OpinionaireUserList(int diId)
  22918. {
  22919. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22920. var sql = string.Format(@"
  22921. SELECT
  22922. o.Id,
  22923. o.DiId,
  22924. di.TeamName AS 'GroupName',
  22925. di.VisitPNumber AS 'PeopleNumber',
  22926. di.ClientName AS 'LeadGroup',
  22927. di.VisitCountry AS 'Travel',
  22928. di.VisitDays AS 'Days',
  22929. o.CityName,
  22930. o.TourGuideName,
  22931. o.Catering,
  22932. o.CateringReason,
  22933. o.Stay,
  22934. o.StayReason,
  22935. o.[Route],
  22936. o.RouteReason,
  22937. o.OfficialActivity,
  22938. o.OfficialActivityReason,
  22939. o.TourGuide,
  22940. o.TourGuideReason,
  22941. o.[Translate],
  22942. o.TranslateReason,
  22943. o.Trip,
  22944. o.TripReason,
  22945. o.ESFileName,
  22946. o.SignatureDate,
  22947. o.Remark
  22948. FROM
  22949. Grp_Opinionaire o
  22950. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22951. WHERE
  22952. o.IsDel = 0
  22953. AND o.DiId = {0}
  22954. ORDER BY
  22955. o.Id ASC", diId);
  22956. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22957. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22958. return Ok(JsonView(data));
  22959. }
  22960. /// <summary>
  22961. /// 团组接待意见调查 - 用户
  22962. /// 保存
  22963. /// </summary>
  22964. /// <param name="dto"></param>
  22965. /// <returns></returns>
  22966. [HttpPost]
  22967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22968. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22969. {
  22970. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22971. foreach (var item in dto)
  22972. {
  22973. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22974. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22975. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22976. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22977. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22978. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22979. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22980. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22981. }
  22982. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22983. if (!Directory.Exists(filePathBase))
  22984. {
  22985. Directory.CreateDirectory(filePathBase);
  22986. }
  22987. #region 上传文件
  22988. var filePaths = new List<string>();
  22989. foreach (var item in dto)
  22990. {
  22991. var file = item.File;
  22992. // 将文件保存到指定位置
  22993. var filePath = Path.Combine(filePathBase, file.FileName);
  22994. using (var stream = new FileStream(filePath, FileMode.Create))
  22995. {
  22996. await file.CopyToAsync(stream);
  22997. }
  22998. //验证文件是否上传成功
  22999. if (!System.IO.File.Exists(filePath))
  23000. {
  23001. foreach (var filePathStr in filePaths)
  23002. {
  23003. System.IO.File.Delete(filePathStr);
  23004. }
  23005. return Ok(JsonView(false, "文件上传失败!"));
  23006. }
  23007. item.ESFileName = file.FileName;
  23008. }
  23009. #endregion
  23010. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23011. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23012. .UpdateColumns(x => new
  23013. {
  23014. x.Catering,
  23015. x.CateringReason,
  23016. x.Stay,
  23017. x.StayReason,
  23018. x.Route,
  23019. x.RouteReason,
  23020. x.OfficialActivity,
  23021. x.OfficialActivityReason,
  23022. x.TourGuide,
  23023. x.TourGuideReason,
  23024. x.Translate,
  23025. x.TranslateReason,
  23026. x.Trip,
  23027. x.TripReason,
  23028. x.ESFileName,
  23029. x.SignatureDate,
  23030. x.Remark
  23031. })
  23032. .WhereColumns(x => new { x.Id })
  23033. .ExecuteCommandAsync();
  23034. if (upd < 1)
  23035. {
  23036. foreach (var filePathStr in filePaths)
  23037. {
  23038. System.IO.File.Delete(filePathStr);
  23039. }
  23040. return Ok(JsonView(false));
  23041. }
  23042. return Ok(JsonView(true));
  23043. }
  23044. #endregion
  23045. #region 团组餐厅相关信息
  23046. /// <summary>
  23047. /// 团组相关餐厅信息
  23048. /// 基础数据(团组)
  23049. /// </summary>
  23050. /// <returns></returns>
  23051. [HttpGet]
  23052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23053. public async Task<IActionResult> RestaurantInit()
  23054. {
  23055. return Ok(await _restaurantRep.InitAsync());
  23056. }
  23057. /// <summary>
  23058. /// 团组相关餐厅信息
  23059. /// Item
  23060. /// </summary>
  23061. /// <param name="dto"></param>
  23062. /// <returns></returns>
  23063. [HttpPost]
  23064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23065. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23066. {
  23067. int portType = dto.PortType,
  23068. groupId = dto.GroupId;
  23069. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23070. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23071. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23072. }
  23073. /// <summary>
  23074. /// 团组相关餐厅信息
  23075. /// List
  23076. /// </summary>
  23077. /// <param name="dto"></param>
  23078. /// <returns></returns>
  23079. [HttpPost]
  23080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23081. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23082. {
  23083. int portType = dto.PortType,
  23084. groupId = dto.GroupId;
  23085. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23086. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23087. var sql = string.Format(@" SELECT
  23088. ri.Id,
  23089. ri.GroupId,
  23090. ri.Date,
  23091. ri.StartTime,
  23092. ri.EndTime,
  23093. CASE WHEN ri.Type = 1 THEN '早餐'
  23094. WHEN ri.Type = 2 THEN '午餐'
  23095. WHEN ri.Type = 3 THEN '晚餐'
  23096. ELSE '其他'
  23097. END AS 'Type',
  23098. ri.Name,
  23099. ri.Address,
  23100. ri.Tel,
  23101. ri.Remark,
  23102. ri.CreateTime,
  23103. u.CnName AS CreateUserName
  23104. FROM
  23105. Grp_RestaurantInfo ri
  23106. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23107. WHERE
  23108. ri.IsDel = 0
  23109. AND ri.GroupId = {0}
  23110. ORDER BY
  23111. ri.Date ASC
  23112. ", groupId);
  23113. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23114. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23115. return Ok(JsonView(infos));
  23116. }
  23117. /// <summary>
  23118. /// 团组相关餐厅信息
  23119. /// Info
  23120. /// </summary>
  23121. /// <param name="dto"></param>
  23122. /// <returns></returns>
  23123. [HttpPost]
  23124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23125. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23126. {
  23127. int portType = dto.PortType,
  23128. id = dto.Id;
  23129. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23130. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23131. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23132. }
  23133. /// <summary>
  23134. /// 团组相关餐厅信息
  23135. /// Op
  23136. /// </summary>
  23137. /// <param name="dto"></param>
  23138. /// <returns></returns>
  23139. [HttpPost]
  23140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23141. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23142. {
  23143. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23144. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23145. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23146. return Ok(await _restaurantRep.OpAsync(dto));
  23147. }
  23148. /// <summary>
  23149. /// 团组相关餐厅信息
  23150. /// Del
  23151. /// </summary>
  23152. /// <param name="dto"></param>
  23153. /// <returns></returns>
  23154. [HttpPost]
  23155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23156. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23157. {
  23158. int userId = dto.DeleteUserId;
  23159. var id = dto.Id;
  23160. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23161. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23162. return Ok(await _restaurantRep.DelAsync(dto));
  23163. }
  23164. #endregion
  23165. #region 团组会务成本
  23166. /// <summary>
  23167. /// 团组会务成本数据初始化
  23168. /// </summary>
  23169. /// <returns></returns>
  23170. [HttpPost]
  23171. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  23172. {
  23173. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23174. .OrderByDescending(x => x.CreateTime)
  23175. .Where(x => x.IsDel == 0)
  23176. .Select<DelegationEasyView>();
  23177. DelegationEasyView di = Dto.GroupId == 0 ?
  23178. expr.First() :
  23179. expr.First(x => x.Id == Dto.GroupId);
  23180. if (di == null)
  23181. {
  23182. return Ok(JsonView(false, "团组信息不存在!"));
  23183. }
  23184. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  23185. .Where(x => x.IsDel == 0 && x.STid == 21)
  23186. .Select(x => new { x.Id, Text = x.Name })
  23187. .ToListAsync();
  23188. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  23189. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  23190. .Select(x => x.Id)
  23191. .ToList();
  23192. //仅检索会务团组
  23193. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  23194. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  23195. .OrderByDescending(x => x.VisitDate)
  23196. .Select(x => new { x.Id, x.TeamName })
  23197. .ToListAsync();
  23198. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  23199. var userList = await _sqlSugar.Queryable<Sys_Users>()
  23200. .Where(x => x.IsDel == 0)
  23201. .Select(x => new { x.Id, x.CnName })
  23202. .ToListAsync();
  23203. var units = await _sqlSugar.Queryable<Sys_SetData>()
  23204. .Where(x => x.IsDel == 0 && x.STid == 119)
  23205. .Select(x => new { x.Id, Text = x.Name })
  23206. .ToListAsync();
  23207. var FileType = new[]
  23208. {
  23209. new { Id = 0 , Name = "成本下载" },
  23210. new { Id = 1 , Name = "报价下载" },
  23211. new { Id = 2 , Name = "总表下载" },
  23212. };
  23213. var GM = new List<int>();
  23214. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  23215. try
  23216. {
  23217. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  23218. }
  23219. catch (Exception ex)
  23220. {
  23221. GM = new List<int>() { 21 };
  23222. }
  23223. var isReview = Dto.UserId == 21;
  23224. var isGM = GM.Contains(Dto.UserId);
  23225. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23226. .Where(x => x.IsDel == 0)
  23227. .Select<ConferenceAffairsCostView>()
  23228. .First(x => x.Diid == di.Id);
  23229. if (ConferenceAffairsCost == null)
  23230. {
  23231. ConferenceAffairsCost = new ConferenceAffairsCostView();
  23232. ConferenceAffairsCost.Diid = di.Id;
  23233. }
  23234. #region 权限校验
  23235. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  23236. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  23237. .Select(x => x.UserId)
  23238. .Distinct()
  23239. .ToList();
  23240. if (!ids.Contains(Dto.UserId) && !isGM)
  23241. {
  23242. return Ok(JsonView(201, "暂无权限!", new
  23243. {
  23244. typeData,
  23245. groupList,
  23246. currenyList,
  23247. isGM,
  23248. userList,
  23249. units,
  23250. isReview,
  23251. operatorUser = ids,
  23252. di,
  23253. FileType
  23254. }));
  23255. }
  23256. #endregion
  23257. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  23258. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  23259. .Select<ConferenceAffairsCostChildView>()
  23260. .OrderBy(x => x.Index)
  23261. .ToList();
  23262. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  23263. {
  23264. ConferenceAffairsCostChi[i - 1].Index = i;
  23265. }
  23266. var backData = new
  23267. {
  23268. ConferenceAffairsCost,
  23269. ConferenceAffairsCostChi,
  23270. typeData,
  23271. groupList,
  23272. currenyList,
  23273. isGM,
  23274. userList,
  23275. units,
  23276. isReview,
  23277. operatorUser = ids,
  23278. di,
  23279. FileType
  23280. };
  23281. return Ok(JsonView(true, "SUCCESS", backData));
  23282. }
  23283. /// <summary>
  23284. /// 会务成本保存
  23285. /// </summary>
  23286. /// <returns></returns>
  23287. [HttpPost]
  23288. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  23289. {
  23290. _sqlSugar.BeginTran();
  23291. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  23292. var childResult = new
  23293. {
  23294. success = 0,
  23295. error = 0
  23296. };
  23297. try
  23298. {
  23299. if (data.Id == 0)
  23300. {
  23301. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23302. .Where(x => x.Diid == Dto.GroupId)
  23303. .SetColumns(x => new Grp_ConferenceAffairsCost
  23304. {
  23305. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23306. DeleteUserId = Dto.UserId
  23307. })
  23308. .ExecuteCommand();
  23309. data.Diid = Dto.GroupId;
  23310. data.CreateTime = DateTime.Now;
  23311. data.CreateUserId = Dto.UserId;
  23312. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  23313. .ExecuteReturnIdentity();
  23314. }
  23315. else
  23316. {
  23317. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  23318. .ExecuteCommand();
  23319. data.Id = data.Id;
  23320. }
  23321. if (Dto.ConferenceAffairsCostChild.Any())
  23322. {
  23323. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  23324. var insertArr = datas.Where(x => x.Id == 0).ToList();
  23325. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  23326. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  23327. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  23328. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  23329. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  23330. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  23331. .ExecuteCommand() : 0;
  23332. childResult = childResult with
  23333. {
  23334. error = notUpdateArr.Count(),
  23335. success = inrsetCount + updateCount
  23336. };
  23337. }
  23338. _sqlSugar.CommitTran();
  23339. }
  23340. catch (Exception ex)
  23341. {
  23342. _sqlSugar.RollbackTran();
  23343. return Ok(JsonView(false, "失败!" + ex.Message));
  23344. }
  23345. return Ok(JsonView(true, "操作成功!", childResult));
  23346. }
  23347. [HttpPost]
  23348. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  23349. {
  23350. var count = 0;
  23351. if (Dto.ConferenceAffairsCostChildids.Any())
  23352. {
  23353. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  23354. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  23355. SetColumns(x => new Grp_ConferenceAffairsCostChild
  23356. {
  23357. ReviewStatus = Dto.ReviewStatus
  23358. }).
  23359. ExecuteCommand();
  23360. }
  23361. return Ok(JsonView(true, "操作成功!", count));
  23362. }
  23363. /// <summary>
  23364. /// 会务成本所有数据清除
  23365. /// </summary>
  23366. /// <param name="Dto"></param>
  23367. /// <returns></returns>
  23368. [HttpPost]
  23369. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  23370. {
  23371. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23372. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  23373. _sqlSugar.BeginTran();
  23374. try
  23375. {
  23376. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  23377. .Where(x => x.Diid == Dto.GroupId)
  23378. .SetColumns(x => new Grp_ConferenceAffairsCost
  23379. {
  23380. IsDel = 1,
  23381. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23382. DeleteUserId = Dto.UserId
  23383. })
  23384. .ExecuteCommand();
  23385. if (delCount > 0)
  23386. {
  23387. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23388. .Where(x => x.Diid == Dto.GroupId)
  23389. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23390. {
  23391. IsDel = 1,
  23392. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23393. DeleteUserId = Dto.UserId
  23394. })
  23395. .ExecuteCommand();
  23396. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23397. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23398. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23399. {
  23400. IsDel = 1,
  23401. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23402. DeleteUserId = Dto.UserId
  23403. })
  23404. .ExecuteCommand();
  23405. }
  23406. _sqlSugar.CommitTran();
  23407. }
  23408. catch (Exception ex)
  23409. {
  23410. _sqlSugar.RollbackTran();
  23411. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23412. }
  23413. return Ok(JsonView(true, "操作成功!"));
  23414. }
  23415. /// <summary>
  23416. /// 子项数据删除
  23417. /// </summary>
  23418. /// <param name="Dto"></param>
  23419. /// <returns></returns>
  23420. [HttpPost]
  23421. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  23422. {
  23423. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  23424. .Any(x => x.ReviewStatus == 1);
  23425. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  23426. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  23427. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  23428. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  23429. {
  23430. IsDel = 1,
  23431. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23432. DeleteUserId = Dto.UserId
  23433. })
  23434. .ExecuteCommand();
  23435. return Ok(JsonView(true, "SUCCESS!", count));
  23436. }
  23437. /// <summary>
  23438. /// 会务成本权限分配
  23439. /// </summary>
  23440. /// <param name="Dto"></param>
  23441. /// <returns></returns>
  23442. [HttpPost]
  23443. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  23444. {
  23445. _sqlSugar.BeginTran();
  23446. var count = 0;
  23447. try
  23448. {
  23449. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  23450. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  23451. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  23452. {
  23453. IsDel = 1,
  23454. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  23455. DeleteUserId = Dto.CreateUserId
  23456. })
  23457. .ExecuteCommand();
  23458. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  23459. {
  23460. CreateTime = DateTime.Now,
  23461. CreateUserId = Dto.CreateUserId,
  23462. UserId = x,
  23463. Diid = Dto.GroupId,
  23464. }).ToList()).ExecuteCommand();
  23465. _sqlSugar.CommitTran();
  23466. }
  23467. catch (Exception ex)
  23468. {
  23469. _sqlSugar.RollbackTran();
  23470. return Ok(JsonView(false, "操作失败!" + ex.Message));
  23471. }
  23472. return Ok(JsonView(true, "操作成功!", count));
  23473. }
  23474. /// <summary>
  23475. /// 团组会务成本文件下载
  23476. /// </summary>
  23477. /// <returns></returns>
  23478. [HttpPost]
  23479. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  23480. {
  23481. var FileType = new[]
  23482. {
  23483. new { Id = 0 , Name = "成本下载" },
  23484. new { Id = 1 , Name = "报价下载" },
  23485. new { Id = 2 , Name = "总表下载" },
  23486. };
  23487. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  23488. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  23489. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23490. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  23491. .Select<DelegationEasyView>()
  23492. .First();
  23493. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  23494. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  23495. if (main == null)
  23496. {
  23497. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  23498. }
  23499. JsonView jw = JsonView(false);
  23500. //总表下载
  23501. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  23502. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  23503. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  23504. var field = string.Empty;
  23505. var fileTypeName = string.Empty;
  23506. field = @$"
  23507. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  23508. b.Name as PriceTypeStr ,
  23509. c.Name as CurrencyStr ,
  23510. d.Name as UnitStr ,
  23511. case a.ReviewStatus
  23512. WHEN 1 THEN '已通过'
  23513. WHEN 0 THEN '未审核'
  23514. WHEN -1 THEN '未通过'
  23515. ELSE '未审核'
  23516. END AS ReviewStatusStr
  23517. ";
  23518. if (Dto.FileTypeId == 0)
  23519. {
  23520. fileTypeName = "会务成本成本表";
  23521. loadPath += $"{fileTypeName}.xlsx";
  23522. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23523. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23524. }
  23525. else if (Dto.FileTypeId == 1)
  23526. {
  23527. fileTypeName = "会务成本报价表";
  23528. loadPath += $"{fileTypeName}.xlsx";
  23529. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23530. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23531. }
  23532. else if (Dto.FileTypeId == 2)
  23533. {
  23534. fileTypeName = "会务成本总表";
  23535. loadPath += $"{fileTypeName}.xlsx";
  23536. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23537. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  23538. }
  23539. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  23540. SELECT
  23541. {field}
  23542. FROM Grp_ConferenceAffairsCostChild a
  23543. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  23544. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  23545. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  23546. WHERE a.isdel = 0
  23547. AND a.Diid = {main.Diid}
  23548. AND a.ConferenceAffairsCostId = {main.Id}
  23549. ").ToList();
  23550. var currLists = chiExcelContent.Select(x => new CurrList
  23551. {
  23552. CurrName = x.CurrencyStr,
  23553. CurrRate = x.Rate
  23554. })
  23555. .Distinct()
  23556. .ToList();
  23557. var designer = new WorkbookDesigner
  23558. {
  23559. Workbook = new Workbook(loadPath)
  23560. };
  23561. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  23562. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  23563. designer.SetDataSource("TeamName", di.TeamName);
  23564. designer.SetDataSource("City", main.City);
  23565. designer.SetDataSource("AllCost", main.CostAll);
  23566. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  23567. designer.SetDataSource("Curr", MostCurr.Name);
  23568. designer.SetDataSource("Curr1", MostCurr.Name);
  23569. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  23570. dt.TableName = "TB";
  23571. designer.SetDataSource(dt);
  23572. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  23573. dt1.TableName = "currTb";
  23574. designer.SetDataSource(dt1);
  23575. designer.Process();
  23576. designer.Workbook.Save(outputPath);
  23577. jw = JsonView(true, "操作成功!", new
  23578. {
  23579. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  23580. FilePath = networkPath
  23581. });
  23582. return Ok(jw);
  23583. }
  23584. [HttpPost]
  23585. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  23586. {
  23587. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  23588. .Select(x => x.PriceName).ToList()));
  23589. }
  23590. #endregion
  23591. #region 团组签证流程
  23592. #endregion
  23593. /// <summary>
  23594. /// 123132123
  23595. /// </summary>
  23596. /// <param name="_dto"></param>
  23597. /// <returns></returns>
  23598. [HttpPost]
  23599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23600. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  23601. {
  23602. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  23603. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  23604. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  23605. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  23606. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  23607. dicDetail.Add(789, 1034);
  23608. dicDetail.Add(790, 1035);
  23609. dicDetail.Add(791, 1036);
  23610. dicDetail.Add(792, 1037);
  23611. dicDetail.Add(793, 1038);
  23612. dicDetail.Add(794, 1039);
  23613. dicDetail.Add(795, 1040);
  23614. dicDetail.Add(796, 1041);
  23615. dicDetail.Add(797, 1042);
  23616. dicDetail.Add(798, 1043);
  23617. dicDetail.Add(801, 1044);
  23618. dicDetail.Add(802, 1045);
  23619. dicDetail.Add(803, 1046);
  23620. Dictionary<int, int> dic = new Dictionary<int, int>();
  23621. dic.Add(806, 1027);
  23622. dic.Add(807, 1028);
  23623. dic.Add(808, 1029);
  23624. dic.Add(809, 1030);
  23625. dic.Add(810, 1031);
  23626. dic.Add(811, 1032);
  23627. dic.Add(812, 1033);
  23628. foreach (var item in list_visa)
  23629. {
  23630. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  23631. temp.Coefficient = item.coefficient;
  23632. DateTime dtCrt;
  23633. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  23634. if (b1)
  23635. {
  23636. temp.CreateTime = dtCrt;
  23637. }
  23638. else
  23639. {
  23640. temp.CreateTime = DateTime.Now;
  23641. }
  23642. temp.CreateUserId = item.Operators;
  23643. temp.DeleteTime = "";
  23644. temp.DeleteUserId = 0;
  23645. temp.DiId = int.Parse(item.DIID);
  23646. temp.FilePath = item.FilePath;
  23647. temp.IsDel = item.IsDel;
  23648. temp.Price = item.Price;
  23649. temp.PriceCount = 1;
  23650. temp.PriceCurrency = item.Currency;
  23651. int detailId = 0;
  23652. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  23653. {
  23654. detailId = dicDetail[item.PriceTypeDetail];
  23655. }
  23656. temp.PriceDetailType = detailId;
  23657. temp.PriceDt = DateTime.Now;
  23658. temp.PriceName = item.PriceName;
  23659. temp.PriceSum = item.Price;
  23660. int tid = 0;
  23661. if (dic.ContainsKey(item.PriceType))
  23662. {
  23663. tid = dic[item.PriceType];
  23664. }
  23665. temp.PriceType = tid;
  23666. temp.Remark = item.Remark;
  23667. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  23668. }
  23669. return Ok(JsonView(true, "操作成功!"));
  23670. }
  23671. [HttpPost]
  23672. public IActionResult TimeTest()
  23673. {
  23674. var jw = JsonView(false, "error");
  23675. _sqlSugar.BeginTran();
  23676. try
  23677. {
  23678. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  23679. .Select(x => new Crm_NewClientData
  23680. {
  23681. Id = x.Id,
  23682. Client = x.Client,
  23683. Contact = x.Contact,
  23684. Location = x.Location,
  23685. })
  23686. .ToList();
  23687. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  23688. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  23689. Stopwatch stopwatch = new Stopwatch();
  23690. // 开始计时
  23691. stopwatch.Start();
  23692. foreach (var item in clientList)
  23693. {
  23694. EncryptionProcessor.DecryptProperties(item);
  23695. }
  23696. stopwatch.Stop();
  23697. jw.Code = 200;
  23698. jw.Data = stopwatch.ElapsedMilliseconds;
  23699. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  23700. }
  23701. catch (Exception ex)
  23702. {
  23703. jw.Code = 400;
  23704. jw.Msg = ex.Message;
  23705. }
  23706. return Ok(jw);
  23707. }
  23708. }
  23709. }