GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900
  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 Microsoft.Extensions.Logging;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.KiMiApi;
  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.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.OCR;
  33. using OASystem.Infrastructure.Repositories.CRM;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using System.Web;
  44. using static OASystem.API.OAMethodLib.JWTHelper;
  45. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  46. using Bookmark = Aspose.Words.Bookmark;
  47. using Cell = Aspose.Words.Tables.Cell;
  48. using Table = Aspose.Words.Tables.Table;
  49. namespace OASystem.API.Controllers
  50. {
  51. /// <summary>
  52. /// 团组相关
  53. /// </summary>
  54. //[Authorize]
  55. [Route("api/[controller]/[action]")]
  56. public class GroupsController : ControllerBase
  57. {
  58. private readonly ILogger<GroupsController> _logger;
  59. private readonly GrpScheduleRepository _grpScheduleRep;
  60. private readonly IMapper _mapper;
  61. private readonly DelegationInfoRepository _groupRepository;
  62. private readonly TaskAssignmentRepository _taskAssignmentRep;
  63. private readonly AirTicketResRepository _airTicketResRep;
  64. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  65. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  66. private readonly DelegationEnDataRepository _delegationEnDataRep;
  67. private readonly DelegationVisaRepository _delegationVisaRep;
  68. private readonly VisaPriceRepository _visaPriceRep;
  69. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  70. private readonly HotelPriceRepository _hotelPriceRep;
  71. private readonly CustomersRepository _customersRep;
  72. private readonly MessageRepository _message;
  73. private readonly SqlSugarClient _sqlSugar;
  74. private readonly TourClientListRepository _tourClientListRep;
  75. private readonly TeamRateRepository _teamRateRep;
  76. #region 成本相关
  77. private readonly CheckBoxsRepository _checkBoxs;
  78. private readonly GroupCostRepository _GroupCostRepository;
  79. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  80. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  81. #endregion
  82. private readonly SetDataRepository _setDataRep;
  83. private string url;
  84. private string path;
  85. private readonly EnterExitCostRepository _enterExitCostRep;
  86. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  87. private readonly UsersRepository _usersRep;
  88. private readonly IJuHeApiService _juHeApi;
  89. private readonly InvertedListRepository _invertedListRep;
  90. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  91. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  92. private readonly ThreeCodeRepository _threeCodeRepository;
  93. private readonly HotelInquiryRepository _hotelInquiryRep;
  94. private readonly FeeAuditRepository _feeAuditRep;
  95. private readonly VisaCommissionRepository _visaCommissionRep;
  96. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  97. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  98. private readonly List<CurrencyInfo> _currencyInit;
  99. private readonly List<int> _portTypeData;
  100. private readonly TableOperationRecordRepository _tableorRep;
  101. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  102. private readonly RestaurantRepository _restaurantRep;
  103. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  104. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. /// <param name="enterExitCostQuoteRep"></param>
  148. /// <param name="grpOrderPreInfoRep"></param>
  149. public GroupsController(
  150. ILogger<GroupsController> logger,
  151. IMapper mapper,
  152. IHubContext<ChatHub, IChatClient> hubContext,
  153. SqlSugarClient sqlSugar,
  154. GrpScheduleRepository grpScheduleRep,
  155. DelegationInfoRepository groupRepository,
  156. TaskAssignmentRepository taskAssignmentRep,
  157. AirTicketResRepository airTicketResRep,
  158. DecreasePaymentsRepository decreasePaymentsRep,
  159. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  160. DelegationEnDataRepository delegationEnDataRep,
  161. EnterExitCostRepository enterExitCostRep,
  162. DelegationVisaRepository delegationVisaRep,
  163. MessageRepository message,
  164. VisaPriceRepository visaPriceRep,
  165. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  166. CheckBoxsRepository checkBoxs,
  167. GroupCostRepository GroupCostRepository,
  168. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  169. GroupCostParameterRepository GroupCostParameterRepository,
  170. HotelPriceRepository hotelPriceRep,
  171. CustomersRepository customersRep,
  172. SetDataRepository setDataRep,
  173. TourClientListRepository tourClientListRep,
  174. TeamRateRepository teamRateRep,
  175. UsersRepository usersRep,
  176. IJuHeApiService juHeApi,
  177. InvertedListRepository invertedListRep,
  178. VisaFeeInfoRepository visaFeeInfoRep,
  179. TicketBlackCodeRepository ticketBlackCodeRep,
  180. HotelInquiryRepository hotelInquiryRep,
  181. ThreeCodeRepository threeCodeRepository,
  182. FeeAuditRepository feeAuditRep,
  183. VisaCommissionRepository visaCommissionRep,
  184. ForeignReceivablesRepository ffrRep,
  185. OpinionaireRepository opinionaireRep,
  186. TableOperationRecordRepository tableorRep,
  187. EnterExitCostDraftRepository enterExitCostDraftRep,
  188. RestaurantRepository restaurantRep,
  189. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  190. GroupOrderPreInfoRepository grpOrderPreInfoRep
  191. )
  192. {
  193. _logger = logger;
  194. _mapper = mapper;
  195. _grpScheduleRep = grpScheduleRep;
  196. _groupRepository = groupRepository;
  197. _taskAssignmentRep = taskAssignmentRep;
  198. _airTicketResRep = airTicketResRep;
  199. _sqlSugar = sqlSugar;
  200. url = AppSettingsHelper.Get("ExcelBaseUrl");
  201. path = AppSettingsHelper.Get("ExcelBasePath");
  202. if (!System.IO.Directory.Exists(path))
  203. {
  204. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  205. }
  206. _decreasePaymentsRep = decreasePaymentsRep;
  207. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  208. _delegationEnDataRep = delegationEnDataRep;
  209. _enterExitCostRep = enterExitCostRep;
  210. _delegationVisaRep = delegationVisaRep;
  211. _message = message;
  212. _visaPriceRep = visaPriceRep;
  213. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  214. _checkBoxs = checkBoxs;
  215. _GroupCostRepository = GroupCostRepository;
  216. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  217. _GroupCostParameterRepository = GroupCostParameterRepository;
  218. _hotelPriceRep = hotelPriceRep;
  219. _customersRep = customersRep;
  220. _setDataRep = setDataRep;
  221. _tourClientListRep = tourClientListRep;
  222. _teamRateRep = teamRateRep;
  223. _hubContext = hubContext;
  224. _usersRep = usersRep;
  225. _juHeApi = juHeApi;
  226. _invertedListRep = invertedListRep;
  227. _visaFeeInfoRep = visaFeeInfoRep;
  228. _ticketBlackCodeRep = ticketBlackCodeRep;
  229. _hotelInquiryRep = hotelInquiryRep;
  230. _threeCodeRepository = threeCodeRepository;
  231. _feeAuditRep = feeAuditRep;
  232. _visaCommissionRep = visaCommissionRep;
  233. _ffrRep = ffrRep;
  234. _opinionaireRep = opinionaireRep;
  235. _currencyInit = new List<CurrencyInfo>()
  236. {
  237. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  238. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  239. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  240. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  241. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  242. };
  243. _portTypeData = new List<int>() { 2, 3 };
  244. _tableorRep = tableorRep;
  245. _enterExitCostDraftRep = enterExitCostDraftRep;
  246. _restaurantRep = restaurantRep;
  247. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  248. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  249. }
  250. #region 流程管控
  251. /// <summary>
  252. /// 获取团组流程管控信息
  253. /// </summary>
  254. /// <param name="_jsonDto">查询参数</param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  259. {
  260. if (string.IsNullOrEmpty(_jsonDto.Paras))
  261. {
  262. return Ok(JsonView(false, "参数为空"));
  263. }
  264. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  265. if (_ScheduleDto != null)
  266. {
  267. if (_ScheduleDto.SearchType == 2)//获取列表
  268. {
  269. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  270. return Ok(JsonView(_grpScheduleViewList));
  271. }
  272. else//获取对象
  273. {
  274. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  275. if (_grpScheduleView != null)
  276. {
  277. return Ok(JsonView(_grpScheduleView));
  278. }
  279. }
  280. }
  281. else
  282. {
  283. return Ok(JsonView(false, "参数反序列化失败"));
  284. }
  285. return Ok(JsonView(false, "暂无数据!"));
  286. }
  287. /// <summary>
  288. /// 修改团组流程管控详细表数据
  289. /// </summary>
  290. /// <param name="dto"></param>
  291. /// <returns></returns>
  292. [HttpPost]
  293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  294. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  295. {
  296. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  297. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  298. .SetColumns(it => it.Duty == _detail.Duty)
  299. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  300. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  301. .SetColumns(it => it.JobContent == _detail.JobContent)
  302. .SetColumns(it => it.Remark == _detail.Remark)
  303. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  304. .Where(s => s.Id == dto.Id)
  305. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  306. .ExecuteCommandAsync();
  307. if (result > 0)
  308. {
  309. return Ok(JsonView(true, "保存成功!"));
  310. }
  311. return Ok(JsonView(false, "保存失败!"));
  312. }
  313. /// <summary>
  314. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  321. {
  322. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  323. _detail.IsDel = 1;
  324. _detail.DeleteUserId = dto.Duty;
  325. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  326. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  327. .SetColumns(it => it.IsDel == _detail.IsDel)
  328. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  329. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  330. .Where(it => it.Id == dto.Id)
  331. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  332. //.WhereColumns(s => s.Id == dto.Id)
  333. .ExecuteCommandAsync();
  334. if (result > 0)
  335. {
  336. return Ok(JsonView(true, "删除成功!"));
  337. }
  338. return Ok(JsonView(false, "删除失败!"));
  339. }
  340. /// <summary>
  341. /// 增加团组流程管控详细表数据
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  348. {
  349. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  350. if (DateTime.Now < _detail.ExpectBeginDt)
  351. {
  352. _detail.StepStatus = 0;
  353. }
  354. else
  355. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  356. _detail.StepStatus = 1;
  357. }
  358. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  359. if (result > 0)
  360. {
  361. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  362. return Ok(JsonView(true, "添加成功!", _result));
  363. }
  364. return Ok(JsonView(false, "添加失败!"));
  365. }
  366. #endregion
  367. #region 团组前期信息
  368. /// <summary>
  369. /// 团组前期信息H5-URL(员工对应地址)
  370. /// </summary>
  371. /// <param name="name">用户名称</param>
  372. /// <returns></returns>
  373. [HttpGet]
  374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  375. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  376. {
  377. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  378. .Where(x => x.IsDel == 0)
  379. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  380. .OrderBy(x => x.Id)
  381. .Select(x => new
  382. {
  383. name = x.CnName,
  384. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  385. })
  386. .ToListAsync();
  387. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count()));
  388. }
  389. /// <summary>
  390. /// 团组前期信息 List
  391. /// </summary>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  396. {
  397. var search = dto.Search;
  398. int[] nameTempIds = new int[] { 1, 12, 28 },
  399. countryTempIds = new int[] { 2, 13, 29 },
  400. daysTempIds = new int[] { 4, 15, 31 },
  401. ppNumTempIds = new int[] { 6 };
  402. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  403. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  404. .Where((opi, u) => opi.IsDel == 0)
  405. .OrderByDescending((opi, u) => opi.CreateTime)
  406. .Select((opi, u) => new GroupOrderPreInfoListView()
  407. {
  408. Id = opi.Id,
  409. Name = opi.Name,
  410. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  411. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. Operator = u.CnName,
  415. OperationTime = opi.CreateTime
  416. })
  417. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  418. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  419. .ToListAsync();
  420. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  421. int total = list.Count;
  422. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  423. var listPageData1 = listPageData
  424. .Skip((dto.PageIndex - 1) * dto.PageSize)
  425. .Take(dto.PageSize)
  426. .ToList();
  427. var infoIds = listPageData1.Select(x => x.Id).ToList();
  428. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  429. .Where(x => x.IsDel == 0 && x.STid == 109)
  430. .ToArrayAsync();
  431. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  432. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  433. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  434. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  435. .ToListAsync();
  436. foreach (var item in listPageData1)
  437. {
  438. var typeDatas1 = typeDatas.Select(x => new
  439. {
  440. Id = x.Id,
  441. Name = x.Name,
  442. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  443. }).ToArray();
  444. item.VersionDetails = typeDatas1;
  445. }
  446. return Ok(JsonView(listPageData1, listPageData1.Count));
  447. }
  448. /// <summary>
  449. /// 团组前期信息 Init
  450. /// </summary>
  451. /// <returns></returns>
  452. [HttpGet("{userId}")]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  455. {
  456. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  457. }
  458. /// <summary>
  459. /// 国家数据源
  460. /// </summary>
  461. /// <param name="pageIndex">当前页码</param>
  462. /// <param name="pageSize">每页条数</param>
  463. /// <param name="search">查询条件</param>
  464. /// <returns></returns>
  465. [HttpGet]
  466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  467. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  468. {
  469. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  470. if (pageIndex == 0 && pageSize == 0)
  471. {
  472. //所有数据
  473. return Ok(JsonView(countrys, countrys.Count));
  474. }
  475. //分页
  476. int skip = (pageIndex - 1) * pageSize;
  477. int take = pageSize;
  478. if (!string.IsNullOrEmpty(search))
  479. {
  480. IEnumerable<char> charSequence = search.Select(c => c);
  481. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  482. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  483. return Ok(JsonView(pageData, pageResult1.Count));
  484. }
  485. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  486. return Ok(JsonView(pageResult2, countrys.Count));
  487. }
  488. /// <summary>
  489. /// 城市数据源
  490. /// </summary>
  491. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  492. /// <param name="pageIndex">当前页码</param>
  493. /// <param name="pageSize">每页条数</param>
  494. /// <param name="search">查询条件</param>
  495. /// <returns></returns>
  496. [HttpGet("{countryLabel}")]
  497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  498. public async Task<IActionResult> CityByCountry(
  499. string countryLabel,
  500. [FromQuery] int pageIndex,
  501. [FromQuery] int pageSize,
  502. [FromQuery] string search)
  503. {
  504. countryLabel = HttpUtility.UrlDecode(countryLabel);
  505. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  506. var citys = Array.Empty<string?>();
  507. if (countryList.Any())
  508. {
  509. var cityDatas = await _sqlSugar
  510. .Queryable<Grp_NationalTravelFee>()
  511. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  512. .ToArrayAsync();
  513. foreach (var item in cityDatas)
  514. {
  515. if (item.City.Contains("城市"))
  516. {
  517. item.City = item.Country + "-所有城市";
  518. }
  519. }
  520. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  521. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  522. }
  523. if (pageIndex == 0 && pageSize == 0)
  524. {
  525. //所有数据
  526. return Ok(JsonView(citys, citys?.Length ?? 0));
  527. }
  528. //分页
  529. int skip = (pageIndex - 1) * pageSize;
  530. int take = pageSize;
  531. if (!string.IsNullOrEmpty(search))
  532. {
  533. IEnumerable<char> charSequence = search.Select(c => c);
  534. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  535. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  536. return Ok(JsonView(pageData, pageResult1.Count()));
  537. }
  538. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  539. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  540. }
  541. /// <summary>
  542. /// 团组前期信息 Info
  543. /// </summary>
  544. /// <param name="dto">Id</param>
  545. /// <param name="portType">Id</param>
  546. /// <returns></returns>
  547. [HttpGet("{Id}/{TempId}")]
  548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  549. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  550. {
  551. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  552. }
  553. /// <summary>
  554. /// 团组前期信息 移动端 Info
  555. /// </summary>
  556. /// <param name="dto">Id</param>
  557. /// <returns></returns>
  558. [HttpGet("{Id}/{TempId}")]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  561. {
  562. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  563. }
  564. /// <summary>
  565. /// 团组前期信息 Save
  566. /// </summary>
  567. /// <param name="dto">Id</param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  572. {
  573. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  574. }
  575. /// <summary>
  576. /// 团组前期信息 Del
  577. /// </summary>
  578. /// <param name="dto">Id</param>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  583. {
  584. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  585. }
  586. /// <summary>
  587. /// 团组前期信息 文件下载
  588. /// </summary>
  589. /// <param name="dto">Id</param>
  590. /// <returns></returns>
  591. [HttpGet("{Id}/{TempId}")]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  594. {
  595. int id = dto.Id, tempId = dto.TempId;
  596. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  597. var data = view.Data as GrpOrderPreInfoView;
  598. #region Excel
  599. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  600. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  601. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  602. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  603. var fileNamePrefix = string.Empty;
  604. if (tempId == 1405)
  605. {
  606. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  607. fileNamePrefix = $"{data.Name}_无商邀版";
  608. }
  609. else if (tempId == 1406)
  610. {
  611. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  612. fileNamePrefix = $"{data.Name}_有商邀版";
  613. }
  614. else
  615. {
  616. //tempId == 1404 默认下载
  617. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  618. fileNamePrefix = $"{data.Name}_单接送机";
  619. }
  620. foreach (var item in data.Items)
  621. {
  622. var obj = item.NewValue;
  623. if (obj == null) item.OriginVal = "";
  624. else if (obj.Equals("有") || obj.Equals("无"))
  625. {
  626. item.OriginVal = obj.ToString();
  627. }
  628. else if (obj is object[] objArray)
  629. {
  630. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  631. item.OriginVal = string.Join("、", stringArray);
  632. }
  633. else if (obj is string[] stringArray)
  634. {
  635. item.OriginVal = string.Join("、", stringArray);
  636. }
  637. else if (obj.Equals("-"))
  638. {
  639. item.OriginVal = "";
  640. }
  641. }
  642. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  643. fileName = CommonFun.ValidFileName(fileName);
  644. //载入模板
  645. WorkbookDesigner designer = new WorkbookDesigner();
  646. designer.Workbook = new Workbook(tempPath);
  647. if (tempId == 1406)
  648. {
  649. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  650. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  651. for (int i = 1; i <= view2.Length; i++)
  652. {
  653. view2[i - 1].Index = i;
  654. }
  655. designer.SetDataSource("View1", view1);
  656. designer.SetDataSource("View2", view2);
  657. }
  658. else
  659. {
  660. designer.SetDataSource("View", data.Items);
  661. }
  662. designer.Process();
  663. if (!Directory.Exists(savePath))
  664. {
  665. Directory.CreateDirectory(savePath);
  666. }
  667. string serverPath = $"{savePath}{fileName}";
  668. designer.Workbook.Save(serverPath);
  669. string rst = $"{servicePath}{ftpPath}{fileName}";
  670. #endregion
  671. return Ok(JsonView(new { url = rst }));
  672. }
  673. #endregion
  674. #region 团组基本信息
  675. /// <summary>
  676. /// 接团信息列表
  677. /// </summary>
  678. /// <param name="dto">团组列表请求dto</param>
  679. /// <returns></returns>
  680. [HttpPost]
  681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  682. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  683. {
  684. var groupData = await _groupRepository.GetGroupList(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(groupData.Data));
  690. }
  691. /// <summary>
  692. /// 分页查询团组列表
  693. /// </summary>
  694. /// <param name="dto"></param>
  695. /// <returns></returns>
  696. [HttpPost]
  697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  698. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  699. {
  700. var watch = new Stopwatch();
  701. watch.Start();
  702. RefAsync<int> total = 0;
  703. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  704. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  705. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  706. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  707. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  708. .Distinct()
  709. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  710. watch.Stop();
  711. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  712. }
  713. /// <summary>
  714. /// 接团信息列表 Page Init
  715. /// </summary>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> PostGroupPageListInit()
  720. {
  721. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  722. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  723. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  724. var _view = new
  725. {
  726. depData = depDatas,
  727. rankData = rankDatas
  728. };
  729. return Ok(JsonView(true, "查询成功!", _view));
  730. }
  731. /// <summary>
  732. /// 接团信息列表 Page
  733. /// </summary>
  734. /// <param name="dto">团组列表请求dto</param>
  735. /// <returns></returns>
  736. [HttpPost]
  737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  738. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  739. {
  740. #region 参数验证
  741. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  742. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  743. PageFunAuthViewBase
  744. pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  751. {
  752. string sqlWhere = string.Empty;
  753. if (dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  762. {
  763. string tj = dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. if (int.TryParse(dto.Rank, out int rankId))
  768. {
  769. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  770. }
  771. string sqlWhere1 = string.Empty;
  772. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  773. {
  774. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime,IsBid
  780. From (
  781. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  782. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  783. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  784. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  785. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  787. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  788. From Grp_DelegationInfo gdi
  789. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  790. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  791. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  792. Where gdi.IsDel = 0 {0}
  793. ) temp {1}", sqlWhere, sqlWhere1);
  794. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  795. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  796. var _view = new
  797. {
  798. PageFuncAuth = pageFunAuthView,
  799. Data = _DelegationList
  800. };
  801. return Ok(JsonView(true, "查询成功!", _view, total));
  802. }
  803. else
  804. {
  805. return Ok(JsonView(false, "查询失败"));
  806. }
  807. }
  808. /// <summary>
  809. /// 团组列表
  810. /// </summary>
  811. /// <returns></returns>
  812. [HttpPost]
  813. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  814. {
  815. #region 参数验证
  816. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  817. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  819. #region 页面操作权限验证
  820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  822. #endregion
  823. #endregion
  824. if (dto.PortType != 1 && dto.PortType != 2)
  825. {
  826. return Ok(JsonView(false, "查询失败!"));
  827. }
  828. string orderbyStr = "order by gdi.CreateTime Desc";
  829. string sqlWhere = string.Empty;
  830. if (dto.IsSure == 0) //未完成
  831. {
  832. sqlWhere += string.Format(@" And IsSure = 0");
  833. }
  834. else if (dto.IsSure == 1) //已完成
  835. {
  836. sqlWhere += string.Format(@" And IsSure = 1");
  837. }
  838. //团组类型
  839. if (dto.TeamDid > 0)
  840. {
  841. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  842. }
  843. //团组名称
  844. if (!string.IsNullOrEmpty(dto.TeamName))
  845. {
  846. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  847. }
  848. //客户名称
  849. if (!string.IsNullOrEmpty(dto.ClientName))
  850. {
  851. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  852. }
  853. //客户单位
  854. if (!string.IsNullOrEmpty(dto.ClientUnit))
  855. {
  856. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  857. }
  858. //出访时间
  859. if (!string.IsNullOrEmpty(dto.visitDataTime))
  860. {
  861. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  862. orderbyStr = "order by gdi.VisitDate";
  863. }
  864. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  865. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  866. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  867. JietuanOperator,IsSure,CreateTime
  868. From (
  869. Select row_number() over({0}) as Row_Number,
  870. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  871. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  872. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  873. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  874. From Grp_DelegationInfo gdi
  875. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  876. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  877. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  878. Where gdi.IsDel = 0 {1}
  879. ) temp ", orderbyStr, sqlWhere);
  880. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  881. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  882. #region 处理所属部门
  883. /*
  884. * 1.sq 和 gyy 等显示 市场部
  885. * 2.王鸽和主管及张总还有管理员号统一国交部
  886. * 2-1. 4 管理员 ,21 张海麟
  887. */
  888. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  889. List<int> userIds1 = new List<int>() { 4, 21 };
  890. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  891. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  892. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  893. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  894. .ToList();
  895. foreach (var item in _DelegationList)
  896. {
  897. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  898. }
  899. #endregion
  900. var _view = new
  901. {
  902. PageFuncAuth = pageFunAuthView,
  903. Data = _DelegationList
  904. };
  905. return Ok(JsonView(true, "查询成功!", _view, total));
  906. }
  907. /// <summary>
  908. /// 接团信息详情
  909. /// </summary>
  910. /// <param name="dto">团组info请求dto</param>
  911. /// <returns></returns>
  912. [HttpPost]
  913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  914. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  915. {
  916. var groupData = await _groupRepository.GetGroupInfo(dto);
  917. if (groupData.Code != 0)
  918. {
  919. return Ok(JsonView(false, groupData.Msg));
  920. }
  921. return Ok(JsonView(groupData.Data));
  922. }
  923. /// <summary>
  924. /// 接团信息 编辑添加
  925. /// 基础信息数据源
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  932. {
  933. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  934. if (groupData.Code != 0)
  935. {
  936. return Ok(JsonView(false, groupData.Msg));
  937. }
  938. return Ok(JsonView(groupData.Data));
  939. }
  940. /// <summary>
  941. /// 成本修改团组信息
  942. /// </summary>
  943. /// <param name="dto"></param>
  944. /// <returns></returns>
  945. [HttpPost]
  946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  947. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  948. {
  949. var jw = JsonView(false, "操作失败");
  950. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  951. if (di == null)
  952. {
  953. jw.Msg = "参数有误!";
  954. return Ok(jw);
  955. }
  956. #region 添加出访起止时间
  957. var startTime = new DateTime();
  958. var endTime = new DateTime();
  959. if (DateTime.TryParse(dto.VisitDate, out startTime))
  960. {
  961. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  962. }
  963. else
  964. {
  965. jw.Msg = "参数有误!";
  966. return Ok(jw);
  967. }
  968. #endregion
  969. di.VisitDate = startTime;
  970. di.VisitPNumber = dto.VisitPNumber;
  971. di.VisitDays = dto.VisitDays;
  972. di.VisitStartDate = startTime;
  973. di.VisitEndDate = endTime;
  974. var count = _sqlSugar.Updateable(di)
  975. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  976. .ExecuteCommand();
  977. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  978. }
  979. /// <summary>
  980. /// 接团信息 编辑添加
  981. /// 省份-城市 基础信息数据源
  982. /// </summary>
  983. /// <param name="dto"></param>
  984. /// <returns></returns>
  985. [HttpPost]
  986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  987. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  988. {
  989. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  990. string search = dto.Search;
  991. var data = await _groupRepository.CityBasicSource();
  992. int total = data.Length;
  993. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  994. .Skip((pageIndex - 1) * pageSize)
  995. .Take(pageSize)
  996. .ToArray();
  997. return Ok(JsonView(data, total));
  998. }
  999. /// <summary>
  1000. /// 接团信息 操作(增改)
  1001. /// </summary>
  1002. /// <param name="dto"></param>
  1003. /// <returns></returns>
  1004. [HttpPost]
  1005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1006. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1007. {
  1008. // 创建 Stopwatch 实例
  1009. Stopwatch stopwatch = Stopwatch.StartNew();
  1010. decimal ffrPrice = 0.00M;
  1011. DateTime? visitDt = null;
  1012. if (dto.Status == 2)
  1013. {
  1014. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1015. if (groupInfo != null)
  1016. {
  1017. ffrPrice = groupInfo.PaymentMoney;
  1018. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1019. }
  1020. }
  1021. var groupData = await _groupRepository.GroupOperation(dto);
  1022. if (groupData.Code != 0)
  1023. {
  1024. return Ok(JsonView(false, groupData.Msg));
  1025. }
  1026. int diId = 0;
  1027. try
  1028. {
  1029. //添加时 默认加入团组汇率
  1030. if (dto.Status == 1) //添加
  1031. {
  1032. diId = groupData.Data;
  1033. //添加默认币种
  1034. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1035. //默认分配权限
  1036. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1037. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1038. var _managerIds = new List<int>() { 22, 32, 21 };
  1039. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1040. if (userIds.Count > 0)
  1041. {
  1042. userIds.Add(208);
  1043. //创建团组管控
  1044. GroupStepForDelegation.CreateWorkStep(diId);
  1045. //发送消息
  1046. string groupName = dto.TeamName;
  1047. string createGroupUser = string.Empty;
  1048. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1049. if (userInfo != null) createGroupUser = userInfo.CnName;
  1050. string title = $"系统通知";
  1051. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1052. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1053. }
  1054. //默认创建倒推表
  1055. await _invertedListRep._Create(dto.UserId, diId);
  1056. }
  1057. else if (dto.Status == 2)
  1058. {
  1059. diId = dto.Id;
  1060. }
  1061. #region 签证人员团组时间通知
  1062. #region 计算出访起止时间
  1063. var startTime = new DateTime();
  1064. var endTime = new DateTime();
  1065. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1066. {
  1067. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1068. }
  1069. #endregion
  1070. #endregion
  1071. #region 团组操作默认添加/修改收款账单
  1072. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1073. {
  1074. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1075. .Where(x => x.IsDel == 0 &&
  1076. x.Diid == diId &&
  1077. x.Remark.Equals("预付款")
  1078. )
  1079. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1080. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1081. .FirstAsync();
  1082. ffrInfo = new Fin_ForeignReceivables()
  1083. {
  1084. Diid = diId,
  1085. PriceName = dto.ClientUnit,
  1086. Price = dto.PaymentMoney,
  1087. Count = 1,
  1088. Unit = $"元",
  1089. ItemSumPrice = dto.PaymentMoney,
  1090. Rate = 1.0000M,
  1091. Currency = 836,
  1092. AddingWay = 0,
  1093. CreateUserId = dto.UserId,
  1094. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1095. Remark = $"预付款"
  1096. };
  1097. if (ffrInfo == null) //Add
  1098. {
  1099. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1100. }
  1101. else //修改
  1102. {
  1103. await _sqlSugar.Updateable(ffrInfo)
  1104. .UpdateColumns(x => new
  1105. {
  1106. x.PriceName,
  1107. x.Price,
  1108. x.ItemSumPrice,
  1109. x.CreateTime,
  1110. x.CreateUserId
  1111. })
  1112. .WhereColumns(x => x.Id)
  1113. .ExecuteCommandAsync();
  1114. }
  1115. }
  1116. #endregion
  1117. if (diId > 0)
  1118. {
  1119. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1120. }
  1121. // 停止计时
  1122. stopwatch.Stop();
  1123. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1124. }
  1125. catch (Exception ex)
  1126. {
  1127. // 停止计时
  1128. stopwatch.Stop();
  1129. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1130. Logs(ex.Message);
  1131. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1132. }
  1133. // 停止计时
  1134. stopwatch.Stop();
  1135. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1136. }
  1137. /// <summary>
  1138. /// 接团流程操作(增改)
  1139. /// 安卓端使用 建团时添加客户名单
  1140. /// </summary>
  1141. /// <param name="dto"></param>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1146. {
  1147. #region 参数验证
  1148. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1149. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1150. #region 页面操作权限验证
  1151. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1152. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1153. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1154. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1155. #endregion
  1156. #endregion
  1157. try
  1158. {
  1159. //_sqlSugar.BeginTran();
  1160. decimal ffrPrice = 0.00M;
  1161. DateTime? visitDt = null;
  1162. if (dto.Status == 2)
  1163. {
  1164. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1165. if (groupInfo != null)
  1166. {
  1167. ffrPrice = groupInfo.PaymentMoney;
  1168. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1169. }
  1170. }
  1171. var _dto = new GroupOperationDto();
  1172. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1173. var groupData = await _groupRepository.GroupOperation(_dto);
  1174. if (groupData.Code != 0)
  1175. {
  1176. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1177. }
  1178. int diId = 0;
  1179. //添加时 默认加入团组汇率
  1180. if (dto.Status == 1) //添加
  1181. {
  1182. diId = groupData.Data;
  1183. //添加默认币种
  1184. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1185. //默认分配权限
  1186. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1187. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1188. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1189. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1190. if (userIds.Count > 0)
  1191. {
  1192. userIds.Add(208);
  1193. //创建团组管控
  1194. GroupStepForDelegation.CreateWorkStep(diId);
  1195. //发送消息
  1196. string groupName = dto.TeamName;
  1197. string createGroupUser = string.Empty;
  1198. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1199. if (userInfo != null) createGroupUser = userInfo.CnName;
  1200. string title = $"系统通知";
  1201. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1202. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1203. }
  1204. #region 应用推送
  1205. try
  1206. {
  1207. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1208. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1209. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1210. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1211. {
  1212. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1213. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1214. }
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. }
  1219. #endregion
  1220. //默认创建倒推表
  1221. await _invertedListRep._Create(dto.UserId, diId);
  1222. }
  1223. if (dto.Status == 2)
  1224. {
  1225. diId = dto.Id;
  1226. if (diId == 0)
  1227. {
  1228. //_sqlSugar.RollbackTran();
  1229. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1230. }
  1231. }
  1232. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1233. if (viewData.Code != 0)
  1234. {
  1235. //_sqlSugar.RollbackTran();
  1236. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1237. }
  1238. #region 团组操作默认添加/修改收款账单
  1239. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1240. {
  1241. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1242. .Where(x => x.IsDel == 0 &&
  1243. x.Diid == diId &&
  1244. x.Remark.Equals("预付款")
  1245. )
  1246. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1247. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1248. .FirstAsync();
  1249. ffrInfo = new Fin_ForeignReceivables()
  1250. {
  1251. Diid = diId,
  1252. PriceName = dto.ClientUnit,
  1253. Price = dto.PaymentMoney,
  1254. Count = 1,
  1255. Unit = $"元",
  1256. ItemSumPrice = dto.PaymentMoney,
  1257. Rate = 1.0000M,
  1258. Currency = 836,
  1259. AddingWay = 0,
  1260. CreateUserId = dto.UserId,
  1261. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1262. Remark = $"预付款"
  1263. };
  1264. if (ffrInfo == null) //Add
  1265. {
  1266. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1267. }
  1268. else //修改
  1269. {
  1270. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1271. .UpdateColumns(x => new
  1272. {
  1273. x.PriceName,
  1274. x.Price,
  1275. x.ItemSumPrice,
  1276. x.CreateTime,
  1277. x.CreateUserId
  1278. })
  1279. .WhereColumns(x => x.Id)
  1280. .ExecuteCommandAsync();
  1281. }
  1282. }
  1283. #endregion
  1284. #region 签证人员团组时间通知
  1285. #region 计算出访起止时间
  1286. var startTime = new DateTime();
  1287. var endTime = new DateTime();
  1288. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1289. {
  1290. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1291. }
  1292. #endregion
  1293. if (diId > 0)
  1294. {
  1295. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1296. }
  1297. #endregion
  1298. //_sqlSugar.CommitTran();
  1299. return Ok(JsonView(true, "添加成功"));
  1300. }
  1301. catch (Exception ex)
  1302. {
  1303. _sqlSugar.RollbackTran();
  1304. return Ok(JsonView(false, ex.Message));
  1305. }
  1306. }
  1307. /// <summary>
  1308. /// 接团流程操作(增改)
  1309. /// 安卓端使用 建团时添加客户名单
  1310. /// </summary>
  1311. /// <param name="dto"></param>
  1312. /// <returns></returns>
  1313. [HttpPost]
  1314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1315. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1316. {
  1317. #region 参数验证
  1318. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1320. #region 页面操作权限验证
  1321. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1322. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1323. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1324. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1325. #endregion
  1326. #endregion
  1327. _sqlSugar.BeginTran();
  1328. decimal ffrPrice = 0.00M;
  1329. DateTime? visitDt = null;
  1330. if (dto.Status == 2)
  1331. {
  1332. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1333. if (groupInfo != null)
  1334. {
  1335. ffrPrice = groupInfo.PaymentMoney;
  1336. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1337. }
  1338. }
  1339. var _dto = new GroupOperationDto();
  1340. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1341. var groupData = await _groupRepository.GroupOperation(_dto);
  1342. if (groupData.Code != 0)
  1343. {
  1344. _sqlSugar.RollbackTran();
  1345. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1346. }
  1347. try
  1348. {
  1349. int diId = 0;
  1350. //添加时 默认加入团组汇率
  1351. if (dto.Status == 1) //添加
  1352. {
  1353. diId = groupData.Data;
  1354. //添加默认币种
  1355. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1356. //默认分配权限
  1357. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1358. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1359. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1360. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1361. if (userIds.Count > 0)
  1362. {
  1363. userIds.Add(208);
  1364. //创建团组管控
  1365. GroupStepForDelegation.CreateWorkStep(diId);
  1366. //发送消息
  1367. string groupName = dto.TeamName;
  1368. string createGroupUser = string.Empty;
  1369. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1370. if (userInfo != null) createGroupUser = userInfo.CnName;
  1371. string title = $"系统通知";
  1372. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1373. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1374. }
  1375. #region 应用推送
  1376. try
  1377. {
  1378. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1379. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1380. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1381. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1382. {
  1383. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1384. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1385. }
  1386. }
  1387. catch (Exception ex)
  1388. {
  1389. _sqlSugar.CommitTran();
  1390. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1391. }
  1392. #endregion
  1393. //默认创建倒推表
  1394. await _invertedListRep._Create(dto.UserId, diId);
  1395. }
  1396. else if (dto.Status == 2)
  1397. {
  1398. diId = dto.Id;
  1399. if (diId == 0)
  1400. {
  1401. _sqlSugar.RollbackTran();
  1402. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1403. }
  1404. }
  1405. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1406. if (viewData.Code != 0)
  1407. {
  1408. _sqlSugar.RollbackTran();
  1409. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1410. }
  1411. #region 团组操作默认添加/修改收款账单
  1412. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1413. {
  1414. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1415. .Where(x => x.IsDel == 0 &&
  1416. x.Diid == diId &&
  1417. x.Remark.Equals("预付款")
  1418. )
  1419. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1420. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1421. .FirstAsync();
  1422. ffrInfo = new Fin_ForeignReceivables()
  1423. {
  1424. Diid = diId,
  1425. PriceName = dto.ClientUnit,
  1426. Price = dto.PaymentMoney,
  1427. Count = 1,
  1428. Unit = $"元",
  1429. ItemSumPrice = dto.PaymentMoney,
  1430. Rate = 1.0000M,
  1431. Currency = 836,
  1432. AddingWay = 0,
  1433. CreateUserId = dto.UserId,
  1434. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1435. Remark = $"预付款"
  1436. };
  1437. if (ffrInfo == null) //Add
  1438. {
  1439. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1440. }
  1441. else //修改
  1442. {
  1443. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1444. .UpdateColumns(x => new
  1445. {
  1446. x.PriceName,
  1447. x.Price,
  1448. x.ItemSumPrice,
  1449. x.CreateTime,
  1450. x.CreateUserId
  1451. })
  1452. .WhereColumns(x => x.Id)
  1453. .ExecuteCommandAsync();
  1454. }
  1455. }
  1456. #endregion
  1457. #region 签证人员团组时间通知
  1458. #region 计算出访起止时间
  1459. var startTime = new DateTime();
  1460. var endTime = new DateTime();
  1461. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1462. {
  1463. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1464. }
  1465. #endregion
  1466. if (diId > 0)
  1467. {
  1468. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1469. }
  1470. #endregion
  1471. _sqlSugar.CommitTran();
  1472. return Ok(JsonView(true));
  1473. }
  1474. catch (Exception ex)
  1475. {
  1476. _sqlSugar.RollbackTran();
  1477. return Ok(JsonView(false, ex.Message));
  1478. }
  1479. }
  1480. /// <summary>
  1481. /// 接团信息 操作(删除)
  1482. /// </summary>
  1483. /// <param name="dto"></param>
  1484. /// <returns></returns>
  1485. [HttpPost]
  1486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1487. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1488. {
  1489. var diId = dto.Id;
  1490. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1491. #region 删除 验证
  1492. /*
  1493. * 1、收款账单数据:0 条
  1494. * 2、收款退还数据:0 条
  1495. * 3、机票费用数据:0 条
  1496. * 4、签证费用数据:0 条
  1497. * 5、保险费用数据:0 条
  1498. * 6、酒店费用数据:0 条
  1499. * 7、公务出访数据:1 条
  1500. * 8、邀请公务活动费用数据:1 条
  1501. * 9、OP费用数据:5 条
  1502. * 10、其他费用数据:0 条
  1503. * 11、团组日付报销费用数据:0 条
  1504. *
  1505. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1506. */
  1507. //收款账单
  1508. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1509. //收款退还
  1510. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1511. //机票费用
  1512. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1513. //签证费用
  1514. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1515. //保险费用
  1516. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1517. //酒店费用
  1518. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1519. //公务出访
  1520. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1521. //邀请公务活动费用
  1522. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1523. //OP费用
  1524. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1525. //其他费用
  1526. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1527. //团组日付报销费用
  1528. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1529. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1530. if (feeCount > 0)
  1531. {
  1532. var delMsgTips = new StringBuilder();
  1533. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1534. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1535. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1536. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1537. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1538. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1539. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1540. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1541. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1542. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1543. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1544. delMsgTips.AppendLine($"");
  1545. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1546. return Ok(JsonView(false, delMsgTips.ToString()));
  1547. }
  1548. #endregion
  1549. var groupData = await _groupRepository.GroupDel(dto);
  1550. if (groupData.Code != 0)
  1551. {
  1552. return Ok(JsonView(false, groupData.Msg));
  1553. }
  1554. return Ok(JsonView(true));
  1555. }
  1556. /// <summary>
  1557. /// 获取团组销售报价号
  1558. /// 团组添加时 使用
  1559. /// </summary>
  1560. /// <returns></returns>
  1561. [HttpPost]
  1562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1563. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1564. {
  1565. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1566. if (groupData.Code != 0)
  1567. {
  1568. return Ok(JsonView(false, groupData.Msg));
  1569. }
  1570. object salesQuoteNo = new
  1571. {
  1572. SalesQuoteNo = groupData.Data
  1573. };
  1574. return Ok(JsonView(salesQuoteNo));
  1575. }
  1576. /// <summary>
  1577. /// 设置确认出团
  1578. /// </summary>
  1579. /// <param name="dto"></param>
  1580. /// <returns></returns>
  1581. [HttpPost]
  1582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1583. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1584. {
  1585. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1586. if (groupData.Code != 0)
  1587. {
  1588. return Ok(JsonView(false, groupData.Msg));
  1589. }
  1590. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1591. #region OA消息推送
  1592. try
  1593. {
  1594. string groupName = groupInfo.TeamName;
  1595. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1596. string title = $"系统通知";
  1597. string content = $"团组[{groupName}]已确认出团!";
  1598. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1599. }
  1600. catch (Exception ex)
  1601. {
  1602. }
  1603. #endregion
  1604. #region 应用推送
  1605. try
  1606. {
  1607. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1608. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1609. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1610. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1611. {
  1612. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1613. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1614. }
  1615. }
  1616. catch (Exception ex)
  1617. {
  1618. }
  1619. #endregion
  1620. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1621. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1622. }
  1623. /// <summary>
  1624. /// 获取团组名称data And 签证国别Data
  1625. /// </summary>
  1626. /// <param name="dto"></param>
  1627. /// <returns></returns>
  1628. [HttpPost]
  1629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1630. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1631. {
  1632. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1633. if (groupData.Code != 0)
  1634. {
  1635. return Ok(JsonView(false, groupData.Msg));
  1636. }
  1637. return Ok(JsonView(groupData.Data));
  1638. }
  1639. /// <summary>
  1640. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1641. /// </summary>
  1642. /// <returns></returns>
  1643. [HttpPost]
  1644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1645. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1646. {
  1647. try
  1648. {
  1649. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1650. if (groupData.Code != 0)
  1651. {
  1652. return Ok(JsonView(false, groupData.Msg));
  1653. }
  1654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1655. }
  1656. catch (Exception ex)
  1657. {
  1658. return Ok(JsonView(false, "程序错误!"));
  1659. throw;
  1660. }
  1661. }
  1662. /// <summary>
  1663. /// 团组清单 Excel
  1664. /// </summary>
  1665. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1666. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1667. /// <returns></returns>
  1668. [HttpGet]
  1669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1670. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1671. {
  1672. DateTime _beginDt, _endDt;
  1673. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1674. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1675. if (!beginBool && !endBool)
  1676. {
  1677. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1678. }
  1679. string sql = string.Format(@"
  1680. SELECT
  1681. ROW_NUMBER,
  1682. Id,
  1683. SalesQuoteNo,
  1684. TourCode,
  1685. TeamTypeId,
  1686. TeamType,
  1687. TeamLevId,
  1688. TeamLev,
  1689. TeamName,
  1690. ClientName,
  1691. ClientUnit,
  1692. VisitDate,
  1693. VisitDays,
  1694. VisitPNumber,
  1695. JietuanOperatorId,
  1696. JietuanOperator,
  1697. IsSure,
  1698. CreateUserName,
  1699. IsBid
  1700. FROM
  1701. (
  1702. SELECT
  1703. ROW_NUMBER() OVER(
  1704. ORDER BY
  1705. gdi.VisitDate Desc
  1706. ) AS ROW_NUMBER,
  1707. gdi.Id,
  1708. SalesQuoteNo,
  1709. TourCode,
  1710. ssd.Id TeamTypeId,
  1711. ssd.Name TeamType,
  1712. ssd1.Id TeamLevId,
  1713. ssd1.Name TeamLev,
  1714. TeamName,
  1715. ClientName,
  1716. ClientUnit,
  1717. VisitDate,
  1718. VisitDays,
  1719. VisitPNumber,
  1720. JietuanOperator JietuanOperatorId,
  1721. su.CnName JietuanOperator,
  1722. IsSure,
  1723. gdi.CreateTime,
  1724. su1.CnName As CreateUserName,
  1725. gdi.IsBid
  1726. FROM
  1727. Grp_DelegationInfo gdi
  1728. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1729. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1730. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1731. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1732. WHERE
  1733. gdi.IsDel = 0
  1734. AND gdi.IsBid = 0
  1735. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1736. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1737. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1738. #region 处理所属部门
  1739. /*
  1740. * 1.sq 和 gyy 等显示 市场部
  1741. * 2.王鸽和主管及张总还有管理员号统一国交部
  1742. * 2-1. 4 管理员 ,21 张海麟
  1743. */
  1744. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1745. List<int> userIds1 = new List<int>() { 4, 21 };
  1746. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1747. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1748. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1749. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1750. .ToListAsync();
  1751. var droupIds = groupList.Select(it => it.Id).ToList();
  1752. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1753. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1754. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1755. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1756. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1757. {
  1758. DiId = tcl.DiId,
  1759. LastName = dc.LastName,
  1760. FirstName = dc.FirstName,
  1761. Sex = dc.Sex,
  1762. Birthday = dc.BirthDay,
  1763. Company = cc.CompanyFullName,
  1764. Job = dc.Job,
  1765. CreateTime = tcl.CreateTime,
  1766. })
  1767. .ToList();
  1768. foreach (var item in groupList)
  1769. {
  1770. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1771. string groupFirstName = "";
  1772. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1773. if (currDatas.Any())
  1774. {
  1775. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1776. }
  1777. item.GroupFirst = groupFirstName;
  1778. }
  1779. #endregion
  1780. #region Excel
  1781. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1782. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1783. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1784. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1785. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1786. //载入模板
  1787. WorkbookDesigner designer = new WorkbookDesigner();
  1788. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1789. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1790. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1791. dt.TableName = "GroupList";
  1792. designer.SetDataSource(dt);
  1793. designer.Process();
  1794. if (!Directory.Exists(savePath))
  1795. {
  1796. Directory.CreateDirectory(savePath);
  1797. }
  1798. string serverPath = $"{savePath}{fileName}";
  1799. designer.Workbook.Save(serverPath);
  1800. string rst = $"{servicePath}{ftpPath}{fileName}";
  1801. #endregion
  1802. return Ok(JsonView(true, "操作成功!", rst));
  1803. }
  1804. /// <summary>
  1805. /// 团组合同下载(1.付款80% 2.付全款)
  1806. /// </summary>
  1807. /// <param name="dto"></param>
  1808. /// <returns></returns>
  1809. /// <exception cref="Exception"></exception>
  1810. [HttpPost]
  1811. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1812. {
  1813. var jw = JsonView(false);
  1814. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1815. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1816. if (di == null)
  1817. {
  1818. jw.Msg = "团组Id有误!";
  1819. return Ok(jw);
  1820. }
  1821. #region 权限校验
  1822. var allDownFile = new List<int>() { 21 };
  1823. try
  1824. {
  1825. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1826. .First(x => x.Id == 1418 && x.IsDel == 0);
  1827. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1828. }
  1829. catch (Exception)
  1830. { }
  1831. var guojiaoDownFile = new List<int>() { 330 };
  1832. var shichangDownFile = new List<int>() { 95 };
  1833. if (allDownFile.Contains(dto.UserId))
  1834. {
  1835. }
  1836. else if (guojiaoDownFile.Contains(dto.UserId))
  1837. {
  1838. var guojiaobuDi = new List<int>() { 4, 21 };
  1839. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1840. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1841. .Where((d, u) => u.Id == di.JietuanOperator)
  1842. .Select((d, u) => d.DepName)
  1843. .First();
  1844. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1845. {
  1846. jw.Msg = "暂无下载权限!";
  1847. return Ok(jw);
  1848. }
  1849. }
  1850. else if (shichangDownFile.Contains(dto.UserId))
  1851. {
  1852. var dic = new Dictionary<int, int[]>()
  1853. {
  1854. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1855. };
  1856. try
  1857. {
  1858. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1859. if (sqSetting != null)
  1860. {
  1861. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1862. foreach (var item in result.Keys)
  1863. {
  1864. if (dic.Keys.Contains(item))
  1865. {
  1866. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1867. Array.Copy(dic[item], dilatation, dic[item].Length);
  1868. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1869. dic[item] = dilatation;
  1870. }
  1871. else
  1872. {
  1873. dic.Add(item, result[item]);
  1874. }
  1875. }
  1876. }
  1877. if (!dic[95].Contains(di.CreateUserId))
  1878. {
  1879. jw.Msg = "暂无下载权限!";
  1880. return Ok(jw);
  1881. }
  1882. }
  1883. catch (Exception)
  1884. { }
  1885. }
  1886. else if (dto.UserId == di.CreateUserId)
  1887. {
  1888. }
  1889. else
  1890. {
  1891. jw.Msg = "暂无下载权限!";
  1892. return Ok(jw);
  1893. }
  1894. #endregion
  1895. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1896. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1897. .ToListAsync();
  1898. if (!blackCodeList.Any())
  1899. {
  1900. jw.Msg = "该团无机票行程代码!";
  1901. return Ok(jw);
  1902. }
  1903. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1904. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1905. if (groupEnterExitCost == null)
  1906. {
  1907. jw.Msg = "暂无三公费用信息!";
  1908. return Ok(jw);
  1909. }
  1910. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1911. rateList ??= new List<CurrencyInfo>();
  1912. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1913. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1914. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1915. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1916. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1917. .Select((x, a, b) => new
  1918. {
  1919. x.Index,
  1920. itemName = a.Name,
  1921. CurrencyStr = b.Name,
  1922. x.Cost,
  1923. x.SubTotal,
  1924. x.Remark
  1925. })
  1926. .OrderBy((x) => x.Index)
  1927. .ToList();
  1928. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1929. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1930. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1931. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1932. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1933. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1934. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1935. decimal subJJC = 0.00M,
  1936. subGWC = 0.00M,
  1937. subTDC = 0.00M;
  1938. //经济舱
  1939. if (groupEnterExitCost.SumJJC == 1)
  1940. {
  1941. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1942. }
  1943. //公务舱
  1944. if (groupEnterExitCost.SumGWC == 1)
  1945. {
  1946. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1947. }
  1948. //头等舱
  1949. if (groupEnterExitCost.SumTDC == 1)
  1950. {
  1951. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1952. }
  1953. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1954. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1955. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1956. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1957. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1958. .Select((x, s, dc, cc) => new groupClints
  1959. {
  1960. Id = x.Id,
  1961. Name = s.Name,
  1962. IsAccompany = x.IsAccompany,
  1963. CompanyFullName = cc.CompanyFullName
  1964. })
  1965. .ToListAsync();
  1966. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1967. //获取舱位人数
  1968. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1969. .GroupBy(x => x.Name)
  1970. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1971. .ToList();
  1972. string cityPath = string.Empty;
  1973. string startCity = string.Empty;
  1974. string endCity = string.Empty;
  1975. foreach (var item in blackCodeList)
  1976. {
  1977. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1978. cityPath += city + "\r\n";
  1979. if (item.Equals(blackCodeList.First()))
  1980. {
  1981. var sp = city.Split('-');
  1982. startCity = sp[0];
  1983. endCity = sp[sp.Length - 1];
  1984. }
  1985. }
  1986. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1987. bookMarkDic.Add("ClientUnit", di.ClientUnit);
  1988. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1989. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1990. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1991. bookMarkDic.Add("CityPath", cityPath);
  1992. bookMarkDic.Add("StartCity", startCity);
  1993. bookMarkDic.Add("EndCity", endCity);
  1994. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚");
  1995. Document doc = null;
  1996. var percentage = 0.8M;
  1997. var fileNameadd = "预付";
  1998. if (dto.FileType == 1)
  1999. {
  2000. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2001. }
  2002. else if (dto.FileType == 2)
  2003. {
  2004. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2005. percentage = 1;
  2006. fileNameadd = "全款";
  2007. }
  2008. else
  2009. {
  2010. throw new Exception("FileType有误!");
  2011. }
  2012. DocumentBuilder builder = new DocumentBuilder(doc);
  2013. decimal totalPrice = 0.00M;
  2014. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2015. if (firstTable != null)
  2016. {
  2017. // 遍历表格的行和单元格
  2018. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2019. {
  2020. for (int i = 0; i < row.Cells.Count; i++)
  2021. {
  2022. var cell = row.Cells[i];
  2023. // 读取单元格内容
  2024. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2025. if (cellTextFirst.Contains("舱位"))
  2026. {
  2027. break;
  2028. }
  2029. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2030. {
  2031. if (i == 2)
  2032. {
  2033. if (cellTextFirst == "经济舱")
  2034. {
  2035. // 设置单元格内容
  2036. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2037. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2038. }
  2039. else
  2040. {
  2041. // 设置单元格内容
  2042. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2043. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2044. }
  2045. }
  2046. if (i == 3)
  2047. {
  2048. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2049. if (count != null)
  2050. {
  2051. // 设置单元格内容
  2052. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2053. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2054. }
  2055. }
  2056. if (i == 4)
  2057. {
  2058. var rowPrice = 0.00M;
  2059. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2060. count ??= 0;
  2061. if (cellTextFirst == "经济舱")
  2062. {
  2063. rowPrice = subJJC * (int)count;
  2064. }
  2065. else
  2066. {
  2067. rowPrice = subGWC * (int)count;
  2068. }
  2069. totalPrice += rowPrice;
  2070. // 设置单元格内容
  2071. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2072. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2073. }
  2074. }
  2075. }
  2076. }
  2077. }
  2078. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2079. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2080. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2081. //--合同表格部分
  2082. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2083. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2084. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2085. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2086. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2087. bookMarkDic.Add("CityPath1", cityPath);
  2088. bookMarkDic.Add("CityPath2", cityPath);
  2089. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2090. if (contractTable != null)
  2091. {
  2092. //数据源
  2093. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2094. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2095. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2096. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2097. .Select((it, y, s) => new
  2098. {
  2099. it.Cost,
  2100. it.SubTotal,
  2101. it.Type,
  2102. y.Id,
  2103. y.City,
  2104. s.Name,
  2105. CurrencyCodeCn = s.Remark
  2106. })
  2107. .ToList()
  2108. .Select(x => new
  2109. {
  2110. CurrencyCode = x.Name,
  2111. CityId = x.Id,
  2112. x.City,
  2113. VisitPNumber = di.VisitPNumber,
  2114. x.Type,
  2115. x.Cost,
  2116. x.SubTotal,
  2117. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2118. x.CurrencyCodeCn,
  2119. });
  2120. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2121. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2122. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2123. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2124. List<tableSetting> tableSettings = new List<tableSetting>()
  2125. {
  2126. new tableSetting{ Index = 1 , Property = "City"},
  2127. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2128. new tableSetting{ Index = 3 , Property = "Cost"},
  2129. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2130. //new tableSetting{ Index = 5 , Property = ""},
  2131. //new tableSetting{ Index = 6 , Property = ""},
  2132. new tableSetting{ Index = 7 , Property = "Rate"},
  2133. //new tableSetting{ Index = 8 , Property = ""},
  2134. };
  2135. //1.住宿费
  2136. int cloneRow = 8;
  2137. int startDayPrice = 8; //写入index
  2138. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2139. foreach (var dac in dac1)
  2140. {
  2141. var first = dac.First();
  2142. var dayCount = dac.Count();
  2143. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2144. for (int i = 1; i < row.Cells.Count; i++)
  2145. {
  2146. var cell = row.Cells[i];
  2147. var findProperty = tableSettings.Find(x => x.Index == i);
  2148. if (findProperty != null)
  2149. {
  2150. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2151. // 设置单元格内容
  2152. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2153. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2154. }
  2155. else
  2156. {
  2157. switch (i)
  2158. {
  2159. case 5:
  2160. cell.FirstParagraph.Runs.Clear();
  2161. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2162. break;
  2163. case 6:
  2164. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2165. cell.FirstParagraph.Runs.Clear();
  2166. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2167. break;
  2168. case 8:
  2169. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2170. cell.FirstParagraph.Runs.Clear();
  2171. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2172. ZSPriceSum += xiaojiRMB;
  2173. break;
  2174. default:
  2175. break;
  2176. }
  2177. }
  2178. }
  2179. startDayPrice++;
  2180. if (!dac1.Last().Equals(dac))
  2181. {
  2182. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2183. // 将克隆的行追加到原行后面
  2184. contractTable.Rows.Insert(startDayPrice, newRow);
  2185. }
  2186. else
  2187. {
  2188. cloneRow += dac1.Count() + 1;
  2189. startDayPrice = cloneRow;
  2190. }
  2191. }
  2192. //2.伙食费
  2193. foreach (var dac in dac2)
  2194. {
  2195. var first = dac.First();
  2196. var dayCount = dac.Count();
  2197. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2198. for (int i = 1; i < row.Cells.Count; i++)
  2199. {
  2200. var cell = row.Cells[i];
  2201. var findProperty = tableSettings.Find(x => x.Index == i);
  2202. if (findProperty != null)
  2203. {
  2204. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2205. // 设置单元格内容
  2206. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2207. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2208. }
  2209. else
  2210. {
  2211. switch (i)
  2212. {
  2213. case 5:
  2214. cell.FirstParagraph.Runs.Clear();
  2215. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2216. break;
  2217. case 6:
  2218. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2219. cell.FirstParagraph.Runs.Clear();
  2220. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2221. break;
  2222. case 8:
  2223. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2224. cell.FirstParagraph.Runs.Clear();
  2225. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2226. HSPriceSum += xiaojiRMB;
  2227. break;
  2228. default:
  2229. break;
  2230. }
  2231. }
  2232. }
  2233. startDayPrice++;
  2234. if (!dac2.Last().Equals(dac))
  2235. {
  2236. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2237. // 将克隆的行追加到原行后面
  2238. contractTable.Rows.Insert(startDayPrice, newRow);
  2239. }
  2240. else
  2241. {
  2242. cloneRow += dac2.Count() + 1;
  2243. startDayPrice = cloneRow;
  2244. }
  2245. }
  2246. //3.公杂费
  2247. foreach (var dac in dac3)
  2248. {
  2249. var first = dac.First();
  2250. var dayCount = dac.Count();
  2251. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2252. for (int i = 1; i < row.Cells.Count; i++)
  2253. {
  2254. var cell = row.Cells[i];
  2255. var findProperty = tableSettings.Find(x => x.Index == i);
  2256. if (findProperty != null)
  2257. {
  2258. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2259. // 设置单元格内容
  2260. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2261. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2262. }
  2263. else
  2264. {
  2265. switch (i)
  2266. {
  2267. case 5:
  2268. cell.FirstParagraph.Runs.Clear();
  2269. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2270. break;
  2271. case 6:
  2272. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2273. cell.FirstParagraph.Runs.Clear();
  2274. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2275. break;
  2276. case 8:
  2277. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2278. cell.FirstParagraph.Runs.Clear();
  2279. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2280. GZPriceSum += xiaojiRMB;
  2281. break;
  2282. default:
  2283. break;
  2284. }
  2285. }
  2286. }
  2287. startDayPrice++;
  2288. if (!dac3.Last().Equals(dac))
  2289. {
  2290. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2291. // 将克隆的行追加到原行后面
  2292. contractTable.Rows.Insert(startDayPrice, newRow);
  2293. }
  2294. else
  2295. {
  2296. cloneRow += dac3.Count() + 1;
  2297. startDayPrice = cloneRow;
  2298. }
  2299. }
  2300. //合并单元格
  2301. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2302. {
  2303. var currentRow = contractTable.Rows[i];
  2304. var nextRow = contractTable.Rows[i + 1];
  2305. // 获取当前行和下一行的第一个单元格
  2306. Cell currentCell = currentRow.Cells[0];
  2307. Cell nextCell = nextRow.Cells[0];
  2308. // 检查单元格内容是否一致(去除尾部的换行符)
  2309. string currentText = currentCell.GetText().Trim();
  2310. string nextText = nextCell.GetText().Trim();
  2311. if (currentText == nextText)
  2312. {
  2313. // 如果当前单元格已经被合并,找到合并的起始单元格
  2314. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2315. {
  2316. // 找到合并的起始单元格
  2317. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2318. // 将下一行的单元格设置为合并的后续单元格
  2319. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2320. }
  2321. else
  2322. {
  2323. // 如果当前单元格是合并的起始单元格
  2324. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2325. // 将下一行的单元格设置为合并的后续单元格
  2326. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2327. }
  2328. }
  2329. else
  2330. {
  2331. // 如果内容不一致,重置当前单元格的合并属性
  2332. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2333. {
  2334. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2335. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2336. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2337. }
  2338. else
  2339. {
  2340. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2341. }
  2342. }
  2343. }
  2344. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2345. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2346. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2347. }
  2348. foreach (var bookmarkName in bookMarkDic.Keys)
  2349. {
  2350. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2351. if (bookmark != null)
  2352. {
  2353. if (bookmarkName == "ClientUnit")
  2354. {
  2355. // 移动到书签位置
  2356. builder.MoveTo(bookmark.BookmarkStart);
  2357. // 设置字体样式为下划线
  2358. builder.Font.Underline = Aspose.Words.Underline.Single;
  2359. // 插入书签值
  2360. builder.Write(bookMarkDic[bookmarkName]);
  2361. // 清除字体格式,避免影响后续文本
  2362. builder.Font.ClearFormatting();
  2363. }
  2364. else
  2365. {
  2366. builder.MoveToBookmark(bookmarkName);
  2367. builder.Write(bookMarkDic[bookmarkName]);
  2368. }
  2369. }
  2370. }
  2371. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2372. doc.Save(savePaht);
  2373. jw.Msg = "生成成功!";
  2374. jw.Code = 200;
  2375. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2376. return Ok(jw);
  2377. }
  2378. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2379. {
  2380. int index = rowIndex;
  2381. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2382. {
  2383. index--;
  2384. }
  2385. return index;
  2386. }
  2387. #endregion
  2388. #region 团组&签证
  2389. /// <summary>
  2390. /// 根据团组Id获取签证客户信息List
  2391. /// </summary>
  2392. /// <param name="dto">请求dto</param>
  2393. /// <returns></returns>
  2394. [HttpPost]
  2395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2396. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2397. {
  2398. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2399. if (groupData.Code != 0)
  2400. {
  2401. return Ok(JsonView(false, groupData.Msg));
  2402. }
  2403. return Ok(JsonView(groupData.Data));
  2404. }
  2405. /// <summary>
  2406. /// IOS获取团组签证拍照上传进度01(团组列表)
  2407. /// </summary>
  2408. /// <param name="dto">请求dto</param>
  2409. /// <returns></returns>
  2410. [HttpPost]
  2411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2412. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2413. {
  2414. if (dto == null)
  2415. {
  2416. return Ok(JsonView(false, "参数为空"));
  2417. }
  2418. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2419. return Ok(JsonView(visaList));
  2420. }
  2421. /// <summary>
  2422. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2423. /// </summary>
  2424. /// <returns></returns>
  2425. [HttpPost]
  2426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2427. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2428. {
  2429. if (dto == null)
  2430. {
  2431. return Ok(JsonView(false, "请求错误:"));
  2432. }
  2433. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2434. return Ok(JsonView(list));
  2435. }
  2436. /// <summary>
  2437. /// IOS获取团组签证拍照上传进度03(相册)
  2438. /// </summary>
  2439. /// <returns></returns>
  2440. [HttpPost]
  2441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2442. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2443. {
  2444. if (dto == null)
  2445. {
  2446. return Ok(JsonView(false, "请求错误:"));
  2447. }
  2448. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2449. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2450. list.ForEach(s => s.url = url);
  2451. return Ok(JsonView(list));
  2452. }
  2453. /// <summary>
  2454. /// IOS获取团组签证拍照上传进度04(图片上传)
  2455. /// </summary>
  2456. /// <param name="dto"></param>
  2457. /// <returns></returns>
  2458. [HttpPost]
  2459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2460. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2461. {
  2462. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2463. //if (!string.IsNullOrEmpty(result))
  2464. //{
  2465. //}
  2466. //else {
  2467. // return Ok(JsonView(false, "上传失败"));
  2468. //}
  2469. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2470. int sucNum = 0;
  2471. try
  2472. {
  2473. foreach (var item in dto.base64DataList)
  2474. {
  2475. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2476. string result = DecodeBase64ToImage(item, imageName);
  2477. if (!string.IsNullOrEmpty(result))
  2478. {
  2479. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2480. pic.CreateUserId = dto.CreateUserId;
  2481. pic.PicName = imageName;
  2482. pic.PicPath = result;
  2483. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2484. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2485. if (insertResult > 0)
  2486. {
  2487. sucNum++;
  2488. }
  2489. }
  2490. }
  2491. }
  2492. catch (Exception ex)
  2493. {
  2494. return Ok(JsonView(false, ex.Message));
  2495. }
  2496. string msg = string.Format(@"成功上传{0}张", sucNum);
  2497. return Ok(JsonView(true, msg));
  2498. }
  2499. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2500. {
  2501. string filename = "";//声明一个string类型的相对路径
  2502. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2503. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2504. try//会有异常抛出,try,catch一下
  2505. {
  2506. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2507. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2508. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2509. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2510. //文件名称
  2511. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2512. //上传的文件的路径
  2513. string filePath = "";
  2514. if (!Directory.Exists(fileDir))
  2515. {
  2516. Directory.CreateDirectory(fileDir);
  2517. }
  2518. //上传的文件的路径
  2519. filePath = fileDir + filename;
  2520. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2521. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2522. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2523. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2524. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2525. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2526. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2527. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2528. bitmap.Dispose();
  2529. }
  2530. catch (Exception e)
  2531. {
  2532. string massage = e.Message;
  2533. Logs("IOS图片上传Error:" + massage);
  2534. //filename = e.Message;
  2535. }
  2536. return filename;//返回相对路径
  2537. }
  2538. /// <summary>
  2539. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2540. /// </summary>
  2541. /// <param name="dto"></param>
  2542. /// <returns></returns>
  2543. [HttpPost]
  2544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2545. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2546. {
  2547. if (dto == null)
  2548. {
  2549. return Ok(JsonView(false, "请求错误:"));
  2550. }
  2551. string msg = "参数错误";
  2552. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2553. {
  2554. try
  2555. {
  2556. //_delegationVisaRep.BeginTran();
  2557. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2558. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2559. .Where(s => s.Id == dto.visaProgressCustomerId)
  2560. .ExecuteCommandAsync();
  2561. if (updCount > 0 && dto.publishCode == 1)
  2562. {
  2563. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2564. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2565. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2566. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2567. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2568. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2569. if (groupData == null)
  2570. {
  2571. _delegationVisaRep.RollbackTran();
  2572. }
  2573. string title = string.Format(@"[签证进度更新]");
  2574. string content = string.Format(@"测试文本");
  2575. bool rst = await _message.AddMsg(new MessageDto()
  2576. {
  2577. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2578. IssuerId = dto.publisher,
  2579. Title = title,
  2580. Content = content,
  2581. ReleaseTime = DateTime.Now,
  2582. UIdList = new List<int> {
  2583. 234
  2584. }
  2585. });
  2586. if (rst)
  2587. {
  2588. return Ok(JsonView(true, "发送通知成功"));
  2589. }
  2590. }
  2591. //_delegationVisaRep.CommitTran();
  2592. }
  2593. catch (Exception)
  2594. {
  2595. //_delegationVisaRep.RollbackTran();
  2596. }
  2597. }
  2598. return Ok(JsonView(true, msg));
  2599. }
  2600. #endregion
  2601. #region 团组任务分配
  2602. /// <summary>
  2603. /// 团组任务分配初始化
  2604. /// </summary>
  2605. /// <returns></returns>
  2606. [HttpPost]
  2607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2608. public async Task<IActionResult> GetTaskAssignmen()
  2609. {
  2610. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2611. if (groupData.Code != 0)
  2612. {
  2613. return Ok(JsonView(false, groupData.Msg));
  2614. }
  2615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2616. }
  2617. /// <summary>
  2618. /// 团组任务分配查询
  2619. /// </summary>
  2620. /// <param name="dto"></param>
  2621. /// <returns></returns>
  2622. [HttpPost]
  2623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2624. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2625. {
  2626. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2627. if (groupData.Code != 0)
  2628. {
  2629. return Ok(JsonView(false, groupData.Msg));
  2630. }
  2631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2632. }
  2633. /// <summary>
  2634. /// 团组任务分配操作
  2635. /// </summary>
  2636. /// <param name="dto"></param>
  2637. /// <returns></returns>
  2638. [HttpPost]
  2639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2640. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2641. {
  2642. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2643. if (groupData.Code != 0)
  2644. {
  2645. return Ok(JsonView(false, groupData.Msg));
  2646. }
  2647. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2648. }
  2649. /// <summary>
  2650. /// 团组任务分配
  2651. /// 批量分配
  2652. /// 查询团组
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2659. {
  2660. //参数验证
  2661. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2662. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2663. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2664. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2665. }
  2666. /// <summary>
  2667. /// 团组任务分配
  2668. /// 批量分配
  2669. /// </summary>
  2670. /// <param name="dto"></param>
  2671. /// <returns></returns>
  2672. [HttpPost]
  2673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2674. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2675. {
  2676. //参数验证
  2677. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2678. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2679. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2680. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2681. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2682. }
  2683. #endregion
  2684. #region 团组费用审核
  2685. /// <summary>
  2686. /// 费用审核
  2687. /// 团组列表 Page
  2688. /// </summary>
  2689. /// <param name="_dto">团组列表请求dto</param>
  2690. /// <returns></returns>
  2691. [HttpPost]
  2692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2693. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2694. {
  2695. #region 参数验证
  2696. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2697. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2699. #region 页面操作权限验证
  2700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2701. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2702. #endregion
  2703. #endregion
  2704. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2705. {
  2706. string sqlWhere = string.Empty;
  2707. if (_dto.IsSure == 0) //未完成
  2708. {
  2709. sqlWhere += string.Format(@" And IsSure = 0");
  2710. }
  2711. else if (_dto.IsSure == 1) //已完成
  2712. {
  2713. sqlWhere += string.Format(@" And IsSure = 1");
  2714. }
  2715. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2716. {
  2717. string tj = _dto.SearchCriteria;
  2718. 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}%')",
  2719. tj, tj, tj, tj, tj);
  2720. }
  2721. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2722. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2723. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2724. From (
  2725. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2726. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2727. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2728. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2729. From Grp_DelegationInfo gdi
  2730. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2731. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2732. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2733. Where gdi.IsDel = 0 {0}
  2734. ) temp ", sqlWhere);
  2735. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2736. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2737. var _view = new
  2738. {
  2739. PageFuncAuth = pageFunAuthView,
  2740. Data = _DelegationList
  2741. };
  2742. return Ok(JsonView(true, "查询成功!", _view, total));
  2743. }
  2744. else
  2745. {
  2746. return Ok(JsonView(false, "查询失败"));
  2747. }
  2748. }
  2749. /// <summary>
  2750. /// 获取团组费用审核
  2751. /// </summary>
  2752. /// <param name="_dto"></param>
  2753. /// <returns></returns>
  2754. [HttpPost]
  2755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2756. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2757. {
  2758. try
  2759. {
  2760. #region 参数验证
  2761. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2762. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2763. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2764. #region 页面操作权限验证
  2765. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2766. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2767. #endregion
  2768. #endregion
  2769. var _view = new Grp_CreditCardPaymentView();
  2770. var clientNameList = getSimplClientList(_dto.DiId);
  2771. #region 费用清单
  2772. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2773. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2774. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2775. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2776. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2777. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2778. /*
  2779. * 76://酒店预订
  2780. */
  2781. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2782. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2783. /*
  2784. * 79://车/导游地接
  2785. */
  2786. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2787. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2788. /*
  2789. * 80: //签证
  2790. */
  2791. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2792. /*
  2793. *81: //邀请/公务活动
  2794. */
  2795. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2796. /*
  2797. * 82: //团组客户保险
  2798. */
  2799. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2800. /*
  2801. * Lable = 85 机票预订
  2802. */
  2803. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2804. /*
  2805. * 85 机票预定
  2806. */
  2807. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2808. /*
  2809. * 98 其他款项
  2810. */
  2811. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2812. /*
  2813. * 285:收款退还
  2814. */
  2815. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2816. /*
  2817. * 1015: //超支费用
  2818. */
  2819. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2820. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2821. /*
  2822. * 币种信息
  2823. */
  2824. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2825. /*
  2826. * 车/导游地接 费用类型
  2827. */
  2828. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2829. /*
  2830. * 车/导游地接 费用类型
  2831. */
  2832. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2833. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2834. /*
  2835. * 用户信息
  2836. */
  2837. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2838. /*
  2839. * 费用模块
  2840. */
  2841. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2842. string priceModule = string.Empty;
  2843. if (sdPriceName != null)
  2844. {
  2845. priceModule = sdPriceName.Name;
  2846. }
  2847. /*
  2848. * 成本信息
  2849. */
  2850. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2851. decimal _groupRate = 0.0000M;
  2852. string _groupCurrencyCode = "-";
  2853. if (groupCost != null)
  2854. {
  2855. _groupRate = groupCost.Rate;
  2856. if (int.TryParse(groupCost.Currency, out int _currency))
  2857. {
  2858. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2859. }
  2860. else _groupCurrencyCode = groupCost.Currency;
  2861. }
  2862. string costContentSql = $"Select * From Grp_GroupCost";
  2863. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2864. //处理日期为空的天数
  2865. for (int i = 0; i < groupCostDetails.Count; i++)
  2866. if (i != 0)
  2867. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2868. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2869. /*
  2870. * 处理详情数据
  2871. */
  2872. foreach (var entity in entityList)
  2873. {
  2874. var _detail = new Grp_CreditCardPaymentDetailView();
  2875. _detail.Id = entity.Id;
  2876. _detail.PriceName = priceModule;
  2877. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2878. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2879. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2880. //处理金额
  2881. if (entity.CTable == 1015)
  2882. {
  2883. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2884. if (czInfo != null)
  2885. {
  2886. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2887. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2888. }
  2889. }
  2890. /*
  2891. * 应付款金额
  2892. */
  2893. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2894. string PaymentCurrency_WaitPay = "Unknown";
  2895. string hotelCurrncyCode = "Unknown";
  2896. string hotelCurrncyName = "Unknown";
  2897. if (sdPaymentCurrency_WaitPay != null)
  2898. {
  2899. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2900. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2901. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2902. if (hotelCurrncyCode.Equals("CNY"))
  2903. {
  2904. entity.DayRate = 1.0000M;
  2905. }
  2906. }
  2907. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2908. /*
  2909. * 此次付款金额
  2910. */
  2911. decimal CurrPayStr = 0.00M,
  2912. OriginalCurrPay = 0.00M;
  2913. if (entity.PayPercentage == 0)
  2914. {
  2915. if (entity.PayThenMoney != 0)
  2916. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2917. }
  2918. else
  2919. {
  2920. if (entity.PayMoney != 0)
  2921. {
  2922. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2923. }
  2924. }
  2925. //if (_dto.Label == 79)
  2926. //{
  2927. // string original = string.Empty;
  2928. // if (hotelCurrncyCode.Equals("CNY"))
  2929. // {
  2930. // OriginalCurrPay = CurrPayStr;
  2931. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2932. // }
  2933. // else
  2934. // {
  2935. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2936. // //760 EUR(7600.00 CNY)
  2937. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2938. // }
  2939. //}
  2940. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2941. string original = string.Empty;
  2942. if (hotelCurrncyCode.Equals("CNY"))
  2943. {
  2944. OriginalCurrPay = CurrPayStr;
  2945. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2946. }
  2947. else
  2948. {
  2949. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2950. //760 EUR(7600.00 CNY)
  2951. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2952. }
  2953. /*
  2954. * 剩余尾款
  2955. */
  2956. decimal BalanceStr = 0;
  2957. if (CurrPayStr != 0)
  2958. {
  2959. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2960. BalanceStr = 0;
  2961. else
  2962. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2963. }
  2964. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2965. /*
  2966. * Bus名称
  2967. */
  2968. _detail.BusName = "待增加";
  2969. /*
  2970. *费用所属
  2971. */
  2972. switch (entity.CTable)
  2973. {
  2974. case 76://酒店预订
  2975. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2976. if (hotelReservations != null)
  2977. {
  2978. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2979. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2980. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2981. string roomFeeStr = "", roomFeestr1 = "";
  2982. //是否比较房型价格
  2983. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2984. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2985. roomFeeStr += $"<br/>";
  2986. var roomTotal = 0.00M;
  2987. if (hotelReservations.SingleRoomPrice > 0)
  2988. {
  2989. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  2990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2991. //__isSingle = true;
  2992. roomTotal += fee;
  2993. }
  2994. if (hotelReservations.DoubleRoomPrice > 0)
  2995. {
  2996. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  2997. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2998. // __isDouble = true;
  2999. roomTotal += fee;
  3000. }
  3001. if (hotelReservations.SuiteRoomPrice > 0)
  3002. {
  3003. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3004. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3005. //__isSuite = true;
  3006. roomTotal += fee;
  3007. }
  3008. if (hotelReservations.OtherRoomPrice > 0)
  3009. {
  3010. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3011. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3012. //__isOther = true;
  3013. roomTotal += fee;
  3014. }
  3015. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3016. else roomFeeStr += " 0.00 * 0";
  3017. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3018. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3019. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3020. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3021. /*
  3022. * 费用类型
  3023. * 1:房费
  3024. * 2:早餐
  3025. * 3:地税
  3026. * 4:城市税
  3027. * </summary>
  3028. */
  3029. //地税
  3030. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3031. if (governmentRentData != null)
  3032. {
  3033. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3034. governmentRentFee = governmentRentData.Price;
  3035. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3036. if (governmentRentCurrData != null)
  3037. {
  3038. governmentRentCode = governmentRentCurrData.Name;
  3039. governmentRentName = $"({governmentRentCurrData.Remark})";
  3040. }
  3041. }
  3042. //城市税
  3043. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3044. if (cityTaxData != null)
  3045. {
  3046. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3047. cityTaxFee = cityTaxData.Price;
  3048. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3049. if (cityTaxCurrData != null)
  3050. {
  3051. cityTaxCode = cityTaxCurrData.Name;
  3052. cityTaxName = $"({cityTaxCurrData.Remark})";
  3053. }
  3054. }
  3055. //酒店早餐
  3056. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3057. if (breakfastData != null)
  3058. {
  3059. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3060. breakfastFee = breakfastData.Price;
  3061. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3062. if (breakfastCurrData != null)
  3063. {
  3064. breakfastCode = breakfastCurrData.Name;
  3065. breakfastName = $"({breakfastCurrData.Remark})";
  3066. }
  3067. }
  3068. //房间费用
  3069. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3070. if (roomData != null)
  3071. {
  3072. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3073. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3074. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3075. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3076. roomFee = roomData.Price;
  3077. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3078. if (roomCurrData != null)
  3079. {
  3080. roomCode = roomCurrData.Name;
  3081. roomName = $"({roomCurrData.Remark})";
  3082. }
  3083. }
  3084. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3085. string hotelCostStr = "";
  3086. decimal hotelCsotTotal = 0.00M;
  3087. if (groupCost != null)
  3088. {
  3089. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3090. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3091. }
  3092. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3093. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3094. string hotelCost_day = "";
  3095. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3096. foreach (var item in hotelCostDetails1)
  3097. {
  3098. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3099. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3100. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3101. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3102. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3103. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3104. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3105. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3106. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3107. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3108. hotelCost_day += @$"<br/>";
  3109. }
  3110. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3111. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3112. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3113. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3114. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3115. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3116. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3117. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3118. $"房间说明: {hotelReservations.Remark} <br/>" +
  3119. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3120. $"{hotelBreakfastStr}" +
  3121. $"{hotelGovernmentRentStr}" +
  3122. $"{hotelCityTaxStr}";
  3123. _detail.PriceNameContent = hotelReservations.HotelName;
  3124. }
  3125. break;
  3126. case 79://车/导游地接
  3127. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3128. if (touristGuideGroundReservations != null)
  3129. {
  3130. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3131. {
  3132. _detail.BusName = touristGuideGroundReservations.BusName;
  3133. }
  3134. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3135. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3136. //if (isInt)
  3137. //{
  3138. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3139. // if (cityInfo != null)
  3140. // {
  3141. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3142. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3143. // if (carFeeItem != null)
  3144. // {
  3145. // nameContent += $@"({carFeeItem.Name})";
  3146. // }
  3147. // _detail.PriceNameContent = nameContent;
  3148. // }
  3149. //}
  3150. //else
  3151. //{
  3152. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3153. //}
  3154. var touristGuideGroundReservationsContents =
  3155. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3156. var opContent_sb = new StringBuilder();
  3157. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3158. opContent_sb.AppendLine(contetTitle);
  3159. foreach (var item in touristGuideGroundReservationsContents)
  3160. {
  3161. string typeName = "Unknown";
  3162. string carCurrencyCode = "Unknown";
  3163. string carCurrencyName = "Unknown";
  3164. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3165. if (carTypeData != null) typeName = carTypeData.Name;
  3166. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3167. if (currencyData != null)
  3168. {
  3169. carCurrencyCode = currencyData.Name;
  3170. carCurrencyName = currencyData.Remark;
  3171. }
  3172. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3173. bool IsCurrencyAgreement = false;
  3174. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3175. string opCostStr = string.Empty;
  3176. decimal opCostTypePrice = 0.00M;
  3177. #region 处理成本各项费用
  3178. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3179. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3180. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3181. costOPFeeCNY = 0.00M, //团组成本 op费用
  3182. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3183. if (opCost.Count > 0)
  3184. {
  3185. switch (item.SId)
  3186. {
  3187. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3188. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3189. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3190. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3191. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3192. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3193. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3194. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3195. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3196. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3197. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3198. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3199. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3200. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3201. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3202. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3203. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3204. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3205. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3206. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3207. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3208. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3209. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3210. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3211. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3212. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3213. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3214. }
  3215. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3216. costOPFeeCNY = opCostTypePrice * _groupRate;
  3217. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3218. }
  3219. #endregion
  3220. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3221. aduitOPFeeCNY = item.Price * entity.DayRate;
  3222. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3223. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3224. $"{opTypeStr} {opCostStr}<br/>" +
  3225. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3226. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3227. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3228. {
  3229. if (IsCurrencyAgreement)
  3230. {
  3231. if (item.Price > opCostTypePrice)
  3232. {
  3233. opContent_sb.Append("<span style='color:red;'>");
  3234. opContent_sb.Append(opContent);
  3235. opContent_sb.Append("</span>");
  3236. opContent_sb.AppendLine();
  3237. }
  3238. else
  3239. {
  3240. opContent_sb.Append(opContent);
  3241. opContent_sb.AppendLine();
  3242. }
  3243. }
  3244. else
  3245. {
  3246. //验证是否超成本 按付款比例计算
  3247. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3248. {
  3249. opContent_sb.Append("<span style='color:red;'>");
  3250. opContent_sb.Append(opContent);
  3251. opContent_sb.Append("</span>");
  3252. opContent_sb.AppendLine();
  3253. }
  3254. else
  3255. {
  3256. opContent_sb.Append(opContent);
  3257. opContent_sb.AppendLine();
  3258. }
  3259. }
  3260. }
  3261. else
  3262. {
  3263. opContent_sb.Append(opContent);
  3264. opContent_sb.AppendLine();
  3265. }
  3266. }
  3267. _detail.PriceMsgContent = opContent_sb.ToString();
  3268. }
  3269. break;
  3270. case 80: //签证
  3271. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3272. if (visaInfo != null)
  3273. {
  3274. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3275. _detail.PriceNameContent = visaInfo.VisaDescription;
  3276. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3277. }
  3278. break;
  3279. case 81: //邀请/公务活动
  3280. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3281. if (_ioa != null)
  3282. {
  3283. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3284. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3285. sendCurrName = "Unknown", //快递费用币种 Name
  3286. sendCurrCode = "Unknown", //快递费用币种 Code
  3287. eventsCurrName = "Unknown", //公务活动费币种 Name
  3288. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3289. translateCurrName = "Unknown", //公务翻译费 Name
  3290. translateCurrCode = "Unknown"; //公务翻译费 Code
  3291. #region 处理费用币种
  3292. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3293. if (inviteCurrData != null)
  3294. {
  3295. inviteCurrName = inviteCurrData.Remark;
  3296. inviteCurrCode = inviteCurrData.Name;
  3297. }
  3298. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3299. if (sendCurrData != null)
  3300. {
  3301. sendCurrName = sendCurrData.Remark;
  3302. sendCurrCode = sendCurrData.Name;
  3303. }
  3304. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3305. if (eventsCurrData != null)
  3306. {
  3307. eventsCurrName = eventsCurrData.Remark;
  3308. eventsCurrCode = eventsCurrData.Name;
  3309. }
  3310. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3311. if (translateCurrData != null)
  3312. {
  3313. translateCurrName = translateCurrData.Remark;
  3314. translateCurrCode = translateCurrData.Name;
  3315. }
  3316. #endregion
  3317. _detail.PriceNameContent = _ioa.InviterArea;
  3318. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3319. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3320. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3321. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3322. $@"备注:" + _ioa.Remark + "<br/>";
  3323. }
  3324. break;
  3325. case 82: //团组客户保险
  3326. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3327. if (customers != null)
  3328. {
  3329. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3330. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3331. }
  3332. break;
  3333. case 85: //机票预订
  3334. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3335. if (jpRes != null)
  3336. {
  3337. string FlightsDescription = jpRes.FlightsDescription;
  3338. string PriceDescription = jpRes.PriceDescription;
  3339. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3340. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3341. }
  3342. break;
  3343. case 98://其他款项
  3344. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3345. if (gdpRes != null)
  3346. {
  3347. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3348. _detail.PriceNameContent = gdpRes.PriceName;
  3349. }
  3350. break;
  3351. case 285://收款退还
  3352. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3353. if (refundAndOtherMoney != null)
  3354. {
  3355. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3356. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3357. }
  3358. break;
  3359. case 751://酒店早餐
  3360. break;
  3361. case 1015://超支费用
  3362. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3363. if (groupExtraCost != null)
  3364. {
  3365. _detail.PriceNameContent = groupExtraCost.PriceName;
  3366. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3367. }
  3368. break;
  3369. default:
  3370. break;
  3371. }
  3372. /*
  3373. * 申请人
  3374. */
  3375. string operatorName = " - ";
  3376. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3377. if (_opUser != null)
  3378. {
  3379. operatorName = _opUser.CnName;
  3380. }
  3381. _detail.OperatorName = operatorName;
  3382. /*
  3383. * 审核人
  3384. */
  3385. string auditOperatorName = " - ";
  3386. if (entity.IsAuditGM != 0)
  3387. {
  3388. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3389. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3390. else
  3391. {
  3392. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3393. if (_adUser != null)
  3394. {
  3395. auditOperatorName = _adUser.CnName;
  3396. }
  3397. }
  3398. }
  3399. _detail.AuditOperatorName = auditOperatorName;
  3400. /*
  3401. * 超预算比例
  3402. */
  3403. string overBudgetStr = "";
  3404. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3405. else if (entity.ExceedBudget == 0)
  3406. {
  3407. if (entity.CTable == 76 || entity.CTable == 79)
  3408. {
  3409. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3410. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3411. }
  3412. else
  3413. {
  3414. overBudgetStr = "未超预算";
  3415. }
  3416. }
  3417. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3418. _detail.OverBudget = overBudgetStr;
  3419. decimal auditFee = 0.00M; //已审核金额 人名币
  3420. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3421. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3422. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3423. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3424. {
  3425. auditedFeeOriginal = entity.PayMoney;
  3426. auditFee = CurrPayStr;
  3427. }
  3428. else if (entity.IsAuditGM == 0)
  3429. {
  3430. unAuditFeeCNY = CurrPayStr;
  3431. unAuditFeeOriginal = OriginalCurrPay;
  3432. OriginalCurrPay = 0.00M;
  3433. }
  3434. /*
  3435. * 费用总计
  3436. */
  3437. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3438. {
  3439. CurrencyId = entity.PaymentCurrency,
  3440. CurrencyName = PaymentCurrency_WaitPay,
  3441. AmountPayable = entity.PayMoney,
  3442. ThisPayment = OriginalCurrPay,
  3443. BalancePayment = BalanceStr,
  3444. AuditedFunds = auditFee,
  3445. AuditedFundsOriginal = auditedFeeOriginal,
  3446. UnAuditFundsCNY = unAuditFeeCNY,
  3447. UnAuditFundsOriginal = unAuditFeeOriginal
  3448. });
  3449. _detail.IsAuditGM = entity.IsAuditGM;
  3450. detailList.Add(_detail);
  3451. }
  3452. #endregion
  3453. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3454. /*
  3455. * 下方描述处理
  3456. */
  3457. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3458. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3459. if (ccpCurrencyPrice != null)
  3460. {
  3461. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3462. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3463. }
  3464. else
  3465. {
  3466. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3467. }
  3468. string amountPayableStr = string.Format(@"应付款总金额: ");
  3469. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3470. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3471. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3472. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3473. foreach (var item in nonDuplicat)
  3474. {
  3475. var currencyName = item.CurrencyName;
  3476. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3477. if (strs.Count > 0)
  3478. {
  3479. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3480. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3481. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3482. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3483. //单独处理此次付款金额
  3484. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3485. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3486. //单独处理已审核费用
  3487. //if (item.CurrencyId == 836) //人民币
  3488. //{
  3489. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3490. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3491. //}
  3492. //else
  3493. //{
  3494. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3495. //}
  3496. if (currencyName.Equals("CNY"))
  3497. {
  3498. //已审核费用
  3499. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3500. //未审核费用
  3501. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3502. }
  3503. else
  3504. {
  3505. //已审核费用
  3506. 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"));
  3507. //未审核费用
  3508. 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"));
  3509. }
  3510. }
  3511. }
  3512. _view.TotalStr1 = amountPayableStr[..^1];
  3513. _view.TotalStr2 = thisPaymentStr[..^1];
  3514. _view.TotalStr3 = balancePaymentStr[..^1];
  3515. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3516. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3517. var _view1 = new
  3518. {
  3519. PageFuncAuth = pageFunAuthView,
  3520. Data = _view
  3521. };
  3522. return Ok(JsonView(_view1));
  3523. }
  3524. catch (Exception ex)
  3525. {
  3526. return Ok(JsonView(false, ex.Message));
  3527. }
  3528. }
  3529. /// <summary>
  3530. /// 费用审核
  3531. /// 修改团组费用审核状态
  3532. /// </summary>
  3533. /// <param name="_dto">参数Json字符串</param>
  3534. /// <returns></returns>
  3535. [HttpPost]
  3536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3537. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3538. {
  3539. #region 参数验证
  3540. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3541. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3542. #endregion
  3543. #region 页面操作权限验证
  3544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3545. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3546. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3547. #endregion
  3548. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3549. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3550. DateTime dtNow = DateTime.Now;
  3551. _groupRepository.BeginTran();
  3552. int rst = 0;
  3553. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3554. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3555. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3556. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3557. List<dynamic> msgDatas = new List<dynamic>();
  3558. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3559. foreach (var item in idList)
  3560. {
  3561. int CreditId = int.Parse(item);
  3562. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3563. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3564. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3565. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3566. .Where(s => s.Id == CreditId)
  3567. .ExecuteCommandAsync();
  3568. if (result < 1)
  3569. {
  3570. rst = -1;
  3571. _groupRepository.RollbackTran();
  3572. return Ok(JsonView(false, "操作失败并回滚!"));
  3573. }
  3574. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3575. if (creditData != null)
  3576. {
  3577. #region 应用通知配置
  3578. try
  3579. {
  3580. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3581. }
  3582. catch (Exception ex)
  3583. {
  3584. }
  3585. #endregion
  3586. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3587. string groupNameStr = string.Empty;
  3588. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3589. if (groupData != null) groupNameStr = groupData.TeamName;
  3590. string creditTypeStr = string.Empty;
  3591. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3592. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3593. string creditCurrency = string.Empty;
  3594. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3595. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3596. if (creditCurrency.Equals("CNY"))
  3597. {
  3598. creditData.DayRate = 1.0000M;
  3599. }
  3600. if (creditData.PayPercentage == 0.00M)
  3601. {
  3602. creditData.PayPercentage = 100M;
  3603. }
  3604. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3605. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3606. string msgContent = "";
  3607. if (creditCurrency.Equals("CNY"))
  3608. {
  3609. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3610. }
  3611. else
  3612. {
  3613. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3614. }
  3615. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3616. }
  3617. }
  3618. if (rst == 0)
  3619. {
  3620. _groupRepository.CommitTran();
  3621. foreach (var item in msgDatas)
  3622. {
  3623. //发送消息
  3624. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3625. }
  3626. #region 应用推送
  3627. try
  3628. {
  3629. foreach (var ccpId in dic_ccp_user.Keys)
  3630. {
  3631. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3632. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3633. }
  3634. }
  3635. catch (Exception)
  3636. {
  3637. }
  3638. #endregion
  3639. return Ok(JsonView(true, "操作成功!"));
  3640. }
  3641. return Ok(JsonView(false, "操作失败!"));
  3642. }
  3643. #endregion
  3644. #region 机票费用录入
  3645. /// <summary>
  3646. /// 机票录入当前登录人可操作团组
  3647. /// </summary>
  3648. /// <param name="dto"></param>
  3649. /// <returns></returns>
  3650. [HttpPost]
  3651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3652. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3653. {
  3654. try
  3655. {
  3656. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3657. if (groupData.Code != 0)
  3658. {
  3659. return Ok(JsonView(false, groupData.Msg));
  3660. }
  3661. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3662. }
  3663. catch (Exception ex)
  3664. {
  3665. return Ok(JsonView(false, "程序错误!"));
  3666. throw;
  3667. }
  3668. }
  3669. /// <summary>
  3670. /// 机票费用录入列表
  3671. /// </summary>
  3672. /// <param name="dto"></param>
  3673. /// <returns></returns>
  3674. [HttpPost]
  3675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3676. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3677. {
  3678. try
  3679. {
  3680. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3681. if (groupData.Code != 0)
  3682. {
  3683. return Ok(JsonView(false, groupData.Msg));
  3684. }
  3685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3686. }
  3687. catch (Exception ex)
  3688. {
  3689. return Ok(JsonView(false, ex.Message));
  3690. throw;
  3691. }
  3692. }
  3693. /// <summary>
  3694. /// 根据id查询费用录入信息
  3695. /// </summary>
  3696. /// <param name="dto"></param>
  3697. /// <returns></returns>
  3698. [HttpPost]
  3699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3700. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3701. {
  3702. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3703. if (groupData.Code != 0)
  3704. {
  3705. return Ok(JsonView(false, groupData.Msg));
  3706. }
  3707. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3708. }
  3709. /// <summary>
  3710. /// 机票费用录入操作(Status:1.新增,2.修改)
  3711. /// </summary>
  3712. /// <param name="dto"></param>
  3713. /// <returns></returns>
  3714. [HttpPost]
  3715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3716. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3717. {
  3718. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3719. if (groupData.Code != 0)
  3720. {
  3721. return Ok(JsonView(false, groupData.Msg));
  3722. }
  3723. #region 应用推送
  3724. try
  3725. {
  3726. var diId = dto.AirTicketResOpData.DiId;
  3727. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3728. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3729. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3730. //自动审核
  3731. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3732. (bool status,string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3733. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3734. $"GroupId:{diId};airId:{dataId};",
  3735. status,
  3736. auditMsg);
  3737. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3738. //2024-10-21 新增LZ UID
  3739. var userIds = new List<int>() { 21 };
  3740. string title = $"系统通知";
  3741. string content = "";
  3742. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3743. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3744. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3745. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3746. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3747. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3748. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3749. }
  3750. catch (Exception ex)
  3751. {
  3752. }
  3753. #endregion
  3754. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3755. }
  3756. /// <summary>
  3757. /// 机票费用自动审核 AI识别方式
  3758. /// </summary>
  3759. /// <returns></returns>
  3760. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3761. {
  3762. var ecoTypeIds = new List<int>() {
  3763. 459, //超经舱
  3764. 460, //经济舱
  3765. 1430, //公务舱(实际经济舱)
  3766. 1432, //头等舱(实际经济舱)
  3767. };
  3768. var bizTypeIds = new List<int>() {
  3769. 457, //头等舱
  3770. 458, //公务舱
  3771. 1431, //头等舱(实际公务舱)
  3772. };
  3773. var auditFeeTypeIds = new List<int>() {};
  3774. auditFeeTypeIds.AddRange(ecoTypeIds);
  3775. auditFeeTypeIds.AddRange(bizTypeIds);
  3776. int currModule = 85;
  3777. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3778. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3779. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3780. .Select((x, y) => new
  3781. {
  3782. x.Id,
  3783. CcpId = y.Id,
  3784. x.FlightsDate,
  3785. x.PrePrice,
  3786. x.CType,
  3787. x.ClientNum,
  3788. x.DIId
  3789. })
  3790. .FirstAsync();
  3791. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3792. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3793. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3794. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3795. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3796. var groupCostContents = await _sqlSugar
  3797. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3798. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3799. .ToListAsync();
  3800. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3801. //处理 成本详细信息日期为空 填装费用信息
  3802. var airFeeLabel = new StringBuilder();
  3803. airFeeLabel.AppendLine("费用成本:");
  3804. for (int i = 0; i < groupCostContents.Count; i++)
  3805. {
  3806. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3807. {
  3808. int index = i - 1;
  3809. if (index >= 0)
  3810. {
  3811. groupCostContents[i].Date = groupCostContents[index].Date;
  3812. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3813. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3814. }
  3815. }
  3816. else
  3817. {
  3818. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3819. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3820. }
  3821. var item = groupCostContents[i];
  3822. airFeeLabel.AppendLine($"{item.Date}");
  3823. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3824. }
  3825. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3826. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3827. //访问Kimi AI 返回价格结果
  3828. var msgs = new List<SeedMessages>()
  3829. {
  3830. new ()
  3831. {
  3832. Role = KimiRole.user,
  3833. Content = airFeeLabel.ToString()
  3834. }
  3835. };
  3836. KiMiApiClient client = new KiMiApiClient();
  3837. var kimiApiResult = await client.SeedMessage(msgs);
  3838. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3839. string clients = kimiApiResult_JObject["content"].ToString();
  3840. decimal ecoPri_kimiAI = 0.00M,
  3841. bizPri_kimiAI = 0.00M;
  3842. //单个价格: 经济舱价格
  3843. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3844. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3845. if (clients.Contains('/'))
  3846. {
  3847. var priArray = clients.Split('/');
  3848. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3849. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3850. }
  3851. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3852. var isAutoAudit = false;
  3853. //价格验证处理
  3854. //经济舱
  3855. if (ecoTypeIds.Contains(airInfo.CType))
  3856. {
  3857. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3858. }
  3859. //公务舱
  3860. else if (bizTypeIds.Contains(airInfo.CType))
  3861. {
  3862. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3863. }
  3864. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3865. //是否执行自动审核
  3866. if (isAutoAudit)
  3867. {
  3868. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3869. .SetColumns(x => x.IsAuditGM == 3)
  3870. .SetColumns(x => x.AuditGMOperate == 4)
  3871. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3872. .Where(x => x.Id == airInfo.CcpId)
  3873. .ExecuteCommandAsync();
  3874. if (auditStatus > 0 ) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3875. }
  3876. return (false, "当前费用超过成本费用,不可自动审核!");
  3877. }
  3878. /// <summary>
  3879. /// 机票费用录入
  3880. /// 自动审核测试 - AI 识别
  3881. /// </summary>
  3882. /// <param name="groupId"></param>
  3883. /// <param name="Id"></param>
  3884. /// <returns></returns>
  3885. [HttpPost]
  3886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3887. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3888. {
  3889. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  3890. return Ok(JsonView(status, msg));
  3891. }
  3892. /// <summary>
  3893. /// 根据舱位类型查询接团客户名单信息
  3894. /// </summary>
  3895. /// <param name="dto"></param>
  3896. /// <returns></returns>
  3897. [HttpPost]
  3898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3899. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3900. {
  3901. try
  3902. {
  3903. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3904. if (crm_Groups.Count != 0)
  3905. {
  3906. List<dynamic> Customer = new List<dynamic>();
  3907. foreach (var item in crm_Groups)
  3908. {
  3909. var data = new
  3910. {
  3911. Id = item.Id,
  3912. Pinyin = item.Pinyin,
  3913. Name = item.LastName + item.FirstName
  3914. };
  3915. Customer.Add(data);
  3916. }
  3917. return Ok(JsonView(true, "查询成功!", Customer));
  3918. }
  3919. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3920. }
  3921. catch (Exception ex)
  3922. {
  3923. return Ok(JsonView(false, "程序错误!"));
  3924. throw;
  3925. }
  3926. }
  3927. /// <summary>
  3928. /// 根据团号获取客户信息
  3929. /// </summary>
  3930. /// <param name="dto"></param>
  3931. /// <returns></returns>
  3932. [HttpPost]
  3933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3934. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3935. {
  3936. var jw = JsonView(false);
  3937. if (dto.DIID < 1)
  3938. {
  3939. jw.Msg += "请输入正确的diid";
  3940. return Ok(jw);
  3941. }
  3942. var arr = getSimplClientList(dto.DIID);
  3943. jw = JsonView(true, "获取成功!", arr);
  3944. return Ok(jw);
  3945. }
  3946. private List<SimplClientInfo> getSimplClientList(int diId)
  3947. {
  3948. 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);
  3949. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3950. foreach (var item in arr)
  3951. {
  3952. EncryptionProcessor.DecryptProperties(item);
  3953. }
  3954. return arr;
  3955. }
  3956. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3957. {
  3958. string result = origin;
  3959. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3960. {
  3961. string[] temparr = origin.Split(',');
  3962. string fistrStr = temparr[0];
  3963. int count = temparr.Count();
  3964. int tempId;
  3965. bool success = int.TryParse(fistrStr, out tempId);
  3966. if (success)
  3967. {
  3968. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3969. if (tempInfo != null)
  3970. {
  3971. if (count > 1)
  3972. {
  3973. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3974. }
  3975. else
  3976. {
  3977. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3978. }
  3979. }
  3980. }
  3981. }
  3982. return result;
  3983. }
  3984. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3985. {
  3986. string result = origin;
  3987. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3988. {
  3989. string[] temparr = origin.Split(',');
  3990. result = "";
  3991. foreach (var item in temparr)
  3992. {
  3993. int tempId;
  3994. bool success = int.TryParse(item, out tempId);
  3995. if (success)
  3996. {
  3997. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3998. if (tempInfo != null)
  3999. {
  4000. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  4001. }
  4002. }
  4003. }
  4004. }
  4005. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4006. return result;
  4007. }
  4008. /// <summary>
  4009. /// 机票费用录入,删除
  4010. /// </summary>
  4011. /// <param name="dto"></param>
  4012. /// <returns></returns>
  4013. [HttpPost]
  4014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4015. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4016. {
  4017. try
  4018. {
  4019. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4020. if (res)
  4021. {
  4022. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4023. {
  4024. IsDel = 1,
  4025. DeleteUserId = dto.DeleteUserId,
  4026. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4027. }).ExecuteCommandAsync();
  4028. return Ok(JsonView(true, "删除成功!"));
  4029. }
  4030. return Ok(JsonView(false, "删除失败!"));
  4031. }
  4032. catch (Exception ex)
  4033. {
  4034. return Ok(JsonView(false, "程序错误!"));
  4035. throw;
  4036. }
  4037. }
  4038. /// <summary>
  4039. /// 导出机票录入报表
  4040. /// </summary>
  4041. /// <param name="dto"></param>
  4042. /// <returns></returns>
  4043. [HttpPost]
  4044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4045. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4046. {
  4047. try
  4048. {
  4049. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4050. if (groupData.Code != 0)
  4051. {
  4052. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4053. }
  4054. else
  4055. {
  4056. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4057. if (AirTicketReservations.Count != 0)
  4058. {
  4059. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4060. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4061. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4062. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4063. WorkbookDesigner designer = new WorkbookDesigner();
  4064. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  4065. decimal countCost = 0;
  4066. foreach (var item in AirTicketReservations)
  4067. {
  4068. #region 处理客人姓名
  4069. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  4070. item.ClientName = clientNames;
  4071. #endregion
  4072. if (item.BankType == "其他")
  4073. {
  4074. item.BankNo = "--";
  4075. }
  4076. else
  4077. {
  4078. if (!string.IsNullOrEmpty(item.BankType))
  4079. {
  4080. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4081. }
  4082. }
  4083. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4084. item.Price = System.Decimal.Round(item.Price, 2);
  4085. countCost += Convert.ToDecimal(item.Price);
  4086. }
  4087. designer.SetDataSource("Export", AirTicketReservations);
  4088. designer.SetDataSource("ExportDiCode", diCode);
  4089. designer.SetDataSource("ExportDiName", diName);
  4090. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4091. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4092. designer.Process();
  4093. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4094. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4095. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4096. return Ok(JsonView(true, "成功", url = rst));
  4097. }
  4098. else
  4099. {
  4100. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4101. }
  4102. }
  4103. }
  4104. catch (Exception ex)
  4105. {
  4106. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4107. throw;
  4108. }
  4109. }
  4110. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4111. /// <summary>
  4112. /// 行程单导出
  4113. /// </summary>
  4114. /// <param name="dto"></param>
  4115. /// <returns></returns>
  4116. [HttpPost]
  4117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4118. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4119. {
  4120. try
  4121. {
  4122. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4123. if (groupData.Code != 0)
  4124. {
  4125. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4126. }
  4127. else
  4128. {
  4129. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4130. if (dto.Language == "CN")
  4131. {
  4132. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4133. DocumentBuilder builder = new DocumentBuilder(doc);
  4134. int tableIndex = 0;//表格索引
  4135. //得到文档中的第一个表格
  4136. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4137. foreach (var item in _AirTicketReservations)
  4138. {
  4139. #region 处理固定数据
  4140. string[] FlightsCode = item.FlightsCode.Split('/');
  4141. if (FlightsCode.Length != 0)
  4142. {
  4143. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4144. if (_AirCompany != null)
  4145. {
  4146. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4147. }
  4148. else
  4149. {
  4150. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4151. }
  4152. }
  4153. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4154. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4155. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4156. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4157. string name = "";
  4158. foreach (string clientName in nameArray)
  4159. {
  4160. if (!name.Contains(clientName))
  4161. {
  4162. name += clientName + ",";
  4163. }
  4164. }
  4165. if (!string.IsNullOrWhiteSpace(name))
  4166. {
  4167. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4168. }
  4169. else
  4170. {
  4171. table.Range.Bookmarks["ClientName"].Text = "--";
  4172. }
  4173. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4174. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4175. table.Range.Bookmarks["JointTicket"].Text = "--";
  4176. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4177. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4178. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4179. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4180. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4181. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4182. #endregion
  4183. #region 循环数据处理
  4184. List<AirInfo> airs = new List<AirInfo>();
  4185. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4186. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4187. for (int i = 0; i < FlightsCode.Length; i++)
  4188. {
  4189. AirInfo air = new AirInfo();
  4190. string[] tempstr = DayArray[i]
  4191. .Replace("\r\n", string.Empty)
  4192. .Replace("\\r\\n", string.Empty)
  4193. .TrimStart().TrimEnd()
  4194. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4195. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4196. string starCity = "";
  4197. if (star_Three != null)
  4198. {
  4199. starCity = star_Three.AirPort;
  4200. }
  4201. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4202. string EndCity = "";
  4203. if (End_Three != null)
  4204. {
  4205. EndCity = End_Three.AirPort;
  4206. }
  4207. air.Destination = starCity + "/" + EndCity;
  4208. air.Flight = FlightsCode[i];
  4209. air.SeatingClass = item.CTypeName;
  4210. string dateTime = tempstr[2];
  4211. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4212. air.FlightDate = DateTemp;
  4213. air.DepartureTime = tempstr[5];
  4214. air.LandingTime = tempstr[6];
  4215. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4216. air.TicketStatus = "--";
  4217. air.Luggage = "--";
  4218. air.DepartureTerminal = "--";
  4219. air.LandingTerminal = "--";
  4220. airs.Add(air);
  4221. }
  4222. int row = 13;
  4223. for (int i = 0; i < airs.Count; i++)
  4224. {
  4225. if (airs.Count > 2)
  4226. {
  4227. for (int j = 0; j < airs.Count - 2; j++)
  4228. {
  4229. var CopyRow = table.Rows[12].Clone(true);
  4230. table.Rows.Add(CopyRow);
  4231. }
  4232. }
  4233. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4234. int index = 0;
  4235. foreach (PropertyInfo property in properties)
  4236. {
  4237. string value = property.GetValue(airs[i]).ToString();
  4238. Cell ishcel0 = table.Rows[row].Cells[index];
  4239. Paragraph p = new Paragraph(doc);
  4240. string s = value;
  4241. p.AppendChild(new Run(doc, s));
  4242. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4243. ishcel0.AppendChild(p);
  4244. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4245. index++;
  4246. }
  4247. row++;
  4248. }
  4249. #endregion
  4250. Paragraph lastParagraph = new Paragraph(doc);
  4251. //第一个表格末尾加段落
  4252. table.ParentNode.InsertAfter(lastParagraph, table);
  4253. //复制第一个表格
  4254. Table cloneTable = (Table)table.Clone(true);
  4255. //在文档末尾段落后面加入复制的表格
  4256. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4257. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4258. {
  4259. int rownewsIndex = 13;
  4260. for (int i = 0; i < 2; i++)
  4261. {
  4262. var CopyRow = table.Rows[12].Clone(true);
  4263. table.Rows.RemoveAt(13);
  4264. table.Rows.Add(CopyRow);
  4265. rownewsIndex++;
  4266. }
  4267. }
  4268. else
  4269. {
  4270. table.Rows.RemoveAt(12);
  4271. }
  4272. cloneTable.Rows.RemoveAt(12);
  4273. }
  4274. if (_AirTicketReservations.Count != 0)
  4275. {
  4276. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4277. if (FlightsCode.Length != 0)
  4278. {
  4279. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4280. if (_AirCompany != null)
  4281. {
  4282. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4283. }
  4284. else
  4285. {
  4286. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4287. }
  4288. }
  4289. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4290. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4291. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4292. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4293. string name = "";
  4294. foreach (string clientName in nameArray)
  4295. {
  4296. if (!name.Contains(clientName))
  4297. {
  4298. name += clientName + ",";
  4299. }
  4300. }
  4301. if (!string.IsNullOrWhiteSpace(name))
  4302. {
  4303. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4304. }
  4305. else
  4306. {
  4307. table.Range.Bookmarks["ClientName"].Text = "--";
  4308. }
  4309. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4310. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4311. table.Range.Bookmarks["JointTicket"].Text = "--";
  4312. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4313. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4314. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4315. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4316. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4317. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4318. }
  4319. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4320. //保存合并后的文档
  4321. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4322. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4323. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4324. return Ok(JsonView(true, "成功!", rst));
  4325. }
  4326. else
  4327. {
  4328. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4329. DocumentBuilder builder = new DocumentBuilder(doc);
  4330. int tableIndex = 0;//表格索引
  4331. //得到文档中的第一个表格
  4332. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4333. List<string> texts = new List<string>();
  4334. foreach (var item in _AirTicketReservations)
  4335. {
  4336. string[] FlightsCode = item.FlightsCode.Split('/');
  4337. if (FlightsCode.Length != 0)
  4338. {
  4339. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4340. if (_AirCompany != null)
  4341. {
  4342. if (!transDic.ContainsKey(_AirCompany.CnName))
  4343. {
  4344. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4345. }
  4346. }
  4347. else
  4348. {
  4349. if (!transDic.ContainsKey("--"))
  4350. {
  4351. transDic.Add("--", "--");
  4352. }
  4353. }
  4354. }
  4355. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4356. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4357. string name = "";
  4358. foreach (string clientName in nameArray)
  4359. {
  4360. name += clientName + ",";
  4361. }
  4362. if (!texts.Contains(name))
  4363. {
  4364. texts.Add(name);
  4365. }
  4366. List<AirInfo> airs = new List<AirInfo>();
  4367. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4368. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4369. for (int i = 0; i < FlightsCode.Length; i++)
  4370. {
  4371. AirInfo air = new AirInfo();
  4372. string[] tempstr = DayArray[i]
  4373. .Replace("\r\n", string.Empty)
  4374. .Replace("\\r\\n", string.Empty)
  4375. .TrimStart().TrimEnd()
  4376. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4377. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4378. if (star_Three != null)
  4379. {
  4380. if (!transDic.ContainsKey(star_Three.AirPort))
  4381. {
  4382. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4383. }
  4384. }
  4385. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4386. if (End_Three != null)
  4387. {
  4388. if (!transDic.ContainsKey(End_Three.AirPort))
  4389. {
  4390. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4391. }
  4392. }
  4393. if (!texts.Contains(item.CTypeName))
  4394. {
  4395. texts.Add(item.CTypeName);
  4396. }
  4397. }
  4398. }
  4399. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4400. if (transData.Count > 0)
  4401. {
  4402. foreach (TranslateResult item in transData)
  4403. {
  4404. if (!transDic.ContainsKey(item.Query))
  4405. {
  4406. transDic.Add(item.Query, item.Translation);
  4407. }
  4408. }
  4409. }
  4410. foreach (var item in _AirTicketReservations)
  4411. {
  4412. #region 处理固定数据
  4413. string[] FlightsCode = item.FlightsCode.Split('/');
  4414. if (FlightsCode.Length != 0)
  4415. {
  4416. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4417. if (_AirCompany != null)
  4418. {
  4419. string str = "--";
  4420. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4421. if (!string.IsNullOrEmpty(translateResult))
  4422. {
  4423. str = translateResult;
  4424. str = _airTicketResRep.Processing(str);
  4425. }
  4426. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4427. }
  4428. else
  4429. {
  4430. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4431. }
  4432. }
  4433. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4434. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4435. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4436. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4437. string names = "";
  4438. foreach (string clientName in nameArray)
  4439. {
  4440. names += clientName + ",";
  4441. }
  4442. if (!string.IsNullOrWhiteSpace(names))
  4443. {
  4444. string str = "--";
  4445. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4446. if (!string.IsNullOrEmpty(translateResult))
  4447. {
  4448. str = translateResult;
  4449. str = _airTicketResRep.Processing(str);
  4450. }
  4451. table.Range.Bookmarks["ClientName"].Text = str;
  4452. }
  4453. else
  4454. {
  4455. table.Range.Bookmarks["ClientName"].Text = "--";
  4456. }
  4457. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4458. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4459. table.Range.Bookmarks["JointTicket"].Text = "--";
  4460. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4461. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4462. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4463. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4464. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4465. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4466. #endregion
  4467. #region 循环数据处理
  4468. List<AirInfo> airs = new List<AirInfo>();
  4469. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4470. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4471. for (int i = 0; i < FlightsCode.Length; i++)
  4472. {
  4473. AirInfo air = new AirInfo();
  4474. string[] tempstr = DayArray[i]
  4475. .Replace("\r\n", string.Empty)
  4476. .Replace("\\r\\n", string.Empty)
  4477. .TrimStart().TrimEnd()
  4478. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4479. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4480. string starCity = "";
  4481. if (star_Three != null)
  4482. {
  4483. string str2 = "--";
  4484. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4485. if (!string.IsNullOrEmpty(translateResult2))
  4486. {
  4487. str2 = translateResult2;
  4488. str2 = _airTicketResRep.Processing(str2);
  4489. }
  4490. starCity = str2;
  4491. }
  4492. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4493. string EndCity = "";
  4494. if (End_Three != null)
  4495. {
  4496. string str1 = "--";
  4497. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4498. if (!string.IsNullOrEmpty(translateResult1))
  4499. {
  4500. str1 = translateResult1;
  4501. str1 = _airTicketResRep.Processing(str1);
  4502. }
  4503. EndCity = str1;
  4504. }
  4505. air.Destination = starCity + "/" + EndCity;
  4506. air.Flight = FlightsCode[i];
  4507. string str = "--";
  4508. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4509. if (!string.IsNullOrEmpty(translateResult))
  4510. {
  4511. str = translateResult;
  4512. str = _airTicketResRep.Processing(str);
  4513. }
  4514. air.SeatingClass = str;
  4515. string dateTime = tempstr[2];
  4516. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4517. air.FlightDate = DateTemp;
  4518. air.DepartureTime = tempstr[5];
  4519. air.LandingTime = tempstr[6];
  4520. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4521. air.TicketStatus = "--";
  4522. air.Luggage = "--";
  4523. air.DepartureTerminal = "--";
  4524. air.LandingTerminal = "--";
  4525. airs.Add(air);
  4526. }
  4527. int row = 13;
  4528. for (int i = 0; i < airs.Count; i++)
  4529. {
  4530. if (airs.Count > 2)
  4531. {
  4532. for (int j = 0; j < airs.Count - 2; j++)
  4533. {
  4534. var CopyRow = table.Rows[12].Clone(true);
  4535. table.Rows.Add(CopyRow);
  4536. }
  4537. }
  4538. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4539. int index = 0;
  4540. foreach (PropertyInfo property in properties)
  4541. {
  4542. string value = property.GetValue(airs[i]).ToString();
  4543. Cell ishcel0 = table.Rows[row].Cells[index];
  4544. Paragraph p = new Paragraph(doc);
  4545. string s = value;
  4546. p.AppendChild(new Run(doc, s));
  4547. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4548. ishcel0.AppendChild(p);
  4549. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4550. //ishcel0.CellFormat.VerticalAlignment=
  4551. index++;
  4552. }
  4553. row++;
  4554. }
  4555. #endregion
  4556. Paragraph lastParagraph = new Paragraph(doc);
  4557. //第一个表格末尾加段落
  4558. table.ParentNode.InsertAfter(lastParagraph, table);
  4559. //复制第一个表格
  4560. Table cloneTable = (Table)table.Clone(true);
  4561. //在文档末尾段落后面加入复制的表格
  4562. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4563. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4564. {
  4565. int rownewsIndex = 13;
  4566. for (int i = 0; i < 2; i++)
  4567. {
  4568. var CopyRow = table.Rows[12].Clone(true);
  4569. table.Rows.RemoveAt(13);
  4570. table.Rows.Add(CopyRow);
  4571. rownewsIndex++;
  4572. }
  4573. }
  4574. else
  4575. {
  4576. table.Rows.RemoveAt(12);
  4577. }
  4578. cloneTable.Rows.RemoveAt(12);
  4579. }
  4580. if (_AirTicketReservations.Count != 0)
  4581. {
  4582. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4583. if (FlightsCode.Length != 0)
  4584. {
  4585. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4586. if (_AirCompany != null)
  4587. {
  4588. string str = "--";
  4589. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4590. if (!string.IsNullOrEmpty(translateResult))
  4591. {
  4592. str = translateResult;
  4593. str = _airTicketResRep.Processing(str);
  4594. }
  4595. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4596. }
  4597. else
  4598. {
  4599. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4600. }
  4601. }
  4602. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4603. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4604. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4605. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4606. string names = "";
  4607. foreach (string clientName in nameArray)
  4608. {
  4609. names += clientName + ",";
  4610. }
  4611. if (!string.IsNullOrWhiteSpace(names))
  4612. {
  4613. string str = "--";
  4614. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4615. if (!string.IsNullOrEmpty(translateResult))
  4616. {
  4617. str = translateResult;
  4618. str = _airTicketResRep.Processing(str);
  4619. }
  4620. table.Range.Bookmarks["ClientName"].Text = str;
  4621. }
  4622. else
  4623. {
  4624. table.Range.Bookmarks["ClientName"].Text = "--";
  4625. }
  4626. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4627. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4628. table.Range.Bookmarks["JointTicket"].Text = "--";
  4629. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4630. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4631. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4632. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4633. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4634. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4635. }
  4636. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4637. //保存合并后的文档
  4638. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4639. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4640. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4641. return Ok(JsonView(true, "成功!", rst));
  4642. }
  4643. }
  4644. }
  4645. catch (Exception ex)
  4646. {
  4647. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4648. throw;
  4649. }
  4650. }
  4651. #endregion
  4652. #region 团组增减款项 --> 其他款项
  4653. /// <summary>
  4654. /// 团组增减款项下拉框绑定
  4655. /// </summary>
  4656. /// <param name="dto"></param>
  4657. /// <returns></returns>
  4658. [HttpPost]
  4659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4660. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4661. {
  4662. #region 参数验证
  4663. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4664. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4665. #endregion
  4666. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4667. }
  4668. /// <summary>
  4669. /// 根据团组Id查询团组增减款项
  4670. /// </summary>
  4671. /// <param name="dto"></param>
  4672. /// <returns></returns>
  4673. [HttpPost]
  4674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4675. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4676. {
  4677. #region 参数验证
  4678. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4679. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4680. #endregion
  4681. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4682. }
  4683. /// <summary>
  4684. /// 团组增减款项操作(Status:1.新增,2.修改)
  4685. /// </summary>
  4686. /// <param name="dto"></param>
  4687. /// <returns></returns>
  4688. [HttpPost]
  4689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4690. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4691. {
  4692. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4693. if (groupData.Code != 200)
  4694. {
  4695. return Ok(JsonView(false, groupData.Msg));
  4696. }
  4697. #region 应用推送
  4698. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4699. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4700. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4701. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4702. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4703. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4704. //自动审核
  4705. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4706. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4707. //2024-10-21 新增LZ UID
  4708. var userIds = new List<int>() { 21 };
  4709. string title = $"系统通知";
  4710. string content = "";
  4711. var diId = dto.DiId;
  4712. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4713. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4714. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4715. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4716. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4717. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4718. #endregion
  4719. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4720. }
  4721. /// <summary>
  4722. /// 团组增减款项操作 删除
  4723. /// </summary>
  4724. /// <param name="dto"></param>
  4725. /// <returns></returns>
  4726. [HttpPost]
  4727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4728. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4729. {
  4730. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4731. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4732. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4733. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4734. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4735. }
  4736. /// <summary>
  4737. /// 根据团组增减款项Id查询
  4738. /// </summary>
  4739. /// <param name="dto"></param>
  4740. /// <returns></returns>
  4741. [HttpPost]
  4742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4743. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4744. {
  4745. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4746. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4747. }
  4748. /// <summary>
  4749. /// 查询供应商名称
  4750. /// </summary>
  4751. /// <param name="dto"></param>
  4752. /// <returns></returns>
  4753. [HttpPost]
  4754. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4755. {
  4756. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4757. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4758. ?? new List<Grp_DecreasePayments>();
  4759. dbResult = dbResult.Distinct(new
  4760. ProductComparer()).ToList();
  4761. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4762. {
  4763. x.Id,
  4764. x.SupplierAddress,
  4765. x.SupplierArea,
  4766. x.SupplierContact,
  4767. x.SupplierContactNumber,
  4768. x.SupplierEmail,
  4769. x.SupplierName,
  4770. x.SupplierSocialAccount,
  4771. x.SupplierTypeId,
  4772. }).ToList());
  4773. return Ok(jw);
  4774. }
  4775. /// <summary>
  4776. /// 团组增减款项 OTA匹配
  4777. /// </summary>
  4778. /// <param name="file"></param>
  4779. /// <returns></returns>
  4780. [HttpPost]
  4781. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4782. {
  4783. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4784. string fileName = file.FileName;
  4785. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4786. {
  4787. return Ok(JsonView(false, "请上传Excel文件!"));
  4788. }
  4789. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4790. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4791. if (!Directory.Exists(path))
  4792. {
  4793. Directory.CreateDirectory(path);
  4794. }
  4795. var filePath = @$"{path}/{fileName}";
  4796. //保存文件
  4797. using (FileStream fs = System.IO.File.Create(filePath))
  4798. {
  4799. file.CopyTo(fs);
  4800. fs.Flush();
  4801. }
  4802. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4803. //读取ExcelFile
  4804. DataTable dt = ConvertExcelToDataTable(filePath);
  4805. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4806. dt.TableName = "TB";
  4807. //修改table列名
  4808. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4809. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4810. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4811. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4812. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4813. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4814. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4815. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4816. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4817. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4818. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4819. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4820. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4821. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4822. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4823. var otaOrderNos = new List<string>();
  4824. foreach (DataRow item in dt.Rows)
  4825. {
  4826. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4827. }
  4828. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4829. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4830. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4831. .Select((dp, di) => new
  4832. {
  4833. dp.PriceName,
  4834. dp.OTAOrderNo,
  4835. dp.FeeTotal,
  4836. di.TeamName,
  4837. })
  4838. .ToListAsync();
  4839. foreach (DataRow item in dt.Rows)
  4840. {
  4841. var otaOrderNo = item["OTAOrderNo"].ToString();
  4842. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4843. if (oaData == null) continue;
  4844. item["GroupName"] = oaData.TeamName;
  4845. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4846. }
  4847. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4848. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4849. List<DataTable> datas = new List<DataTable>();
  4850. datas.Add(dt);
  4851. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4852. return Ok(JsonView(true, "操作成功", new { url = url }));
  4853. }
  4854. #region
  4855. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4856. {
  4857. // 创建Workbook对象
  4858. Workbook workbook = new Workbook(excelFilePath);
  4859. // 获取第一个工作表
  4860. Worksheet worksheet = workbook.Worksheets[0];
  4861. // 将工作表转换为DataTable
  4862. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4863. return dataTable;
  4864. }
  4865. #endregion
  4866. /// <summary>
  4867. /// 世运会数据
  4868. /// </summary>
  4869. /// <returns></returns>
  4870. [HttpGet]
  4871. public IActionResult WorldGamesData()
  4872. {
  4873. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  4874. var groupMenu = setData.GroupBy(x => x.T0);
  4875. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4876. foreach (var item in groupMenu)
  4877. {
  4878. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4879. {
  4880. Data = new SetDataView
  4881. {
  4882. Name = item.Key
  4883. },
  4884. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  4885. });
  4886. }
  4887. return Ok(JsonView(true, "success", resultArr));
  4888. }
  4889. #endregion
  4890. #region 文件上传、删除
  4891. /// <summary>
  4892. /// region 文件上传 可以带参数
  4893. /// </summary>
  4894. /// <param name="file"></param>
  4895. /// <returns></returns>
  4896. [HttpPost]
  4897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4898. public async Task<IActionResult> UploadProject(IFormFile file)
  4899. {
  4900. //var TypeName = Request.Headers["TypeName"].ToString();
  4901. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4902. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4903. ////文件名称
  4904. //string projectFileName = file.FileName;
  4905. ////上传的文件的路径
  4906. //string filePath = $"{fileDir}/{projectFileName}";
  4907. //if (TypeName == "A")//A代表团组增减款项
  4908. //{
  4909. // filePath = fileDir + $@"\团组增减款项相关文件";
  4910. // if (!Directory.Exists(filePath))
  4911. // {
  4912. // Directory.CreateDirectory(filePath);
  4913. // }
  4914. // //上传的文件的路径
  4915. // filePath += $@"\{projectFileName}";
  4916. //}
  4917. //else if (TypeName == "B")//B代表商邀相关文件
  4918. //{
  4919. // //上传的文件的路径
  4920. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4921. // if (!Directory.Exists(filePath))
  4922. // {
  4923. // Directory.CreateDirectory(filePath);
  4924. // }
  4925. // //上传的文件的路径
  4926. // filePath = $@"\{projectFileName}";
  4927. //}
  4928. //try
  4929. //{
  4930. // using (FileStream fs = System.IO.File.Create(filePath))
  4931. // {
  4932. // file.CopyTo(fs);
  4933. // fs.Flush();
  4934. // }
  4935. //}
  4936. //catch (Exception ex)
  4937. //{
  4938. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4939. //}
  4940. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4941. try
  4942. {
  4943. var TypeName = Request.Headers["TypeName"].ToString();
  4944. if (file != null)
  4945. {
  4946. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4947. //文件名称
  4948. string projectFileName = file.FileName;
  4949. //上传的文件的路径
  4950. string filePath = $"{fileDir}/{projectFileName}";
  4951. if (TypeName == "A")//A代表团组增减款项
  4952. {
  4953. if (!Directory.Exists(fileDir))
  4954. {
  4955. Directory.CreateDirectory(fileDir);
  4956. }
  4957. //上传的文件的路径
  4958. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4959. }
  4960. else if (TypeName == "B")//B代表商邀相关文件
  4961. {
  4962. if (!Directory.Exists(fileDir))
  4963. {
  4964. Directory.CreateDirectory(fileDir);
  4965. }
  4966. //上传的文件的路径
  4967. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4968. }
  4969. using (FileStream fs = System.IO.File.Create(filePath))
  4970. {
  4971. file.CopyTo(fs);
  4972. fs.Flush();
  4973. }
  4974. return Ok(JsonView(true, "上传成功!", projectFileName));
  4975. }
  4976. else
  4977. {
  4978. return Ok(JsonView(false, "上传失败!"));
  4979. }
  4980. }
  4981. catch (Exception ex)
  4982. {
  4983. return Ok(JsonView(false, "程序错误!"));
  4984. }
  4985. }
  4986. /// <summary>
  4987. /// 删除指定文件
  4988. /// </summary>
  4989. /// <param name="dto"></param>
  4990. /// <returns></returns>
  4991. [HttpPost]
  4992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4993. public async Task<IActionResult> DelFile(DelFileDto dto)
  4994. {
  4995. try
  4996. {
  4997. var TypeName = Request.Headers["TypeName"].ToString();
  4998. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4999. string filePath = "";
  5000. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5001. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  5002. int id = 0;
  5003. if (TypeName == "A")
  5004. {
  5005. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5006. // 删除该文件
  5007. System.IO.File.Delete(filePath);
  5008. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5009. .Where(a => a.Id == dto.Id)
  5010. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5011. .ExecuteCommandAsync();
  5012. }
  5013. else if (TypeName == "B")
  5014. {
  5015. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5016. // 删除该文件
  5017. System.IO.File.Delete(filePath);
  5018. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5019. if (info != null)
  5020. {
  5021. string[] files = new string[] { };
  5022. if (!string.IsNullOrEmpty(info.Attachment))
  5023. {
  5024. try
  5025. {
  5026. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5027. }
  5028. catch (Exception)
  5029. {
  5030. files = new List<string>() { info.Attachment }.ToArray();
  5031. }
  5032. }
  5033. if (files.Length > 0)
  5034. {
  5035. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5036. string filePath2 = string.Empty;
  5037. if (files1.Length > 0)
  5038. {
  5039. filePath2 = JsonConvert.SerializeObject(files1);
  5040. }
  5041. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5042. .Where(a => a.Id == dto.Id)
  5043. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5044. .ExecuteCommandAsync();
  5045. }
  5046. }
  5047. }
  5048. if (id != 0)
  5049. {
  5050. return Ok(JsonView(true, "成功!"));
  5051. }
  5052. else
  5053. {
  5054. return Ok(JsonView(false, "失败!"));
  5055. }
  5056. }
  5057. catch (Exception ex)
  5058. {
  5059. return Ok(JsonView(false, "程序错误!"));
  5060. throw;
  5061. }
  5062. }
  5063. /// <summary>
  5064. /// 文件上传多个文件 可以带参数
  5065. /// </summary>
  5066. /// <param name="files"></param>
  5067. /// <returns></returns>
  5068. [HttpPost]
  5069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5070. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5071. {
  5072. try
  5073. {
  5074. var TypeName = Request.Headers["TypeName"].ToString();
  5075. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5076. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5077. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5078. var filePahts = new List<string>();
  5079. foreach (var file in files)
  5080. {
  5081. //文件名称
  5082. string projectFileName = file.FileName;
  5083. //上传的文件的路径
  5084. string filePath = $"{fileDir}/{projectFileName}";
  5085. if (TypeName == "A")//A代表团组增减款项
  5086. {
  5087. if (!Directory.Exists(fileDir))
  5088. {
  5089. Directory.CreateDirectory(fileDir);
  5090. }
  5091. //上传的文件的路径
  5092. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5093. }
  5094. else if (TypeName == "B")//B代表商邀相关文件
  5095. {
  5096. if (!Directory.Exists(fileDir))
  5097. {
  5098. Directory.CreateDirectory(fileDir);
  5099. }
  5100. //上传的文件的路径
  5101. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5102. }
  5103. using (FileStream fs = System.IO.File.Create(filePath))
  5104. {
  5105. file.CopyTo(fs);
  5106. fs.Flush();
  5107. }
  5108. filePahts.Add(projectFileName);
  5109. }
  5110. return Ok(JsonView(true, "上传成功!", filePahts));
  5111. }
  5112. catch (Exception ex)
  5113. {
  5114. return Ok(JsonView(false, "程序错误!"));
  5115. }
  5116. }
  5117. #endregion
  5118. #region 商邀费用录入
  5119. /// <summary>
  5120. /// 根据团组Id查询商邀费用列表
  5121. /// </summary>
  5122. /// <param name="dto"></param>
  5123. /// <returns></returns>
  5124. [HttpPost]
  5125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5126. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5127. {
  5128. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5129. if (groupData.Code != 0)
  5130. {
  5131. return Ok(JsonView(false, groupData.Msg));
  5132. }
  5133. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5134. }
  5135. /// <summary>
  5136. /// 商邀费用列表
  5137. /// 下载文件
  5138. /// </summary>
  5139. /// <param name="id"></param>
  5140. /// <returns></returns>
  5141. [HttpGet("{id}")]
  5142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5143. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5144. {
  5145. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5146. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5147. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5148. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5149. var filePaths = new List<string>();
  5150. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5151. try
  5152. {
  5153. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5154. }
  5155. catch (Exception ex)
  5156. {
  5157. filePaths.Add(info.Attachment);
  5158. }
  5159. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5160. for (int i = 0; i < filePaths.Count; i++)
  5161. {
  5162. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5163. }
  5164. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5165. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5166. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5167. {
  5168. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5169. {
  5170. foreach (string filePath in filePaths)
  5171. {
  5172. if (System.IO.File.Exists(filePath))
  5173. {
  5174. // 获取文件名
  5175. string fileName = Path.GetFileName(filePath);
  5176. // 将文件添加到ZIP归档中
  5177. zipArchive.CreateEntryFromFile(filePath, fileName);
  5178. }
  5179. }
  5180. }
  5181. }
  5182. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5183. }
  5184. /// <summary>
  5185. /// 商邀费用 Info Page 基础数据源
  5186. /// </summary>
  5187. /// <returns></returns>
  5188. [HttpPost]
  5189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5190. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5191. {
  5192. try
  5193. {
  5194. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  5195. if (groupData.Code != 0)
  5196. {
  5197. return Ok(JsonView(false, groupData.Msg));
  5198. }
  5199. return Ok(JsonView(true, "操作成功", groupData.Data));
  5200. }
  5201. catch (Exception ex)
  5202. {
  5203. return Ok(JsonView(false, ex.Message));
  5204. throw;
  5205. }
  5206. }
  5207. /// <summary>
  5208. /// 根据商邀费用ID查询C表和商邀费用数据
  5209. /// </summary>
  5210. /// <param name="dto"></param>
  5211. /// <returns></returns>
  5212. [HttpPost]
  5213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5214. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5215. {
  5216. try
  5217. {
  5218. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5219. if (groupData.Code != 0)
  5220. {
  5221. return Ok(JsonView(false, groupData.Msg));
  5222. }
  5223. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5224. }
  5225. catch (Exception ex)
  5226. {
  5227. return Ok(JsonView(false, ex.Message));
  5228. throw;
  5229. }
  5230. }
  5231. /// <summary>
  5232. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5233. /// </summary>
  5234. /// <param name="dto"></param>
  5235. /// <returns></returns>
  5236. [HttpPost]
  5237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5238. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5239. {
  5240. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5241. if (groupData.Code != 0)
  5242. {
  5243. return Ok(JsonView(false, groupData.Msg));
  5244. }
  5245. #region 应用推送
  5246. try
  5247. {
  5248. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5249. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5250. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5251. //2024-10-21 新增LZ UID
  5252. var userIds = new List<int>() { 21 };
  5253. string title = $"系统通知";
  5254. string content = "";
  5255. var diId = dto.DiId;
  5256. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5257. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5258. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5259. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5260. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5261. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5262. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5263. }
  5264. catch (Exception ex)
  5265. {
  5266. }
  5267. #endregion
  5268. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5269. }
  5270. /// <summary>
  5271. /// 商邀删除
  5272. /// </summary>
  5273. /// <param name="dto"></param>
  5274. /// <returns></returns>
  5275. [HttpPost]
  5276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5277. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5278. {
  5279. try
  5280. {
  5281. _sqlSugar.BeginTran();
  5282. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5283. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5284. {
  5285. IsDel = 1,
  5286. DeleteUserId = dto.DeleteUserId,
  5287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5288. })
  5289. .Where(it => it.Id == dto.Id)
  5290. .ExecuteCommand();
  5291. if (res1 > 0)
  5292. {
  5293. int _diId = 0;
  5294. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5295. if (_ioaInfo != null)
  5296. {
  5297. _diId = _ioaInfo.DiId;
  5298. }
  5299. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5300. .SetColumns(a => new Grp_CreditCardPayment()
  5301. {
  5302. IsDel = 1,
  5303. DeleteUserId = dto.DeleteUserId,
  5304. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5305. })
  5306. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5307. .ExecuteCommand();
  5308. if (res2 > 0)
  5309. {
  5310. _sqlSugar.CommitTran();
  5311. return Ok(JsonView(true, "删除成功!"));
  5312. }
  5313. }
  5314. _sqlSugar.RollbackTran();
  5315. return Ok(JsonView(false, "删除失败"));
  5316. }
  5317. catch (Exception ex)
  5318. {
  5319. _sqlSugar.RollbackTran();
  5320. return Ok(JsonView(false, ex.Message));
  5321. }
  5322. }
  5323. #endregion
  5324. #region 票据上传
  5325. /// <summary>
  5326. /// 团组模块文件上传
  5327. /// </summary>
  5328. /// <param name="dto"></param>
  5329. /// <returns></returns>
  5330. [HttpPost]
  5331. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5332. {
  5333. var jw = JsonView(false);
  5334. long M = 1024 * 1024;
  5335. if (dto.Files == null || dto.Files.Count == 0)
  5336. {
  5337. jw.Msg = "无文件信息!";
  5338. return Ok(jw);
  5339. }
  5340. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5341. {
  5342. jw.Msg = "文件大小超过20M!";
  5343. return Ok(jw);
  5344. }
  5345. //var nameSp = dto.File.FileName.Split(".");
  5346. //if (nameSp.Length < 2)
  5347. //{
  5348. // jw.Msg = "拓展名称有误!";
  5349. // return Ok(jw);
  5350. //}
  5351. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5352. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5353. //{
  5354. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5355. // return Ok(jw);
  5356. //}
  5357. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5358. if (Ctable == null)
  5359. {
  5360. jw.Msg = "Ctable指向有误!";
  5361. return Ok(jw);
  5362. }
  5363. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5364. if (groupInfo == null)
  5365. {
  5366. jw.Msg = "团组信息不存在!";
  5367. return Ok(jw);
  5368. }
  5369. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5370. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5371. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5372. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5373. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5374. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5375. try
  5376. {
  5377. if (!Directory.Exists(fileBase))
  5378. {
  5379. Directory.CreateDirectory(fileBase);
  5380. }
  5381. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5382. foreach (var fileStream in dto.Files)
  5383. {
  5384. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5385. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5386. {
  5387. Cid = dto.Cid,
  5388. CreateTime = DateTime.Now,
  5389. CreateUserId = dto.Userid,
  5390. Ctable = dto.Ctable,
  5391. Diid = dto.Diid,
  5392. IsDel = 0,
  5393. FilePath = saveFilePath,
  5394. FileName = fileStream.FileName
  5395. };
  5396. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5397. {
  5398. fileStream.CopyTo(fs);
  5399. fs.Flush();
  5400. }
  5401. saveArr.Add(file);
  5402. }
  5403. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5404. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5405. jw = JsonView(true, "保存成功!", new
  5406. {
  5407. count = addResult,
  5408. filesName = saveArr.Select(x => x.FileName)
  5409. });
  5410. }
  5411. catch (Exception ex)
  5412. {
  5413. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5414. {
  5415. count = 0,
  5416. filesName = new string[0],
  5417. });
  5418. }
  5419. return Ok(jw);
  5420. }
  5421. /// <summary>
  5422. /// 查询各模块已保存文件
  5423. /// </summary>
  5424. /// <param name="dto"></param>
  5425. /// <returns></returns>
  5426. [HttpPost]
  5427. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5428. {
  5429. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5430. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5431. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5432. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5433. {
  5434. expression = Expressionable.Create<Grp_GroupModelFile>()
  5435. .And(x => visaIds.Contains(x.CreateUserId));
  5436. }
  5437. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5438. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5439. .Where(expression.ToExpression())
  5440. .ToList();
  5441. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5442. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5443. {
  5444. x.FileName,
  5445. x.Id,
  5446. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5447. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5448. })));
  5449. }
  5450. /// <summary>
  5451. /// 下载该团组下的所有文件
  5452. /// </summary>
  5453. /// <param name="dto"></param>
  5454. /// <returns></returns>
  5455. [HttpPost]
  5456. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5457. {
  5458. var jw = JsonView(false);
  5459. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5460. if (groupInfo == null)
  5461. {
  5462. jw.Msg = "团组信息不存在!";
  5463. return Ok(jw);
  5464. }
  5465. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5466. var isModule = Convert.ToBoolean(dto.isModule);
  5467. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5468. IOOperatorHelper io = new IOOperatorHelper();
  5469. if (isModule)
  5470. {
  5471. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5472. foreach (var moduleArr in moduleGroup)
  5473. {
  5474. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5475. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5476. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5477. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5478. foreach (var item in moduleArr)
  5479. {
  5480. if (System.IO.File.Exists(item.FilePath))
  5481. {
  5482. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5483. {
  5484. byte[] bytes = new byte[fileStream.Length];
  5485. fileStream.Read(bytes, 0, bytes.Length);
  5486. fileStream.Close();
  5487. Stream stream = new MemoryStream(bytes);
  5488. chiZips.Add(item.FileName, stream);
  5489. }
  5490. }
  5491. }
  5492. if (chiZips.Count > 0)
  5493. {
  5494. var byts = io.ConvertZipStream(chiZips);
  5495. Stream stream = new MemoryStream(byts);
  5496. Zips.Add(key.Name + "_.zip", stream);
  5497. }
  5498. }
  5499. }
  5500. else
  5501. {
  5502. foreach (var item in dbQuery)
  5503. {
  5504. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5505. {
  5506. byte[] bytes = new byte[fileStream.Length];
  5507. fileStream.Read(bytes, 0, bytes.Length);
  5508. fileStream.Close();
  5509. Stream stream = new MemoryStream(bytes);
  5510. while (Zips.Keys.Contains(item.FileName))
  5511. {
  5512. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5513. }
  5514. Zips.Add(item.FileName, stream);
  5515. }
  5516. }
  5517. }
  5518. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5519. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5520. if (Zips.Count > 0)
  5521. {
  5522. var byts = io.ConvertZipStream(Zips);
  5523. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5524. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5525. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5526. }
  5527. else
  5528. {
  5529. jw.Msg = "暂无生成文件!";
  5530. }
  5531. return Ok(jw);
  5532. }
  5533. /// <summary>
  5534. /// 下载该团组下此模块的所有文件
  5535. /// </summary>
  5536. /// <param name="dto"></param>
  5537. /// <returns></returns>
  5538. [HttpPost]
  5539. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5540. {
  5541. var jw = JsonView(false);
  5542. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5543. if (groupInfo == null)
  5544. {
  5545. jw.Msg = "团组信息不存在!";
  5546. return Ok(jw);
  5547. }
  5548. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5549. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5550. && x.IsDel == 0);
  5551. if (key == null)
  5552. {
  5553. jw.Msg = "Ctable指向错误!";
  5554. return Ok(jw);
  5555. }
  5556. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5557. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5558. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5559. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5560. IOOperatorHelper io = new IOOperatorHelper();
  5561. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5562. foreach (var item in dbQuery)
  5563. {
  5564. if (System.IO.File.Exists(item.FilePath))
  5565. {
  5566. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5567. {
  5568. byte[] bytes = new byte[fileStream.Length];
  5569. fileStream.Read(bytes, 0, bytes.Length);
  5570. fileStream.Close();
  5571. Stream stream = new MemoryStream(bytes);
  5572. while (Zips.Keys.Contains(item.FileName))
  5573. {
  5574. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5575. }
  5576. Zips.Add(item.FileName, stream);
  5577. }
  5578. }
  5579. }
  5580. if (Zips.Count > 0)
  5581. {
  5582. var byts = io.ConvertZipStream(Zips);
  5583. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5584. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5585. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5586. }
  5587. else
  5588. {
  5589. jw.Msg = "暂无生成文件!";
  5590. }
  5591. return Ok(jw);
  5592. }
  5593. /// <summary>
  5594. /// 删除该团组下的指定文件
  5595. /// </summary>
  5596. /// <param name="dto"></param>
  5597. /// <returns></returns>
  5598. [HttpPost]
  5599. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5600. {
  5601. var jw = JsonView(false);
  5602. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5603. if (sing == null)
  5604. {
  5605. jw.Msg = "暂无";
  5606. return Ok(jw);
  5607. }
  5608. if (System.IO.File.Exists(sing.FilePath))
  5609. {
  5610. try
  5611. {
  5612. System.IO.File.Delete(sing.FilePath);
  5613. }
  5614. catch (Exception ex)
  5615. {
  5616. jw.Msg = "删除失败!" + ex.Message;
  5617. return Ok(jw);
  5618. }
  5619. }
  5620. sing.IsDel = 1;
  5621. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5622. sing.DeleteUserId = dto.UserId;
  5623. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5624. jw = JsonView(true, "删除成功!");
  5625. return Ok(jw);
  5626. }
  5627. #endregion
  5628. #region 共享文件上传
  5629. /// <summary>
  5630. /// 共享文件数据初始化
  5631. /// </summary>
  5632. /// <returns></returns>
  5633. [HttpGet]
  5634. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5635. {
  5636. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5637. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5638. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5639. .Select(x => x.Id)
  5640. .ToList()
  5641. .Contains(userid);
  5642. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5643. .Where(x => x.STid == 111 && x.IsDel == 0)
  5644. .Select(x => new
  5645. {
  5646. x.Name,
  5647. x.Id,
  5648. }).ToList();
  5649. if (isMarketingDepartment)
  5650. {
  5651. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5652. }
  5653. if (portType == 1)
  5654. {
  5655. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5656. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5657. .Where(x => x.IsDel == 0)
  5658. .OrderByDescending(x => x.VisitDate)
  5659. .Select(x => new
  5660. {
  5661. x.TeamName,
  5662. x.Id,
  5663. x.CityId,
  5664. })
  5665. .ToList()
  5666. .Select(x =>
  5667. {
  5668. var provinceId = x.CityId;
  5669. var isDefualtVal = true;
  5670. if (provinceId > 0)
  5671. {
  5672. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5673. if (parentId != null)
  5674. {
  5675. isDefualtVal = false;
  5676. provinceId = (int)parentId;
  5677. }
  5678. }
  5679. if (isDefualtVal)
  5680. {
  5681. provinceId = 122; //默认四川
  5682. }
  5683. return new
  5684. {
  5685. x.TeamName,
  5686. x.Id,
  5687. provinceId,
  5688. };
  5689. })
  5690. .ToList();
  5691. return Ok(JsonView(true, "SUCCESS!", new
  5692. {
  5693. dropDownType,
  5694. dropDownGroupList,
  5695. isMarketingDepartment
  5696. }));
  5697. }
  5698. else if (portType == 2 || portType == 3)
  5699. {
  5700. return Ok(JsonView(true, "SUCCESS!", new
  5701. {
  5702. dropDownType,
  5703. isMarketingDepartment
  5704. }));
  5705. }
  5706. else
  5707. {
  5708. return Ok(JsonView(false, "portType有误!"));
  5709. }
  5710. }
  5711. /// <summary>
  5712. /// 共享文件上传
  5713. /// </summary>
  5714. /// <param name="dto"></param>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5718. {
  5719. var isGroup = new List<int> { 1412 };
  5720. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5721. {
  5722. return Ok(JsonView(false, "该文件需要关联团组!"));
  5723. }
  5724. if (dto.Files == null || dto.Files.Count == 0)
  5725. {
  5726. return Ok(JsonView(false, "无文件信息!"));
  5727. }
  5728. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5729. {
  5730. return Ok(JsonView(false, "文件大小超过20M!"));
  5731. }
  5732. if (dto.Userid < 1)
  5733. {
  5734. return Ok(JsonView(false, "请传入有效的Userid!"));
  5735. }
  5736. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5737. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5738. .Select((u, j) => new
  5739. {
  5740. u.CnName,
  5741. UserId = u.Id,
  5742. j.JobName,
  5743. })
  5744. .First();
  5745. if (jobInfo == null)
  5746. {
  5747. return Ok(JsonView(false, "请传入有效的Userid!"));
  5748. }
  5749. List<string> commonFileExtensions = new List<string>
  5750. {
  5751. // 文本文件
  5752. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5753. // 图片文件
  5754. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5755. // 视频文件
  5756. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5757. // 音频文件
  5758. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5759. // 压缩文件
  5760. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5761. // 数据文件
  5762. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5763. };
  5764. try
  5765. {
  5766. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5767. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5768. commonFileExtensions.AddRange(settingExtend);
  5769. }
  5770. catch (Exception)
  5771. { }
  5772. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5773. if (setdata == null)
  5774. {
  5775. return Ok(JsonView(false, "请传入有效的FileType!"));
  5776. }
  5777. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5778. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5779. if (!Directory.Exists(winPath))
  5780. {
  5781. Directory.CreateDirectory(winPath);
  5782. }
  5783. foreach (var item in dto.Files)
  5784. {
  5785. var houzui = Path.GetExtension(item.FileName);
  5786. if (!commonFileExtensions.Contains(houzui))
  5787. {
  5788. return Ok(JsonView(false, "未知后缀名称!"));
  5789. }
  5790. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5791. var saveFilePath = winPath + fileName;
  5792. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5793. {
  5794. item.CopyTo(fs);
  5795. fs.Flush();
  5796. }
  5797. var fileDetail = new Grp_GroupShareFile()
  5798. {
  5799. CreateUserId = dto.Userid,
  5800. CreateTime = DateTime.Now,
  5801. UploadJob = jobInfo.JobName,
  5802. FileName = fileName,
  5803. FileType = dto.FileType,
  5804. Diid = dto.Diid,
  5805. FilePath = winPath + fileName,
  5806. };
  5807. insertList.Add(fileDetail);
  5808. }
  5809. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5810. return Ok(JsonView(true, "保存成功!"));
  5811. }
  5812. /// <summary>
  5813. /// 查询共享文件列表
  5814. /// </summary>
  5815. /// <param name="dto"></param>
  5816. /// <returns></returns>
  5817. [HttpPost]
  5818. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5819. {
  5820. var isGroup = new List<int> { 1412 };
  5821. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5822. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5823. .And(x => x.Diid == dto.Diid)
  5824. .And(x => x.FileType == dto.FileType)
  5825. .And(x => x.IsDel == 0)
  5826. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5827. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5828. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5829. int totalCount = 0;
  5830. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5831. .Where(queryExpression.ToExpression())
  5832. .OrderBy(x => x.UploadJob)
  5833. .Select(x => new
  5834. {
  5835. x.Id,
  5836. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5837. x.FileName,
  5838. x.FileType,
  5839. x.CreateTime,
  5840. })
  5841. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5842. return Ok(JsonView(true, "SUCCESS!", new
  5843. {
  5844. FileList = dbQuery,
  5845. dto.PageSize,
  5846. dto.PageIndex,
  5847. totalCount
  5848. }));
  5849. }
  5850. /// <summary>
  5851. /// 删除共享文件模块下的指定文件
  5852. /// </summary>
  5853. /// <param name="dto"></param>
  5854. /// <returns></returns>
  5855. [HttpPost]
  5856. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5857. {
  5858. var jw = JsonView(false);
  5859. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5860. if (sing == null)
  5861. {
  5862. jw.Msg = "暂无文件信息!";
  5863. return Ok(jw);
  5864. }
  5865. if (sing.CreateUserId != dto.UserId)
  5866. {
  5867. jw.Msg = "只能删除自己上传的文件!";
  5868. return Ok(jw);
  5869. }
  5870. if (System.IO.File.Exists(sing.FilePath))
  5871. {
  5872. try
  5873. {
  5874. System.IO.File.Delete(sing.FilePath);
  5875. }
  5876. catch (Exception ex)
  5877. {
  5878. jw.Msg = "删除失败!" + ex.Message;
  5879. return Ok(jw);
  5880. }
  5881. }
  5882. sing.IsDel = 1;
  5883. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5884. sing.DeleteUserId = dto.UserId;
  5885. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5886. jw = JsonView(true, "删除成功!");
  5887. return Ok(jw);
  5888. }
  5889. #endregion
  5890. #region 团组英文资料
  5891. /// <summary>
  5892. /// 查询团组英文所有资料
  5893. /// </summary>
  5894. /// <param name="dto"></param>
  5895. /// <returns></returns>
  5896. [HttpPost]
  5897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5898. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5899. {
  5900. try
  5901. {
  5902. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5903. if (groupData.Code != 0)
  5904. {
  5905. return Ok(JsonView(false, groupData.Msg));
  5906. }
  5907. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5908. }
  5909. catch (Exception ex)
  5910. {
  5911. return Ok(JsonView(false, "程序错误!"));
  5912. throw;
  5913. }
  5914. }
  5915. /// <summary>
  5916. /// 团组英文资料操作(Status:1.新增,2.修改)
  5917. /// </summary>
  5918. /// <param name="dto"></param>
  5919. /// <returns></returns>
  5920. [HttpPost]
  5921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5922. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5923. {
  5924. try
  5925. {
  5926. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5927. if (groupData.Code != 0)
  5928. {
  5929. return Ok(JsonView(false, groupData.Msg));
  5930. }
  5931. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5932. }
  5933. catch (Exception ex)
  5934. {
  5935. return Ok(JsonView(false, "程序错误!"));
  5936. throw;
  5937. }
  5938. }
  5939. /// <summary>
  5940. /// 团组英文资料Id查询数据
  5941. /// </summary>
  5942. /// <param name="dto"></param>
  5943. /// <returns></returns>
  5944. [HttpPost]
  5945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5946. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5947. {
  5948. try
  5949. {
  5950. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5951. if (_DelegationEnData != null)
  5952. {
  5953. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5954. }
  5955. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5956. }
  5957. catch (Exception ex)
  5958. {
  5959. return Ok(JsonView(false, "程序错误!"));
  5960. throw;
  5961. }
  5962. }
  5963. /// <summary>
  5964. /// 团组英文资料删除
  5965. /// </summary>
  5966. /// <param name="dto"></param>
  5967. /// <returns></returns>
  5968. [HttpPost]
  5969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5970. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5971. {
  5972. try
  5973. {
  5974. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5975. if (!res)
  5976. {
  5977. return Ok(JsonView(false, "删除失败"));
  5978. }
  5979. return Ok(JsonView(true, "删除成功!"));
  5980. }
  5981. catch (Exception ex)
  5982. {
  5983. return Ok(JsonView(false, "程序错误!"));
  5984. throw;
  5985. }
  5986. }
  5987. #endregion
  5988. #region 导出邀请函
  5989. /// <summary>
  5990. /// 导出邀请函页面初始化
  5991. /// </summary>
  5992. /// <param name="dto"></param>
  5993. /// <returns></returns>
  5994. [HttpPost]
  5995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5996. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5997. {
  5998. try
  5999. {
  6000. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  6001. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  6002. if (dto.DiId == 0)
  6003. {
  6004. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6005. }
  6006. else
  6007. {
  6008. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6009. }
  6010. return Ok(JsonView(true, "查询成功!", new
  6011. {
  6012. deleClient = crm_Deles,
  6013. delegations = grp_Delegations
  6014. }));
  6015. }
  6016. catch (Exception ex)
  6017. {
  6018. return Ok(JsonView(false, "程序错误!"));
  6019. throw;
  6020. }
  6021. }
  6022. /// <summary>
  6023. /// 导出邀请函
  6024. /// </summary>
  6025. /// <param name="dto"></param>
  6026. /// <returns></returns>
  6027. [HttpPost]
  6028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6029. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6030. {
  6031. #region 参数验证
  6032. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6033. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6034. #endregion
  6035. try
  6036. {
  6037. Dictionary<string, string> transDic = new Dictionary<string, string>();
  6038. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6039. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6040. From Grp_TourClientList tcl
  6041. Left Join
  6042. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6043. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6044. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6045. From Crm_DeleClient dc
  6046. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6047. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6048. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6049. Where dc.IsDel = 0) temp
  6050. On temp.DcId =tcl.ClientId
  6051. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6052. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6053. List<string> texts = new List<string>();
  6054. if (datas.Count != 0)
  6055. {
  6056. foreach (TourClientListDetailsView item in datas)
  6057. {
  6058. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6059. {
  6060. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6061. }
  6062. else
  6063. {
  6064. string name = item.LastName + item.FirstName;
  6065. texts.Add(name);
  6066. }
  6067. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6068. {
  6069. if (!transDic.ContainsKey(item.Job))
  6070. {
  6071. texts.Add(item.Job);
  6072. }
  6073. }
  6074. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6075. {
  6076. texts.Add(item.CompanyFullName);
  6077. }
  6078. }
  6079. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6080. if (transData.Count > 0)
  6081. {
  6082. foreach (TranslateResult item in transData)
  6083. {
  6084. if (!transDic.ContainsKey(item.Query))
  6085. {
  6086. transDic.Add(item.Query, item.Translation);
  6087. }
  6088. }
  6089. }
  6090. List<GuestList> list = new List<GuestList>();
  6091. foreach (TourClientListDetailsView dele in datas)
  6092. {
  6093. GuestList guestList = new GuestList();
  6094. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6095. {
  6096. guestList.Name = dele.Pinyin;
  6097. }
  6098. else
  6099. {
  6100. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6101. guestList.Name = Name;
  6102. }
  6103. if (dele.Sex == 0)
  6104. {
  6105. guestList.Sex = "Male";
  6106. }
  6107. else if (dele.Sex == 1)
  6108. {
  6109. guestList.Sex = "Female";
  6110. }
  6111. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6112. if (!string.IsNullOrEmpty(dele.Job))
  6113. {
  6114. guestList.Job = dele.Job;
  6115. }
  6116. list.Add(guestList);
  6117. }
  6118. //载入模板
  6119. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6120. DocumentBuilder builder = new DocumentBuilder(doc);
  6121. //获取word里所有表格
  6122. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6123. //获取所填表格的序数
  6124. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6125. var rowStart = tableOne.Rows[0]; //获取第1行
  6126. //循环赋值
  6127. for (int i = 0; i < list.Count; i++)
  6128. {
  6129. builder.MoveToCell(0, i + 1, 0, 0);
  6130. builder.Write(list[i].Name.ToString());
  6131. builder.MoveToCell(0, i + 1, 1, 0);
  6132. builder.Write(list[i].Sex.ToString());
  6133. builder.MoveToCell(0, i + 1, 2, 0);
  6134. builder.Write(list[i].DOB.ToString());
  6135. builder.MoveToCell(0, i + 1, 3, 0);
  6136. builder.Write(list[i].Job.ToString());
  6137. }
  6138. //删除多余行
  6139. while (tableOne.Rows.Count > list.Count + 1)
  6140. {
  6141. tableOne.Rows.RemoveAt(list.Count + 1);
  6142. }
  6143. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6144. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6145. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6146. doc.Save(filePath);
  6147. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6148. return Ok(JsonView(true, "操作成功!", Url));
  6149. }
  6150. else
  6151. {
  6152. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6153. }
  6154. }
  6155. catch (Exception ex)
  6156. {
  6157. return Ok(JsonView(false, ex.Message));
  6158. throw;
  6159. }
  6160. }
  6161. #endregion
  6162. #region 团组经理模块 出入境费用
  6163. /// <summary>
  6164. /// 团组模块 - 出入境费用 - 省份基础数据源
  6165. /// </summary>
  6166. /// <returns></returns>
  6167. [HttpGet]
  6168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6169. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6170. {
  6171. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6172. }
  6173. /// <summary>
  6174. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6175. /// </summary>
  6176. /// <returns></returns>
  6177. [HttpPost]
  6178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6179. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6180. {
  6181. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6182. var groupNamFirst = groupNameData.FirstOrDefault();
  6183. //SetDataInfoView
  6184. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6185. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6186. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6187. //验证城市归属并给默认值
  6188. int provinceId = 122;
  6189. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6190. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6191. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6192. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6193. return Ok(JsonView(true, "查询成功!", new
  6194. {
  6195. GroupNameData = groupNameData,
  6196. CurrencyData = _CurrencyData,
  6197. WordTypeData = wordTypeData,
  6198. ExcelTypeData = excelTypeData,
  6199. CurrencyInit = _currencyInfos,
  6200. ViewPermissionData = viewPermissionData
  6201. }));
  6202. }
  6203. /// <summary>
  6204. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6205. /// </summary>
  6206. /// <returns></returns>
  6207. [HttpGet("{provinceId}")]
  6208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6209. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6210. {
  6211. //验证城市归属并给默认值
  6212. if (provinceId < 1) provinceId = 122;
  6213. /*
  6214. * 122 四川
  6215. * 108 贵州
  6216. * 103 重庆
  6217. * 132 云南
  6218. */
  6219. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6220. return Ok(JsonView(true, "查询成功!", new
  6221. {
  6222. WordTypeData = wordTypeData,
  6223. ExcelTypeData = excelTypeData,
  6224. }));
  6225. }
  6226. /// <summary>
  6227. /// 团组模块 - 出入境费用
  6228. /// 实时汇率 tips
  6229. /// 签证费用 tips
  6230. /// 机票费用 tips
  6231. /// </summary>
  6232. /// <returns></returns>
  6233. [HttpPost]
  6234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6235. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6236. {
  6237. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6238. //默认币种显示
  6239. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6240. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6241. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6242. return Ok(JsonView(true, "查询成功!", new
  6243. {
  6244. //GroupNameData = groupNameData.Data,
  6245. visaData = visaData.Data,
  6246. airData = airData,
  6247. reteInfos = reteInfos
  6248. }));
  6249. }
  6250. /// <summary>
  6251. /// 团组模块 - 出入境费用 - Info
  6252. /// </summary>
  6253. /// <returns></returns>
  6254. [HttpPost]
  6255. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6257. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6258. {
  6259. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6261. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6262. }
  6263. /// <summary>
  6264. /// 团组模块 - 出入境费用 - 设置view权限
  6265. /// </summary>
  6266. /// <returns></returns>
  6267. [HttpPost]
  6268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6269. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6270. {
  6271. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6272. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6273. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6274. var permissions = new List<Grp_EnterExitCostPermission>();
  6275. foreach (var userId in dto.UserIds)
  6276. {
  6277. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6278. }
  6279. if (permissions.Any())
  6280. {
  6281. _sqlSugar.BeginTran();
  6282. try
  6283. {
  6284. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6285. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6286. if (result < 1)
  6287. {
  6288. _sqlSugar.RollbackTran();
  6289. return Ok(JsonView(false));
  6290. }
  6291. }
  6292. catch (Exception ex)
  6293. {
  6294. _sqlSugar.RollbackTran();
  6295. return Ok(JsonView(false, ex.Message));
  6296. }
  6297. _sqlSugar.CommitTran();
  6298. return Ok(JsonView(true));
  6299. }
  6300. return Ok(JsonView(false));
  6301. }
  6302. /// <summary>
  6303. /// 团组模块 - 出入境费用 - Add And Update
  6304. /// </summary>
  6305. /// <returns></returns>
  6306. [HttpPost]
  6307. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6309. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6310. {
  6311. try
  6312. {
  6313. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6314. if (dto.DayOtherPriceData.Any())
  6315. {
  6316. var inserList = dto.DayOtherPriceData
  6317. .Where(x => x.Id == 0)
  6318. .Select(x => new Grp_DayOtherPrice
  6319. {
  6320. Cost = x.Cost,
  6321. Id = x.Id,
  6322. CreateTime = DateTime.Now,
  6323. CreateUserId = dto.UserId,
  6324. Currency = x.Currency,
  6325. Diid = x.DiId,
  6326. Index = x.Index,
  6327. IsDel = 0,
  6328. SetDataId = x.SetDataId,
  6329. SubTotal = x.SubTotal,
  6330. Remark = x.Remark
  6331. })
  6332. .ToList();
  6333. var updateList = dto.DayOtherPriceData
  6334. .Where(x => x.Id != 0)
  6335. .Select(x => new Grp_DayOtherPrice
  6336. {
  6337. Cost = x.Cost,
  6338. Id = x.Id,
  6339. CreateTime = DateTime.Now,
  6340. CreateUserId = dto.UserId,
  6341. Currency = x.Currency,
  6342. Diid = x.DiId,
  6343. Index = x.Index,
  6344. IsDel = 0,
  6345. SetDataId = x.SetDataId,
  6346. SubTotal = x.SubTotal,
  6347. Remark = x.Remark
  6348. })
  6349. .ToList();
  6350. //添加
  6351. _sqlSugar.BeginTran();
  6352. if (inserList.Any())
  6353. {
  6354. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6355. }
  6356. if (updateList.Any())
  6357. {
  6358. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6359. }
  6360. _sqlSugar.CommitTran();
  6361. }
  6362. if (data.Code != 0)
  6363. {
  6364. return Ok(JsonView(false, data.Msg));
  6365. }
  6366. //生成默认文件pdf并且通知人员
  6367. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6368. {
  6369. DiId = dto.DiId,
  6370. ExportType = 1,
  6371. SubTypeId = 1005
  6372. }, "pdf");
  6373. //发送通知
  6374. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6375. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6376. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6377. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6378. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6379. //汇率信息记录
  6380. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6381. return Ok(JsonView(true, data.Msg, data.Data));
  6382. }
  6383. catch (Exception ex)
  6384. {
  6385. return Ok(JsonView(false, ex.Message));
  6386. }
  6387. }
  6388. /// <summary>
  6389. /// 团组模块 - 出入境费用 - Confirm 费用
  6390. /// </summary>
  6391. /// <returns></returns>
  6392. [HttpPost]
  6393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6394. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6395. {
  6396. //TODO:测试完毕需把对应的用户ID更改
  6397. //1、数据表添加字段
  6398. //2、更改字段接口()
  6399. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6400. //3、确认成功 给财务发送消息
  6401. if (_view.Code == 200)
  6402. {
  6403. if (dto.Type == 1)
  6404. {
  6405. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6406. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6407. }
  6408. }
  6409. return Ok(_view);
  6410. }
  6411. /// <summary>
  6412. /// 团组模块 - 出入境费用 - File download
  6413. /// </summary>
  6414. /// <param name="dto"></param>
  6415. /// <returns></returns>
  6416. [HttpPost]
  6417. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6419. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6420. {
  6421. try
  6422. {
  6423. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6424. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6425. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6426. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6427. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6428. 3 团组成员名单 1 团组成员名单", ""));
  6429. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6430. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6431. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6432. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6433. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6434. //数据源
  6435. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6436. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6437. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6438. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6439. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6440. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6441. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6442. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6443. .Select((x, a, b) => new
  6444. {
  6445. x.Index,
  6446. itemName = a.Name,
  6447. CurrencyStr = b.Name,
  6448. x.Cost,
  6449. x.SubTotal,
  6450. x.Remark
  6451. })
  6452. .OrderBy((x) => x.Index)
  6453. .ToList(); //其他款项费用
  6454. var peiceItemCurrencys = new List<string>();
  6455. if (_DayAndCosts.Any())
  6456. {
  6457. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6458. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6459. }
  6460. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6461. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6462. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6463. {
  6464. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6465. }
  6466. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6467. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6468. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6469. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6470. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6471. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6472. .Select((tcl, dc, cc) => new ClientInfo
  6473. {
  6474. LastName = dc.LastName,
  6475. FirstName = dc.FirstName,
  6476. Sex = dc.Sex,
  6477. Birthday = dc.BirthDay,
  6478. Company = cc.CompanyFullName,
  6479. Job = dc.Job
  6480. })
  6481. .ToList();
  6482. foreach (var item in DeleClientList)
  6483. {
  6484. EncryptionProcessor.DecryptProperties(item);
  6485. }
  6486. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6487. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6488. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6489. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6490. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6491. if (dto.ExportType == 1) //明细表
  6492. {
  6493. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6494. {
  6495. //获取模板
  6496. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6497. //载入模板
  6498. Document doc = new Document(tempPath);
  6499. DocumentBuilder builder = new DocumentBuilder(doc);
  6500. //利用键值对存放数据
  6501. Dictionary<string, string> dic = new Dictionary<string, string>();
  6502. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6503. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6504. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6505. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6506. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6507. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6508. //境内费用(其他费用)
  6509. if (_EnterExitCosts.ChoiceOne == 1)
  6510. {
  6511. string row1_1 = "";
  6512. if (_EnterExitCosts.Visa > 0)
  6513. {
  6514. //insidePayTotal += _EnterExitCosts.Visa;
  6515. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6516. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6517. //{
  6518. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6519. //}
  6520. }
  6521. string row1_2 = "";
  6522. if (_EnterExitCosts.YiMiao > 0)
  6523. {
  6524. //insidePayTotal += _EnterExitCosts.YiMiao;
  6525. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6526. }
  6527. if (_EnterExitCosts.HeSuan > 0)
  6528. {
  6529. //insidePayTotal += _EnterExitCosts.HeSuan;
  6530. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6531. }
  6532. if (_EnterExitCosts.Service > 0)
  6533. {
  6534. //insidePayTotal += _EnterExitCosts.Service;
  6535. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6536. }
  6537. string row1_3 = "";
  6538. if (_EnterExitCosts.Safe > 0)
  6539. {
  6540. //insidePayTotal += _EnterExitCosts.Safe;
  6541. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6542. }
  6543. if (_EnterExitCosts.Ticket > 0)
  6544. {
  6545. //insidePayTotal += _EnterExitCosts.Ticket;
  6546. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6547. }
  6548. string row1 = "";
  6549. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6550. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6551. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6552. row1 += $"备注:{_EnterExitCosts.Remark}";
  6553. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6554. dic.Add("Row1Str", row1);
  6555. }
  6556. string airTotalStr = string.Empty,
  6557. airPriceStr = string.Empty;
  6558. //经济舱
  6559. if (_EnterExitCosts.SumJJC == 1)
  6560. {
  6561. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6562. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6563. }
  6564. //公务舱
  6565. if (_EnterExitCosts.SumGWC == 1)
  6566. {
  6567. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6568. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6569. }
  6570. //头等舱
  6571. if (_EnterExitCosts.SumTDC == 1)
  6572. {
  6573. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6574. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6575. }
  6576. //汇率描述
  6577. string rateStr = "";
  6578. if (peiceItemCurrencyInfos.Any())
  6579. {
  6580. rateStr = "\r\n汇率描述:";
  6581. foreach (var item in peiceItemCurrencyInfos)
  6582. {
  6583. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6584. }
  6585. }
  6586. string twoItemRemark = "备注:";
  6587. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6588. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6589. dic.Add("AirTotalStr", airTotalStr);
  6590. dic.Add("AirPriceStr", airPriceStr);
  6591. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6592. dic.Add("TwoItemRemark", twoItemRemark);
  6593. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6594. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6595. int table1Row = 0,
  6596. table2Row = 0,
  6597. table3Row = 0,
  6598. table4Row = 0,
  6599. table5Row = 0;
  6600. //住宿费
  6601. if (_EnterExitCosts.ChoiceThree == 1)
  6602. {
  6603. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6604. table1Row = dac1.Count;
  6605. #region 填充word表格内容
  6606. for (int i = 0; i < dac1.Count; i++)
  6607. {
  6608. Grp_DayAndCost dac = dac1[i];
  6609. if (dac == null) continue;
  6610. builder.MoveToCell(0, i, 0, 0);
  6611. builder.Write("第" + dac.Days.ToString() + "晚:");
  6612. builder.MoveToCell(0, i, 1, 0);
  6613. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6614. //builder.Write(dac.Place == null ? "" : dac.Place);
  6615. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6616. builder.MoveToCell(0, i, 2, 0);
  6617. builder.Write("费用标准:");
  6618. string curr = "";
  6619. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6620. if (currData != null)
  6621. {
  6622. curr = currData.Name;
  6623. }
  6624. builder.MoveToCell(0, i, 3, 0);
  6625. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6626. builder.MoveToCell(0, i, 4, 0);
  6627. builder.Write("费用小计:");
  6628. builder.MoveToCell(0, i, 5, 0);
  6629. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6630. }
  6631. #endregion
  6632. }
  6633. else dic.Add("SubZS", "0.00");
  6634. //删除多余行
  6635. while (table1.Rows.Count > table1Row)
  6636. {
  6637. table1.Rows.RemoveAt(table1Row);
  6638. }
  6639. //伙食费
  6640. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6641. if (_EnterExitCosts.ChoiceFour == 1)
  6642. {
  6643. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6644. table2Row = dac2.Count;
  6645. #region 填充word表格内容
  6646. for (int i = 0; i < dac2.Count; i++)
  6647. {
  6648. Grp_DayAndCost dac = dac2[i];
  6649. if (dac == null) continue;
  6650. builder.MoveToCell(1, i, 0, 0);
  6651. builder.Write("第" + dac.Days.ToString() + "天:");
  6652. builder.MoveToCell(1, i, 1, 0);
  6653. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6654. builder.MoveToCell(1, i, 2, 0);
  6655. builder.Write("费用标准:");
  6656. string curr = "";
  6657. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6658. if (currData != null)
  6659. {
  6660. curr = currData.Name;
  6661. }
  6662. builder.MoveToCell(1, i, 3, 0);
  6663. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6664. builder.MoveToCell(1, i, 4, 0);
  6665. builder.Write("费用小计:");
  6666. builder.MoveToCell(1, i, 5, 0);
  6667. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6668. }
  6669. #endregion
  6670. }
  6671. else dic.Add("SubHS", "0.00");
  6672. //删除多余行
  6673. while (table2.Rows.Count > table2Row)
  6674. {
  6675. table2.Rows.RemoveAt(table2Row);
  6676. }
  6677. //公杂费
  6678. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6679. if (_EnterExitCosts.ChoiceFive == 1)
  6680. {
  6681. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6682. table3Row = dac3.Count;
  6683. #region 填充word表格内容
  6684. for (int i = 0; i < dac3.Count; i++)
  6685. {
  6686. Grp_DayAndCost dac = dac3[i];
  6687. if (dac == null) continue;
  6688. builder.MoveToCell(2, i, 0, 0);
  6689. builder.Write("第" + dac.Days.ToString() + "天:");
  6690. builder.MoveToCell(2, i, 1, 0);
  6691. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6692. builder.MoveToCell(2, i, 2, 0);
  6693. builder.Write("费用标准:");
  6694. string curr = "";
  6695. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6696. if (currData != null)
  6697. {
  6698. curr = currData.Name;
  6699. }
  6700. builder.MoveToCell(2, i, 3, 0);
  6701. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6702. builder.MoveToCell(2, i, 4, 0);
  6703. builder.Write("费用小计:");
  6704. builder.MoveToCell(2, i, 5, 0);
  6705. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6706. }
  6707. //删除多余行
  6708. while (table3.Rows.Count > table3Row)
  6709. {
  6710. table3.Rows.RemoveAt(table3Row);
  6711. }
  6712. #endregion
  6713. }
  6714. else dic.Add("SubGZF", "0.00");
  6715. //删除多余行
  6716. while (table3.Rows.Count > table3Row)
  6717. {
  6718. table3.Rows.RemoveAt(table3Row);
  6719. }
  6720. //培训费
  6721. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6722. if (_EnterExitCosts.ChoiceSix == 1)
  6723. {
  6724. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6725. dic.Add("SubPX", pxStr);
  6726. table4Row = dac4.Count;
  6727. #region 填充word表格内容
  6728. for (int i = 0; i < dac4.Count; i++)
  6729. {
  6730. Grp_DayAndCost dac = dac4[i];
  6731. if (dac == null) continue;
  6732. builder.MoveToCell(3, i, 0, 0);
  6733. builder.Write("第" + dac.Days.ToString() + "天:");
  6734. builder.MoveToCell(3, i, 1, 0);
  6735. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6736. builder.MoveToCell(3, i, 2, 0);
  6737. builder.Write("费用标准:");
  6738. string curr = "";
  6739. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6740. if (currData != null)
  6741. {
  6742. curr = currData.Name;
  6743. }
  6744. builder.MoveToCell(3, i, 3, 0);
  6745. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6746. builder.MoveToCell(3, i, 4, 0);
  6747. builder.Write("费用小计:");
  6748. builder.MoveToCell(3, i, 5, 0);
  6749. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6750. }
  6751. #endregion
  6752. }
  6753. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6754. //删除多余行
  6755. while (table4.Rows.Count > table4Row)
  6756. {
  6757. table4.Rows.RemoveAt(table4Row);
  6758. }
  6759. //其他费用
  6760. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6761. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6762. {
  6763. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6764. dic.Add("titleQi", qtStr);
  6765. table5Row = dac5.Count;
  6766. #region 填充word表格内容
  6767. for (int i = 0; i < dac5.Count; i++)
  6768. {
  6769. var dac = dac5[i];
  6770. if (dac == null) continue;
  6771. builder.MoveToCell(4, i, 0, 0);
  6772. builder.Write("第" + dac.Index.ToString() + "项:");
  6773. builder.MoveToCell(4, i, 1, 0);
  6774. builder.Write(dac.itemName);
  6775. builder.MoveToCell(4, i, 2, 0);
  6776. builder.Write("费用标准:");
  6777. builder.MoveToCell(4, i, 3, 0);
  6778. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6779. builder.MoveToCell(4, i, 4, 0);
  6780. builder.Write("费用小计:");
  6781. builder.MoveToCell(4, i, 5, 0);
  6782. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6783. builder.MoveToCell(4, i, 6, 0);
  6784. builder.Write("备注:");
  6785. builder.MoveToCell(4, i, 7, 0);
  6786. builder.Write(dac.Remark);
  6787. }
  6788. #endregion
  6789. }
  6790. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6791. //删除多余行
  6792. while (table5.Rows.Count > table5Row)
  6793. {
  6794. table5.Rows.RemoveAt(table5Row);
  6795. }
  6796. //加上其他费用
  6797. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6798. decimal subJJC = 0.00M,
  6799. subGWC = 0.00M,
  6800. subTDC = 0.00M;
  6801. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6802. string totalLabel = string.Format("全部费用总计:");
  6803. //经济舱
  6804. if (_EnterExitCosts.SumJJC == 1)
  6805. {
  6806. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6807. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6808. }
  6809. //公务舱
  6810. if (_EnterExitCosts.SumGWC == 1)
  6811. {
  6812. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6813. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6814. }
  6815. //头等舱
  6816. if (_EnterExitCosts.SumTDC == 1)
  6817. {
  6818. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6819. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6820. }
  6821. //TotalLabel
  6822. dic.Add("TotalLabel", totalLabel);
  6823. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6824. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6825. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6826. #region 填充word模板书签内容
  6827. foreach (var key in dic.Keys)
  6828. {
  6829. Bookmark bookmark = doc.Range.Bookmarks[key];
  6830. if (bookmark != null)
  6831. {
  6832. builder.MoveToBookmark(key);
  6833. builder.Write(dic[key]);
  6834. }
  6835. }
  6836. #endregion
  6837. #region 设置页眉
  6838. string userLabel = string.Empty;
  6839. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6840. if (currUserInfo != null)
  6841. {
  6842. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6843. if (userInfo != null)
  6844. {
  6845. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6846. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6847. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6848. }
  6849. }
  6850. //设置页脚
  6851. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6852. #endregion
  6853. //文件名
  6854. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6855. AsposeHelper.removewatermark_v2180();
  6856. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6857. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6858. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6859. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6860. }
  6861. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6862. {
  6863. //获取模板
  6864. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6865. //载入模板
  6866. Document doc = new Document(tempPath);
  6867. DocumentBuilder builder = new DocumentBuilder(doc);
  6868. Dictionary<string, string> dic = new Dictionary<string, string>();
  6869. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6870. {
  6871. List<string> list = new List<string>();
  6872. try
  6873. {
  6874. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6875. foreach (var item in spilitArr)
  6876. {
  6877. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6878. var depCode = spDotandEmpty[2].Substring(0, 3);
  6879. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6880. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6881. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6882. list.Add(depName);
  6883. list.Add(arrName);
  6884. }
  6885. list = list.Distinct().ToList();
  6886. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6887. }
  6888. catch (Exception)
  6889. {
  6890. dic.Add("ReturnCode", "行程录入不正确!");
  6891. }
  6892. }
  6893. else
  6894. {
  6895. dic.Add("ReturnCode", "未录入行程!");
  6896. }
  6897. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6898. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6899. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6900. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6901. {
  6902. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6903. dic.Add("Day", sp.Days.ToString());
  6904. }
  6905. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6906. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6907. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6908. //dic.Add("Names", Names);
  6909. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6910. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6911. decimal dac1totalPrice = 0.00M;
  6912. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6913. foreach (var dac in dac1)
  6914. {
  6915. if (dac.SubTotal == 0.00M)
  6916. {
  6917. continue;
  6918. }
  6919. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6920. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6921. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6922. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6923. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6924. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6925. builder.Write(currency);//币种
  6926. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6927. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6928. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6929. builder.Write("");//人数
  6930. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6931. builder.Write("");//天数
  6932. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6933. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6934. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6935. decimal rate = 0.00M;
  6936. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6937. builder.Write(rate.ToString("#0.0000"));//汇率
  6938. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6939. decimal rbmPrice = dac.SubTotal;
  6940. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6941. accommodationStartIndex++;
  6942. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6943. }
  6944. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6945. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6946. {
  6947. table1.Rows.RemoveAt(i - 1);
  6948. foodandotherStartIndex--;
  6949. }
  6950. if (dac2.Count == dac3.Count)//国家 币种 金额
  6951. {
  6952. for (int i = 0; i < dac2.Count; i++)
  6953. {
  6954. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6955. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6956. }
  6957. }
  6958. decimal dac2totalPrice = 0.00M;
  6959. foreach (var dac in dac2)
  6960. {
  6961. if (dac.SubTotal == 0)
  6962. {
  6963. continue;
  6964. }
  6965. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6966. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6967. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6968. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6969. builder.Write(currency);//币种
  6970. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6971. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6972. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6973. builder.Write("");//人数
  6974. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6975. builder.Write("");//天数
  6976. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6977. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6978. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6979. decimal rate = 0.00M;
  6980. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6981. builder.Write(rate.ToString("#0.0000"));//汇率
  6982. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6983. decimal rbmPrice = dac.SubTotal;
  6984. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6985. foodandotherStartIndex++;
  6986. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6987. }
  6988. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6989. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6990. {
  6991. table1.Rows.RemoveAt(i - 1);
  6992. }
  6993. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6994. string otherFeeStr = "";
  6995. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6996. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6997. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6998. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6999. foreach (var otherInfo in dac5)
  7000. {
  7001. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7002. }
  7003. #endregion
  7004. if (otherFeeStr.Length > 0)
  7005. {
  7006. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7007. otherFeeStr = $"({otherFeeStr})";
  7008. dic.Add("OtherFeeStr", otherFeeStr);
  7009. }
  7010. //总计
  7011. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7012. //国际旅费
  7013. string outsideAir = string.Empty;
  7014. string allPriceAir = string.Empty;
  7015. if (_EnterExitCosts.SumJJC == 1)
  7016. {
  7017. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7018. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7019. }
  7020. if (_EnterExitCosts.SumGWC == 1)
  7021. {
  7022. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7023. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7024. }
  7025. if (_EnterExitCosts.SumTDC == 1)
  7026. {
  7027. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7028. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7029. }
  7030. dic.Add("InTravelPrice", $"({outsideAir})");
  7031. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7032. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7033. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7034. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7035. foreach (var key in dic.Keys)
  7036. {
  7037. builder.MoveToBookmark(key);
  7038. builder.Write(dic[key]);
  7039. }
  7040. //模板文件名
  7041. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7042. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7043. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7044. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7045. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7046. }
  7047. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7048. {
  7049. //获取模板
  7050. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7051. //载入模板
  7052. WorkbookDesigner designer = new WorkbookDesigner();
  7053. designer.Workbook = new Workbook(tempPath);
  7054. Dictionary<string, string> dic = new Dictionary<string, string>();
  7055. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7056. {
  7057. List<string> list = new List<string>();
  7058. try
  7059. {
  7060. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7061. foreach (var item in spilitArr)
  7062. {
  7063. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7064. var depCode = spDotandEmpty[2].Substring(0, 3);
  7065. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7066. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7067. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7068. list.Add(depName);
  7069. list.Add(arrName);
  7070. }
  7071. list = list.Distinct().ToList();
  7072. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7073. }
  7074. catch (Exception)
  7075. {
  7076. dic.Add("ReturnCode", "行程录入不正确!");
  7077. }
  7078. }
  7079. else
  7080. {
  7081. dic.Add("ReturnCode", "未录入行程!");
  7082. }
  7083. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7084. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7085. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7086. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7087. {
  7088. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7089. dic.Add("Day", sp.Days.ToString());
  7090. }
  7091. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7092. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7093. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7094. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7095. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7096. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7097. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7098. designer.SetDataSource("Name", Names);
  7099. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7100. designer.SetDataSource("Day", dic["Day"] + "天");
  7101. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7102. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7103. int startIndex = 10;
  7104. const int startIndexcopy = 10;
  7105. if (dac2.Count == dac3.Count)//国家 币种 金额
  7106. {
  7107. for (int i = 0; i < dac2.Count; i++)
  7108. {
  7109. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7110. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7111. }
  7112. }
  7113. DataTable dtdac1 = new DataTable();
  7114. List<string> place = new List<string>();
  7115. dtdac1.Columns.AddRange(new DataColumn[] {
  7116. new DataColumn(){ ColumnName = "city"},
  7117. new DataColumn(){ ColumnName = "curr"},
  7118. new DataColumn(){ ColumnName = "criterion"},
  7119. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7120. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7121. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7122. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7123. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7124. });
  7125. DataTable dtdac2 = new DataTable();
  7126. dtdac2.Columns.AddRange(new DataColumn[] {
  7127. new DataColumn(){ ColumnName = "city"},
  7128. new DataColumn(){ ColumnName = "curr"},
  7129. new DataColumn(){ ColumnName = "criterion"},
  7130. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7131. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7132. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7133. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7134. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7135. });
  7136. dtdac1.TableName = "tb1";
  7137. dtdac2.TableName = "tb2";
  7138. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7139. foreach (var item in dac1)
  7140. {
  7141. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7142. if (place.Contains(item.Place))
  7143. {
  7144. continue;
  7145. }
  7146. DataRow row = dtdac1.NewRow();
  7147. row["city"] = item.Place;
  7148. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7149. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7150. row["curr"] = currency;
  7151. row["rate"] = rate.ToString("#0.0000");
  7152. row["criterion"] = item.Cost.ToString("#0.00");
  7153. row["number"] = 1;
  7154. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7155. //row["costRMB"] = rbmPrice;
  7156. dtdac1.Rows.Add(row);
  7157. place.Add(item.Place);
  7158. }
  7159. place = new List<string>();
  7160. foreach (var item in dac2)
  7161. {
  7162. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7163. if (place.Contains(item.Place))
  7164. {
  7165. continue;
  7166. }
  7167. DataRow row = dtdac2.NewRow();
  7168. row["city"] = item.Place;
  7169. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7170. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7171. row["curr"] = currency;
  7172. row["rate"] = rate.ToString("#0.0000");
  7173. row["criterion"] = item.Cost.ToString("#0.00");
  7174. row["number"] = 1;
  7175. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7176. //row["cost"] = item.SubTotal;
  7177. //row["costRMB"] = rbmPrice;
  7178. dtdac2.Rows.Add(row);
  7179. place.Add(item.Place);
  7180. //dac2totalPrice += rbmPrice;
  7181. }
  7182. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7183. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7184. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7185. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7186. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7187. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7188. string cell4Str1 = string.Empty;
  7189. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7190. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7191. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7192. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7193. string cellStr = $" 5.其他费用(";
  7194. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7195. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7196. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7197. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7198. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7199. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7200. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7201. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7202. foreach (var otherInfo in dac5)
  7203. {
  7204. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7205. }
  7206. #endregion
  7207. if (cellStr.Length > 8)
  7208. {
  7209. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7210. }
  7211. cellStr += ")";
  7212. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7213. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7214. decimal pxFee = dac4.Sum(it => it.Cost);
  7215. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7216. string celllastStr1 = "";
  7217. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7218. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7219. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7220. celllastStr1 += $",国际旅费 元";
  7221. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7222. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7223. designer.SetDataSource("cell4Str", cell4Str);
  7224. designer.SetDataSource("cellStr", cellStr);
  7225. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7226. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7227. designer.SetDataSource("celllastStr", celllastStr);
  7228. Workbook wb = designer.Workbook;
  7229. var sheet = wb.Worksheets[0];
  7230. //绑定datatable数据集
  7231. designer.SetDataSource(dtdac1);
  7232. designer.SetDataSource(dtdac2);
  7233. designer.Process();
  7234. var rowStart = dtdac1.Rows.Count;
  7235. while (rowStart > 0)
  7236. {
  7237. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7238. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7239. startIndex++;
  7240. rowStart--;
  7241. }
  7242. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7243. startIndex += 1; //总计行
  7244. rowStart = dtdac2.Rows.Count;
  7245. while (rowStart > 0)
  7246. {
  7247. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7248. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7249. startIndex++;
  7250. rowStart--;
  7251. }
  7252. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7253. wb.CalculateFormula(true);
  7254. //模板文件名
  7255. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7256. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7257. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7258. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7259. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7260. }
  7261. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7262. {
  7263. //获取模板
  7264. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7265. //载入模板
  7266. Document doc = new Document(tempPath);
  7267. DocumentBuilder builder = new DocumentBuilder(doc);
  7268. Dictionary<string, string> dic = new Dictionary<string, string>();
  7269. dic.Add("GroupName", _DelegationInfo.TeamName);
  7270. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7271. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7272. string missionLeaderJob = "";//负责人job
  7273. //int groupNumber = 0; //团人数
  7274. if (DeleClientList.Count > 0)
  7275. {
  7276. missionLeader = DeleClientList[0]?.Name ?? "";
  7277. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7278. }
  7279. dic.Add("MissionLeader", missionLeader); //团负责人
  7280. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7281. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7282. #region MyRegion
  7283. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7284. //{
  7285. // List<string> list = new List<string>();
  7286. // try
  7287. // {
  7288. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7289. // foreach (var item in spilitArr)
  7290. // {
  7291. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7292. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7293. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7294. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7295. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7296. // list.Add(depName);
  7297. // list.Add(arrName);
  7298. // }
  7299. // list = list.Distinct().ToList();
  7300. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7301. // }
  7302. // catch (Exception)
  7303. // {
  7304. // dic.Add("ReturnCode", "行程录入不正确!");
  7305. // }
  7306. //}
  7307. //else
  7308. //{
  7309. // dic.Add("ReturnCode", "未录入行程!");
  7310. //}
  7311. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7312. dic.Add("ReturnCode", string.Join("、", countrys));
  7313. #endregion
  7314. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7315. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7316. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7317. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7318. //{
  7319. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7320. // dic.Add("Day", sp.Days.ToString());
  7321. //}
  7322. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7323. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7324. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7325. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7326. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7327. //培训人员名单
  7328. int cultivateRowIndex = 7;
  7329. foreach (var item in DeleClientList)
  7330. {
  7331. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7332. builder.Write(item.Name);
  7333. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7334. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7335. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7336. string birthDay = "";
  7337. if (item.Birthday != null)
  7338. {
  7339. DateTime dt = Convert.ToDateTime(item.Birthday);
  7340. birthDay = $"{dt.Year}.{dt.Month}";
  7341. }
  7342. builder.Write(birthDay);
  7343. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7344. builder.Write(item.Company);
  7345. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7346. builder.Write(item.Job);
  7347. cultivateRowIndex++;
  7348. }
  7349. //删除多余行
  7350. //cultivateRowIndex -= 2;
  7351. int delRows = 10 + 7 - cultivateRowIndex;
  7352. if (delRows > 0)
  7353. {
  7354. for (int i = 0; i < delRows; i++)
  7355. {
  7356. table1.Rows.RemoveAt(cultivateRowIndex);
  7357. //cultivateRowIndex++;
  7358. }
  7359. }
  7360. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7361. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7362. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7363. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7364. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7365. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7366. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7367. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7368. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7369. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7370. //其他费用
  7371. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7372. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7373. //其他费用合计
  7374. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7375. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7376. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7377. //公务舱合计
  7378. //国际旅费
  7379. //string outsideJJ = "";
  7380. //string allPriceJJ = "";
  7381. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7382. {
  7383. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7384. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7385. }
  7386. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7387. {
  7388. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7389. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7390. }
  7391. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7392. {
  7393. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7394. dic.Add("AirFeeTotal", airFeeTotalStr);
  7395. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7396. dic.Add("FeeTotal", feeTotalStr);
  7397. }
  7398. foreach (var key in dic.Keys)
  7399. {
  7400. builder.MoveToBookmark(key);
  7401. builder.Write(dic[key]);
  7402. }
  7403. //模板文件名
  7404. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7405. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7409. }
  7410. }
  7411. else if (dto.ExportType == 2) //表格
  7412. {
  7413. //利用键值对存放数据
  7414. Dictionary<string, string> dic = new Dictionary<string, string>();
  7415. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7416. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7417. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7418. dic.Add("Day", sp.Days.ToString());
  7419. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7420. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7421. {
  7422. //获取模板
  7423. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7424. //载入模板
  7425. Document doc = new Document(tempPath);
  7426. DocumentBuilder builder = new DocumentBuilder(doc);
  7427. dic.Add("TeamName", _DelegationInfo.TeamName);
  7428. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7429. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7430. string missionLeaderName = "",
  7431. missionLeaderJob = "";
  7432. if (DeleClientList.Count > 0)
  7433. {
  7434. missionLeaderName = DeleClientList[0].Name;
  7435. missionLeaderJob = DeleClientList[0].Job;
  7436. }
  7437. dic.Add("MissionLeaderName", missionLeaderName);
  7438. dic.Add("MissionLeaderJob", missionLeaderJob);
  7439. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7440. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7441. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7442. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7443. int rowCount = 10;//总人数行
  7444. int startRowIndex = 7; //起始行
  7445. for (int i = 0; i < DeleClientList.Count; i++)
  7446. {
  7447. builder.MoveToCell(0, startRowIndex, 0, 0);
  7448. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7449. builder.MoveToCell(0, startRowIndex, 1, 0);
  7450. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7451. builder.Write(sex);//性别
  7452. builder.MoveToCell(0, startRowIndex, 2, 0);
  7453. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7454. builder.MoveToCell(0, startRowIndex, 3, 0);
  7455. builder.Write(DeleClientList[i].Company);//工作单位
  7456. builder.MoveToCell(0, startRowIndex, 4, 0);
  7457. builder.Write(DeleClientList[i].Job);//职务及级别
  7458. builder.MoveToCell(0, startRowIndex, 5, 0);
  7459. builder.Write("");//人员属性
  7460. builder.MoveToCell(0, startRowIndex, 6, 0);
  7461. builder.Write("");//上次出国时间
  7462. startRowIndex++;
  7463. }
  7464. int nullRow = rowCount - DeleClientList.Count;//空行
  7465. for (int i = 0; i < nullRow; i++)
  7466. {
  7467. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7468. }
  7469. foreach (var key in dic.Keys)
  7470. {
  7471. builder.MoveToBookmark(key);
  7472. builder.Write(dic[key]);
  7473. }
  7474. //模板文件名
  7475. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7476. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7477. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7478. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7479. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7480. }
  7481. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7482. {
  7483. //获取模板
  7484. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7485. //载入模板
  7486. Document doc = new Document(tempPath);
  7487. DocumentBuilder builder = new DocumentBuilder(doc);
  7488. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7489. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7490. dic.Add("Names", Names);
  7491. int accommodationRows = 12;
  7492. //int foodandotherRows = 12;
  7493. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7494. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7495. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7496. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7497. int accommodationStartIndex = 6;
  7498. decimal dac1totalPrice = 0.00M;
  7499. foreach (var dac in dac1)
  7500. {
  7501. if (dac.SubTotal == 0)
  7502. {
  7503. continue;
  7504. }
  7505. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7506. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7507. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7508. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7509. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7510. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7511. builder.Write(currency);//币种
  7512. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7513. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7514. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7515. builder.Write("");//人数
  7516. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7517. builder.Write("");//天数
  7518. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7519. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7520. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7521. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7522. builder.Write(rate.ToString("#0.0000"));//汇率
  7523. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7524. decimal rbmPrice = rate * dac.SubTotal;
  7525. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7526. accommodationStartIndex++;
  7527. dac1totalPrice += rbmPrice;
  7528. }
  7529. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7530. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7531. builder.Write("小计");
  7532. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7533. builder.Write(dac1totalPrice.ToString("#0.00"));
  7534. accommodationStartIndex++;
  7535. int nullRow = accommodationRows - dac1.Count;
  7536. //删除空行
  7537. //if (nullRow > 0)
  7538. //{
  7539. // int rowIndex = accommodationStartIndex;
  7540. // for (int i = 0; i < nullRow; i++)
  7541. // {
  7542. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7543. // row.Remove();
  7544. // rowIndex++;
  7545. // }
  7546. //}
  7547. if (dac2.Count == dac3.Count)//国家 币种 金额
  7548. {
  7549. for (int i = 0; i < dac2.Count; i++)
  7550. {
  7551. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7552. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7553. }
  7554. }
  7555. int foodandotherStartIndex = 19;//
  7556. decimal dac2totalPrice = 0.00M;
  7557. foreach (var dac in dac2)
  7558. {
  7559. if (dac.SubTotal == 0)
  7560. {
  7561. continue;
  7562. }
  7563. //foodandotherStartIndex = 12;
  7564. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7565. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7566. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7567. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7568. builder.Write(currency);//币种
  7569. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7570. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7571. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7572. builder.Write("");//人数
  7573. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7574. builder.Write("");//天数
  7575. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7576. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7577. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7578. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7579. builder.Write(rate.ToString("#0.0000"));//汇率
  7580. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7581. decimal rbmPrice = rate * dac.SubTotal;
  7582. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7583. foodandotherStartIndex++;
  7584. dac2totalPrice += rbmPrice;
  7585. }
  7586. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7587. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7588. //删除空行
  7589. //if (dac2.Count < foodandotherRows)
  7590. //{
  7591. // while (table2.Rows.Count > dac2.Count)
  7592. // {
  7593. // table2.Rows.RemoveAt(dac2.Count);
  7594. // }
  7595. //}
  7596. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7597. string otherFeeStr = "";
  7598. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7599. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7600. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7601. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7602. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7603. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7604. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7605. foreach (var otherInfo in dac5)
  7606. {
  7607. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7608. }
  7609. #endregion
  7610. if (otherFeeStr.Length > 0)
  7611. {
  7612. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7613. otherFeeStr = $"({otherFeeStr})";
  7614. dic.Add("OtherFeeStr", otherFeeStr);
  7615. }
  7616. foreach (var key in dic.Keys)
  7617. {
  7618. builder.MoveToBookmark(key);
  7619. builder.Write(dic[key]);
  7620. }
  7621. //模板文件名
  7622. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7623. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7624. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7625. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7626. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7627. }
  7628. }
  7629. else if (dto.ExportType == 3)
  7630. {
  7631. if (dto.SubTypeId == 1) //团组成员名单
  7632. {
  7633. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7634. //获取模板
  7635. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7636. //载入模板
  7637. Document doc = new Document(tempPath);
  7638. DocumentBuilder builder = new DocumentBuilder(doc);
  7639. //获取word里所有表格
  7640. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7641. //获取所填表格的序数
  7642. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7643. var rowStart = tableOne.Rows[0]; //获取第1行
  7644. //循环赋值
  7645. for (int i = 0; i < DeleClientList.Count; i++)
  7646. {
  7647. builder.MoveToCell(0, i + 1, 0, 0);
  7648. builder.Write(DeleClientList[i].Name);
  7649. builder.MoveToCell(0, i + 1, 1, 0);
  7650. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7651. builder.Write(sex);
  7652. builder.MoveToCell(0, i + 1, 2, 0);
  7653. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7654. builder.MoveToCell(0, i + 1, 3, 0);
  7655. builder.Write(DeleClientList[i].Company);
  7656. builder.MoveToCell(0, i + 1, 4, 0);
  7657. builder.Write(DeleClientList[i].Job);
  7658. }
  7659. //删除多余行
  7660. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7661. {
  7662. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7663. }
  7664. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7665. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7666. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7667. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7668. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7669. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7670. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7671. }
  7672. }
  7673. return Ok(JsonView(400, "操作失败!", ""));
  7674. }
  7675. catch (Exception ex)
  7676. {
  7677. return Ok(JsonView(400, ex.Message, ""));
  7678. }
  7679. }
  7680. /// <summary>
  7681. /// 获取三公费用标准city
  7682. /// </summary>
  7683. /// <param name="placeData"></param>
  7684. /// <param name="nationalTravelFeeId"></param>
  7685. /// <returns></returns>
  7686. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7687. {
  7688. string _city = string.Empty;
  7689. if (placeData.Count < 1) return _city;
  7690. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7691. if (data == null) return _city;
  7692. string country = data.Country;
  7693. string city = data.City;
  7694. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7695. else _city = city;
  7696. return _city;
  7697. }
  7698. ///// <summary>
  7699. ///// 团组模块 - 出入境费用 - 明细表导出
  7700. ///// </summary>
  7701. ///// <returns></returns>
  7702. //[HttpPost]
  7703. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7704. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7705. //{
  7706. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7707. // if (data.Code != 0)
  7708. // {
  7709. // return Ok(JsonView(false, data.Msg));
  7710. // }
  7711. // return Ok(JsonView(true, data.Msg, data.Data));
  7712. //}
  7713. /// <summary>
  7714. /// 团组模块 - 出入境费用 - 一键清空
  7715. /// </summary>
  7716. /// <returns></returns>
  7717. [HttpPost]
  7718. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7720. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7721. {
  7722. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7723. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7724. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7725. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7726. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7727. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7728. .SetColumns(x => new Grp_DayOtherPrice
  7729. {
  7730. IsDel = 1,
  7731. DeleteUserId = dto.UserId,
  7732. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7733. })
  7734. .ExecuteCommandAsync();
  7735. if (_view.Code == 0)
  7736. {
  7737. return Ok(JsonView(true, "操作成功"));
  7738. }
  7739. return Ok(JsonView(false, "操作失败"));
  7740. }
  7741. /// <summary>
  7742. /// 团组模块 - 出入境费用 - 子项删除
  7743. /// </summary>
  7744. /// <returns></returns>
  7745. [HttpPost]
  7746. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7748. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7749. {
  7750. try
  7751. {
  7752. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7753. if (data.Code != 0)
  7754. {
  7755. return Ok(JsonView(false, data.Msg));
  7756. }
  7757. return Ok(JsonView(true, "操作成功!", data.Data));
  7758. }
  7759. catch (Exception ex)
  7760. {
  7761. return Ok(JsonView(false, ex.Message));
  7762. }
  7763. }
  7764. /// <summary>
  7765. /// 删除三公其他费用
  7766. /// </summary>
  7767. /// <param name="dto"></param>
  7768. /// <returns></returns>
  7769. [HttpPost]
  7770. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7771. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7772. {
  7773. var jw = JsonView(false, "删除失败!");
  7774. var data = new Grp_DayOtherPrice()
  7775. {
  7776. Id = dto.Id,
  7777. IsDel = 1,
  7778. DeleteUserId = dto.DeleteUserId,
  7779. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7780. };
  7781. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7782. if (del > 0)
  7783. {
  7784. jw.Code = 200;
  7785. jw.Msg = "删除成功!";
  7786. }
  7787. return Ok(jw);
  7788. }
  7789. /// <summary>
  7790. /// 团组模块 - 出入境国家费用标准 List
  7791. /// </summary>
  7792. /// <returns></returns>
  7793. [HttpPost]
  7794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7795. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7796. {
  7797. int provinceId = dto.ProvinceId;
  7798. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7799. var nftData = await _sqlSugar
  7800. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7801. JoinType.Left, ntf.Currency == sd1.Id,
  7802. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7803. JoinType.Left, ntf.ProvinceId == c.Id
  7804. ))
  7805. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7806. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7807. {
  7808. Id = ntf.Id,
  7809. ProvinceId = ntf.ProvinceId,
  7810. ProvinceName = c.Name_CN,
  7811. Continent = ntf.Continent,
  7812. Country = ntf.Country,
  7813. City = ntf.City,
  7814. Currency = ntf.Currency,
  7815. CurrencyCode = sd1.Name,
  7816. CurrencyName = sd1.Remark,
  7817. RoomCost = ntf.RoomCost,
  7818. FoodCost = ntf.FoodCost,
  7819. PublicCost = ntf.PublicCost,
  7820. LastUpdateUserId = ntf.LastUpdateUserId,
  7821. LastUpdateUserName = u.CnName,
  7822. LastUpdateTime = ntf.LastUpdateTime
  7823. })
  7824. .ToListAsync();
  7825. return Ok(JsonView(true, "查询成功!", nftData));
  7826. }
  7827. /// <summary>
  7828. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7829. /// </summary>
  7830. /// <returns></returns>
  7831. [HttpPost]
  7832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7833. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7834. {
  7835. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7836. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7837. List<string> countryData = new List<string>();
  7838. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7839. countryData = countryData.Distinct().ToList();
  7840. List<dynamic> dataSource = new List<dynamic>();
  7841. foreach (var item in countryData)
  7842. {
  7843. var cityData1 = new List<string>();
  7844. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7845. var countryData2 = new
  7846. {
  7847. CountryName = item,
  7848. CityData = cityData1
  7849. };
  7850. if (!dataSource.Contains(countryData2))
  7851. {
  7852. dataSource.Add(countryData2);
  7853. }
  7854. }
  7855. return Ok(JsonView(true, "查询成功!", dataSource));
  7856. }
  7857. /// <summary>
  7858. /// 团组模块 - 出入境国家费用标准 Page List
  7859. /// </summary>
  7860. /// <returns></returns>
  7861. [HttpPost]
  7862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7863. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7864. {
  7865. int portId = dto.PortType,
  7866. pageIndex = dto.PageIndex,
  7867. pageSize = dto.PageSize;
  7868. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7869. if (pageIndex == 0) pageIndex = 1;
  7870. if (pageSize == 0) pageSize = 10;
  7871. RefAsync<int> total = 0;
  7872. var nationalTravelFeeData = await _sqlSugar
  7873. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7874. JoinType.Left, ntf.Currency == sd1.Id,
  7875. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7876. JoinType.Left, ntf.ProvinceId == sd2.Id
  7877. ))
  7878. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7879. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7880. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7881. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7882. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7883. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7884. {
  7885. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7886. Id = ntf.Id,
  7887. ProvinceId = ntf.ProvinceId,
  7888. ProvinceName = sd2.Name_CN,
  7889. Continent = ntf.Continent,
  7890. Country = ntf.Country,
  7891. City = ntf.City,
  7892. Currency = ntf.Currency,
  7893. CurrencyCode = sd1.Name,
  7894. CurrencyName = sd1.Remark,
  7895. RoomCost = ntf.RoomCost,
  7896. FoodCost = ntf.FoodCost,
  7897. PublicCost = ntf.PublicCost,
  7898. LastUpdateUserId = ntf.LastUpdateUserId,
  7899. LastUpdateUserName = u.CnName,
  7900. LastUpdateTime = ntf.LastUpdateTime,
  7901. Remark = ntf.Remark
  7902. })
  7903. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7904. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7905. }
  7906. /// <summary>
  7907. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7908. /// </summary>
  7909. /// <returns></returns>
  7910. [HttpPost]
  7911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7912. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7913. {
  7914. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7915. int portId = dto.PortType;
  7916. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7917. string whereSql = string.Empty;
  7918. if (!string.IsNullOrEmpty(dto.Country))
  7919. {
  7920. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7921. }
  7922. if (!string.IsNullOrEmpty(dto.City))
  7923. {
  7924. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7925. }
  7926. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7927. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7928. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7929. From Grp_NationalTravelFee gntf
  7930. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7931. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7932. Where gntf.Isdel = 0 {0} ", whereSql);
  7933. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7934. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7935. }
  7936. /// <summary>
  7937. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7938. /// </summary>
  7939. /// <returns></returns>
  7940. [HttpPost]
  7941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7942. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7943. {
  7944. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7945. }
  7946. /// <summary>
  7947. /// 团组模块 - 出入境国家费用标准 - Del
  7948. /// </summary>
  7949. /// <returns></returns>
  7950. [HttpPost]
  7951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7952. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7953. {
  7954. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7955. {
  7956. Id = dto.Id,
  7957. DeleteUserId = dto.DeleteUserId,
  7958. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7959. IsDel = 1
  7960. };
  7961. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7962. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7963. .WhereColumns(it => new { it.Id })
  7964. .ExecuteCommandAsync();
  7965. if (delStatus <= 0)
  7966. {
  7967. return Ok(JsonView(false, "删除失败!"));
  7968. }
  7969. return Ok(JsonView(true, "操作成功!"));
  7970. }
  7971. /// <summary>
  7972. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7973. /// 注:Get 请求Headers 加 Token
  7974. /// </summary>
  7975. /// <param name="groupId"></param>
  7976. /// <returns></returns>
  7977. [HttpGet("{groupId}")]
  7978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7979. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7980. {
  7981. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7982. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7983. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7984. data.ForEach(x =>
  7985. {
  7986. x.CreateUserId = _currUserInfo.UserId;
  7987. });
  7988. if (data.Any())
  7989. {
  7990. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7991. if (add > 0)
  7992. {
  7993. return Ok(JsonView(true, "操作成功!"));
  7994. }
  7995. }
  7996. return Ok(JsonView(false, "未操作!"));
  7997. }
  7998. #endregion
  7999. #region 团组经理模块 出入境费用-草稿
  8000. /// <summary>
  8001. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  8002. /// </summary>
  8003. /// <returns></returns>
  8004. [HttpGet]
  8005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8006. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8007. {
  8008. var provData = await _groupRepository.ProvinceBasicSource();
  8009. return Ok(JsonView(true, "查询成功!", provData));
  8010. }
  8011. /// <summary>
  8012. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8013. /// </summary>
  8014. /// <returns></returns>
  8015. [HttpGet("{provinceId}")]
  8016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8017. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8018. {
  8019. //验证城市归属并给默认值
  8020. if (provinceId < 1) provinceId = 122;
  8021. /*
  8022. * 122 四川
  8023. * 108 贵州
  8024. * 103 重庆
  8025. * 132 云南
  8026. */
  8027. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8028. return Ok(JsonView(true, "查询成功!", new
  8029. {
  8030. WordTypeData = wordTypeData,
  8031. ExcelTypeData = excelTypeData,
  8032. }));
  8033. }
  8034. /// <summary>
  8035. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8036. /// </summary>
  8037. /// <returns></returns>
  8038. [HttpPost]
  8039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8040. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8041. {
  8042. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8043. .Where(x => x.IsDel == 0)
  8044. .OrderByDescending(x => x.CreateTime)
  8045. .Select(x => new { x.Id, x.DraftName })
  8046. .ToListAsync();
  8047. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8048. //SetDataInfoView
  8049. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8050. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8051. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8052. int provinceId = dto.ProvinceId;
  8053. if (provinceId < 1) provinceId = 122;
  8054. /*
  8055. * 122 四川
  8056. * 108 贵州
  8057. * 103 重庆
  8058. * 132 云南
  8059. */
  8060. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8061. //默认币种显示
  8062. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8063. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8064. return Ok(JsonView(true, "查询成功!", new
  8065. {
  8066. DraftNameDatas = draftNameDatas,
  8067. CurrencyData = _CurrencyData,
  8068. WordTypeData = wordTypeData,
  8069. ExcelTypeData = excelTypeData,
  8070. CurrencyInit = _currencyInfos,
  8071. ViewPermissionData = viewPermissionData
  8072. }));
  8073. }
  8074. /// <summary>
  8075. /// 团组模块 - 出入境费用-草稿
  8076. /// 实时汇率 tips
  8077. /// 机票费用 tips
  8078. /// </summary>
  8079. /// <returns></returns>
  8080. [HttpPost]
  8081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8082. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8083. {
  8084. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8085. return Ok(JsonView(true, "查询成功!", new
  8086. {
  8087. //GroupNameData = groupNameData.Data,
  8088. //visaData = visaData.Data,
  8089. //airData = airData.Data,
  8090. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8091. }));
  8092. }
  8093. /// <summary>
  8094. /// 团组模块 - 出入境费用-草稿
  8095. /// 签证费用 tips
  8096. /// </summary>
  8097. /// <returns></returns>
  8098. [HttpPost]
  8099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8100. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8101. {
  8102. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8103. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8104. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8105. .Select(x => x.NationalTravelFeeId)
  8106. .Distinct()
  8107. .ToListAsync();
  8108. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8109. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8110. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8111. .Select(x => x.Country)
  8112. .Distinct()
  8113. .ToArrayAsync();
  8114. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8115. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8116. return Ok(JsonView(true, "查询成功!", new
  8117. {
  8118. totalAmt = totalAmt,
  8119. remark = remark
  8120. }));
  8121. }
  8122. /// <summary>
  8123. /// 团组模块 - 出入境费用-草稿 - Info
  8124. /// </summary>
  8125. /// <returns></returns>
  8126. [HttpPost]
  8127. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8129. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8130. {
  8131. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8132. }
  8133. /// <summary>
  8134. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8135. /// </summary>
  8136. /// <returns></returns>
  8137. [HttpPost]
  8138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8139. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8140. {
  8141. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8142. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8143. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8144. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8145. foreach (var userId in dto.UserIds)
  8146. {
  8147. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8148. }
  8149. if (permissions.Any())
  8150. {
  8151. _sqlSugar.BeginTran();
  8152. try
  8153. {
  8154. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8155. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8156. if (result < 1)
  8157. {
  8158. _sqlSugar.RollbackTran();
  8159. return Ok(JsonView(false));
  8160. }
  8161. }
  8162. catch (Exception ex)
  8163. {
  8164. _sqlSugar.RollbackTran();
  8165. return Ok(JsonView(false, ex.Message));
  8166. }
  8167. _sqlSugar.CommitTran();
  8168. return Ok(JsonView(true));
  8169. }
  8170. return Ok(JsonView(false));
  8171. }
  8172. /// <summary>
  8173. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8174. /// </summary>
  8175. /// <returns></returns>
  8176. [HttpPost]
  8177. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8179. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8180. {
  8181. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8182. if (data.Code != 0)
  8183. {
  8184. return Ok(JsonView(false, data.Msg));
  8185. }
  8186. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8187. //汇率信息记录
  8188. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8189. return Ok(JsonView(true, data.Msg, data.Data));
  8190. }
  8191. /// <summary>
  8192. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8193. /// </summary>
  8194. /// <param name="dto"></param>
  8195. /// <returns></returns>
  8196. [HttpPost]
  8197. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8199. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8200. {
  8201. try
  8202. {
  8203. var id = dto.Id;
  8204. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8205. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8206. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8207. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8208. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8209. 3 团组成员名单 1 团组成员名单", ""));
  8210. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8211. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8212. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8213. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8214. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8215. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8216. //数据源
  8217. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8218. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8219. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8220. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8221. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8222. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8223. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8224. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8225. .Select((x, a, b) => new
  8226. {
  8227. x.Index,
  8228. itemName = a.Name,
  8229. CurrencyStr = b.Name,
  8230. x.Cost,
  8231. x.SubTotal,
  8232. x.Remark
  8233. })
  8234. .OrderBy((x) => x.Index)
  8235. .ToList(); //其他款项费用
  8236. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8237. var peiceItemCurrencys = new List<string>();
  8238. if (_DayAndCosts.Any())
  8239. {
  8240. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8241. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8242. }
  8243. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8244. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8245. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8246. {
  8247. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8248. }
  8249. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8250. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8251. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8252. if (dto.ExportType == 1) //明细表
  8253. {
  8254. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8255. {
  8256. //获取模板
  8257. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8258. //载入模板
  8259. Document doc = new Document(tempPath);
  8260. DocumentBuilder builder = new DocumentBuilder(doc);
  8261. //利用键值对存放数据
  8262. Dictionary<string, string> dic = new Dictionary<string, string>();
  8263. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8264. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8265. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8266. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8267. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8268. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8269. //境内费用(其他费用)
  8270. if (_EnterExitCosts.ChoiceOne == 1)
  8271. {
  8272. string row1_1 = "";
  8273. if (_EnterExitCosts.Visa > 0)
  8274. {
  8275. //insidePayTotal += _EnterExitCosts.Visa;
  8276. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8277. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8278. //{
  8279. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8280. //}
  8281. }
  8282. string row1_2 = "";
  8283. if (_EnterExitCosts.YiMiao > 0)
  8284. {
  8285. //insidePayTotal += _EnterExitCosts.YiMiao;
  8286. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8287. }
  8288. if (_EnterExitCosts.HeSuan > 0)
  8289. {
  8290. //insidePayTotal += _EnterExitCosts.HeSuan;
  8291. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8292. }
  8293. if (_EnterExitCosts.Service > 0)
  8294. {
  8295. //insidePayTotal += _EnterExitCosts.Service;
  8296. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8297. }
  8298. string row1_3 = "";
  8299. if (_EnterExitCosts.Safe > 0)
  8300. {
  8301. //insidePayTotal += _EnterExitCosts.Safe;
  8302. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8303. }
  8304. if (_EnterExitCosts.Ticket > 0)
  8305. {
  8306. //insidePayTotal += _EnterExitCosts.Ticket;
  8307. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8308. }
  8309. string row1 = "";
  8310. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8311. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8312. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8313. row1 += $"备注:{_EnterExitCosts.Remark}";
  8314. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8315. dic.Add("Row1Str", row1);
  8316. }
  8317. string airTotalStr = string.Empty,
  8318. airPriceStr = string.Empty;
  8319. //经济舱
  8320. if (_EnterExitCosts.SumJJC == 1)
  8321. {
  8322. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8323. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8324. }
  8325. //公务舱
  8326. if (_EnterExitCosts.SumGWC == 1)
  8327. {
  8328. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8329. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8330. }
  8331. //头等舱
  8332. if (_EnterExitCosts.SumTDC == 1)
  8333. {
  8334. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8335. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8336. }
  8337. //汇率描述
  8338. string rateStr = "";
  8339. if (peiceItemCurrencyInfos.Any())
  8340. {
  8341. rateStr = "\r\n汇率描述:";
  8342. foreach (var item in peiceItemCurrencyInfos)
  8343. {
  8344. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8345. }
  8346. }
  8347. string twoItemRemark = "备注:";
  8348. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8349. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8350. dic.Add("AirTotalStr", airTotalStr);
  8351. dic.Add("AirPriceStr", airPriceStr);
  8352. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8353. dic.Add("TwoItemRemark", twoItemRemark);
  8354. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8355. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8356. int table1Row = 0,
  8357. table2Row = 0,
  8358. table3Row = 0,
  8359. table4Row = 0,
  8360. table5Row = 0;
  8361. //住宿费
  8362. if (_EnterExitCosts.ChoiceThree == 1)
  8363. {
  8364. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8365. table1Row = dac1.Count;
  8366. #region 填充word表格内容
  8367. for (int i = 0; i < dac1.Count; i++)
  8368. {
  8369. var dac = dac1[i];
  8370. if (dac == null) continue;
  8371. builder.MoveToCell(0, i, 0, 0);
  8372. builder.Write("第" + dac.Days.ToString() + "晚:");
  8373. builder.MoveToCell(0, i, 1, 0);
  8374. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8375. //builder.Write(dac.Place == null ? "" : dac.Place);
  8376. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8377. builder.MoveToCell(0, i, 2, 0);
  8378. builder.Write("费用标准:");
  8379. string curr = "";
  8380. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8381. if (currData != null)
  8382. {
  8383. curr = currData.Name;
  8384. }
  8385. builder.MoveToCell(0, i, 3, 0);
  8386. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8387. builder.MoveToCell(0, i, 4, 0);
  8388. builder.Write("费用小计:");
  8389. builder.MoveToCell(0, i, 5, 0);
  8390. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8391. }
  8392. #endregion
  8393. }
  8394. else dic.Add("SubZS", "0.00");
  8395. //删除多余行
  8396. while (table1.Rows.Count > table1Row)
  8397. {
  8398. table1.Rows.RemoveAt(table1Row);
  8399. }
  8400. //伙食费
  8401. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8402. if (_EnterExitCosts.ChoiceFour == 1)
  8403. {
  8404. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8405. table2Row = dac2.Count;
  8406. #region 填充word表格内容
  8407. for (int i = 0; i < dac2.Count; i++)
  8408. {
  8409. var dac = dac2[i];
  8410. if (dac == null) continue;
  8411. builder.MoveToCell(1, i, 0, 0);
  8412. builder.Write("第" + dac.Days.ToString() + "天:");
  8413. builder.MoveToCell(1, i, 1, 0);
  8414. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8415. builder.MoveToCell(1, i, 2, 0);
  8416. builder.Write("费用标准:");
  8417. string curr = "";
  8418. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8419. if (currData != null)
  8420. {
  8421. curr = currData.Name;
  8422. }
  8423. builder.MoveToCell(1, i, 3, 0);
  8424. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8425. builder.MoveToCell(1, i, 4, 0);
  8426. builder.Write("费用小计:");
  8427. builder.MoveToCell(1, i, 5, 0);
  8428. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8429. }
  8430. #endregion
  8431. }
  8432. else dic.Add("SubHS", "0.00");
  8433. //删除多余行
  8434. while (table2.Rows.Count > table2Row)
  8435. {
  8436. table2.Rows.RemoveAt(table2Row);
  8437. }
  8438. //公杂费
  8439. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8440. if (_EnterExitCosts.ChoiceFive == 1)
  8441. {
  8442. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8443. table3Row = dac3.Count;
  8444. #region 填充word表格内容
  8445. for (int i = 0; i < dac3.Count; i++)
  8446. {
  8447. var dac = dac3[i];
  8448. if (dac == null) continue;
  8449. builder.MoveToCell(2, i, 0, 0);
  8450. builder.Write("第" + dac.Days.ToString() + "天:");
  8451. builder.MoveToCell(2, i, 1, 0);
  8452. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8453. builder.MoveToCell(2, i, 2, 0);
  8454. builder.Write("费用标准:");
  8455. string curr = "";
  8456. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8457. if (currData != null)
  8458. {
  8459. curr = currData.Name;
  8460. }
  8461. builder.MoveToCell(2, i, 3, 0);
  8462. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8463. builder.MoveToCell(2, i, 4, 0);
  8464. builder.Write("费用小计:");
  8465. builder.MoveToCell(2, i, 5, 0);
  8466. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8467. }
  8468. //删除多余行
  8469. while (table3.Rows.Count > table3Row)
  8470. {
  8471. table3.Rows.RemoveAt(table3Row);
  8472. }
  8473. #endregion
  8474. }
  8475. else dic.Add("SubGZF", "0.00");
  8476. //删除多余行
  8477. while (table3.Rows.Count > table3Row)
  8478. {
  8479. table3.Rows.RemoveAt(table3Row);
  8480. }
  8481. //培训费
  8482. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8483. if (_EnterExitCosts.ChoiceSix == 1)
  8484. {
  8485. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8486. dic.Add("SubPX", pxStr);
  8487. table4Row = dac4.Count;
  8488. #region 填充word表格内容
  8489. for (int i = 0; i < dac4.Count; i++)
  8490. {
  8491. var dac = dac4[i];
  8492. if (dac == null) continue;
  8493. builder.MoveToCell(3, i, 0, 0);
  8494. builder.Write("第" + dac.Days.ToString() + "天:");
  8495. builder.MoveToCell(3, i, 1, 0);
  8496. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8497. builder.MoveToCell(3, i, 2, 0);
  8498. builder.Write("费用标准:");
  8499. string curr = "";
  8500. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8501. if (currData != null)
  8502. {
  8503. curr = currData.Name;
  8504. }
  8505. builder.MoveToCell(3, i, 3, 0);
  8506. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8507. builder.MoveToCell(3, i, 4, 0);
  8508. builder.Write("费用小计:");
  8509. builder.MoveToCell(3, i, 5, 0);
  8510. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8511. }
  8512. #endregion
  8513. }
  8514. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8515. //删除多余行
  8516. while (table4.Rows.Count > table4Row)
  8517. {
  8518. table4.Rows.RemoveAt(table4Row);
  8519. }
  8520. //其他费用
  8521. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8522. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8523. {
  8524. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8525. dic.Add("titleQi", qtStr);
  8526. table5Row = dac5.Count;
  8527. #region 填充word表格内容
  8528. for (int i = 0; i < dac5.Count; i++)
  8529. {
  8530. var dac = dac5[i];
  8531. if (dac == null) continue;
  8532. builder.MoveToCell(4, i, 0, 0);
  8533. builder.Write("第" + dac.Index.ToString() + "项:");
  8534. builder.MoveToCell(4, i, 1, 0);
  8535. builder.Write(dac.itemName);
  8536. builder.MoveToCell(4, i, 2, 0);
  8537. builder.Write("费用标准:");
  8538. builder.MoveToCell(4, i, 3, 0);
  8539. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8540. builder.MoveToCell(4, i, 4, 0);
  8541. builder.Write("费用小计:");
  8542. builder.MoveToCell(4, i, 5, 0);
  8543. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8544. builder.MoveToCell(4, i, 6, 0);
  8545. builder.Write("备注:");
  8546. builder.MoveToCell(4, i, 7, 0);
  8547. builder.Write(dac.Remark);
  8548. }
  8549. #endregion
  8550. }
  8551. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8552. //删除多余行
  8553. while (table5.Rows.Count > table5Row)
  8554. {
  8555. table5.Rows.RemoveAt(table5Row);
  8556. }
  8557. //加上其他费用
  8558. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8559. decimal subJJC = 0.00M,
  8560. subGWC = 0.00M,
  8561. subTDC = 0.00M;
  8562. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8563. string totalLabel = string.Format("全部费用总计:");
  8564. //经济舱
  8565. if (_EnterExitCosts.SumJJC == 1)
  8566. {
  8567. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8568. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8569. }
  8570. //公务舱
  8571. if (_EnterExitCosts.SumGWC == 1)
  8572. {
  8573. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8574. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8575. }
  8576. //头等舱
  8577. if (_EnterExitCosts.SumTDC == 1)
  8578. {
  8579. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8580. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8581. }
  8582. //TotalLabel
  8583. dic.Add("TotalLabel", totalLabel);
  8584. #region 填充word模板书签内容
  8585. foreach (var key in dic.Keys)
  8586. {
  8587. Bookmark bookmark = doc.Range.Bookmarks[key];
  8588. if (bookmark != null)
  8589. {
  8590. builder.MoveToBookmark(key);
  8591. builder.Write(dic[key]);
  8592. }
  8593. }
  8594. #endregion
  8595. //文件名
  8596. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8597. strFileName = CommonFun.ValidFileName(strFileName);
  8598. AsposeHelper.removewatermark_v2180();
  8599. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8600. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8601. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8602. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8603. }
  8604. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8605. {
  8606. //获取模板
  8607. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8608. //载入模板
  8609. Document doc = new Document(tempPath);
  8610. DocumentBuilder builder = new DocumentBuilder(doc);
  8611. Dictionary<string, string> dic = new Dictionary<string, string>();
  8612. string returnCodeLabel = string.Empty;
  8613. if (nationalTravelFeeData.Any())
  8614. {
  8615. List<string> list = new List<string>();
  8616. foreach (var item in nationalTravelFeeData)
  8617. {
  8618. list.Add($"{item.Country}({item.City})");
  8619. }
  8620. list = list.Distinct().ToList();
  8621. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8622. }
  8623. var countryLabel = string.Empty;
  8624. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8625. if (countryData.Any())
  8626. {
  8627. countryLabel = string.Join("、", countryData);
  8628. }
  8629. dic.Add("ReturnCodeAir", returnCodeLabel);
  8630. dic.Add("VisitStartDate", "-");
  8631. dic.Add("VisitEndDate", "-");
  8632. dic.Add("Day", "-");
  8633. dic.Add("VisitCountry", countryLabel);
  8634. dic.Add("ClientUnit", "-");
  8635. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8636. //dic.Add("Names", Names);
  8637. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8638. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8639. decimal dac1totalPrice = 0.00M;
  8640. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8641. foreach (var dac in dac1)
  8642. {
  8643. if (dac.SubTotal == 0.00M)
  8644. {
  8645. continue;
  8646. }
  8647. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8648. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8649. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8650. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8651. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8652. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8653. builder.Write(currency);//币种
  8654. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8655. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8656. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8657. builder.Write("");//人数
  8658. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8659. builder.Write("");//天数
  8660. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8661. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8662. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8663. decimal rate = 0.00M;
  8664. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8665. builder.Write(rate.ToString("#0.0000"));//汇率
  8666. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8667. decimal rbmPrice = dac.SubTotal;
  8668. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8669. accommodationStartIndex++;
  8670. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8671. }
  8672. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8673. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8674. {
  8675. table1.Rows.RemoveAt(i - 1);
  8676. foodandotherStartIndex--;
  8677. }
  8678. if (dac2.Count == dac3.Count)//国家 币种 金额
  8679. {
  8680. for (int i = 0; i < dac2.Count; i++)
  8681. {
  8682. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8683. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8684. }
  8685. }
  8686. decimal dac2totalPrice = 0.00M;
  8687. foreach (var dac in dac2)
  8688. {
  8689. if (dac.SubTotal == 0)
  8690. {
  8691. continue;
  8692. }
  8693. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8694. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8695. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8696. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8697. builder.Write(currency);//币种
  8698. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8699. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8700. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8701. builder.Write("");//人数
  8702. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8703. builder.Write("");//天数
  8704. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8705. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8706. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8707. decimal rate = 0.00M;
  8708. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8709. builder.Write(rate.ToString("#0.0000"));//汇率
  8710. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8711. decimal rbmPrice = dac.SubTotal;
  8712. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8713. foodandotherStartIndex++;
  8714. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8715. }
  8716. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8717. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8718. {
  8719. table1.Rows.RemoveAt(i - 1);
  8720. }
  8721. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8722. string otherFeeStr = "";
  8723. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8724. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8725. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8726. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8727. foreach (var otherInfo in dac5)
  8728. {
  8729. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8730. }
  8731. #endregion
  8732. if (otherFeeStr.Length > 0)
  8733. {
  8734. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8735. otherFeeStr = $"({otherFeeStr})";
  8736. dic.Add("OtherFeeStr", otherFeeStr);
  8737. }
  8738. //总计
  8739. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8740. //国际旅费
  8741. string outsideAir = string.Empty;
  8742. string allPriceAir = string.Empty;
  8743. if (_EnterExitCosts.SumJJC == 1)
  8744. {
  8745. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8746. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8747. }
  8748. if (_EnterExitCosts.SumGWC == 1)
  8749. {
  8750. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8751. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8752. }
  8753. if (_EnterExitCosts.SumTDC == 1)
  8754. {
  8755. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8756. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8757. }
  8758. dic.Add("InTravelPrice", $"({outsideAir})");
  8759. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8760. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8761. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8762. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8763. foreach (var key in dic.Keys)
  8764. {
  8765. builder.MoveToBookmark(key);
  8766. builder.Write(dic[key]);
  8767. }
  8768. //模板文件名
  8769. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8770. strFileName = CommonFun.ValidFileName(strFileName);
  8771. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8772. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8773. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8774. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8775. }
  8776. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8777. {
  8778. //获取模板
  8779. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8780. //载入模板
  8781. WorkbookDesigner designer = new WorkbookDesigner();
  8782. designer.Workbook = new Workbook(tempPath);
  8783. Dictionary<string, string> dic = new Dictionary<string, string>();
  8784. string returnCodeLabel = string.Empty;
  8785. if (nationalTravelFeeData.Any())
  8786. {
  8787. List<string> list = new List<string>();
  8788. foreach (var item in nationalTravelFeeData)
  8789. {
  8790. list.Add($"{item.Country}({item.City})");
  8791. }
  8792. list = list.Distinct().ToList();
  8793. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8794. }
  8795. var countryLabel = string.Empty;
  8796. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8797. if (countryData.Any())
  8798. {
  8799. countryLabel = string.Join("、", countryData);
  8800. }
  8801. dic.Add("ReturnCodeAir", returnCodeLabel);
  8802. dic.Add("VisitStartDate", "-");
  8803. dic.Add("VisitEndDate", "-");
  8804. dic.Add("Day", "0");
  8805. dic.Add("VisitCountry", countryLabel);
  8806. dic.Add("ClientUnit", "-");
  8807. designer.SetDataSource("ClientUnit", "-");
  8808. designer.SetDataSource("VisitCountry", countryLabel);
  8809. designer.SetDataSource("Group", "-");
  8810. designer.SetDataSource("ClientUnitTitle", "-");
  8811. designer.SetDataSource("Name", "-");
  8812. designer.SetDataSource("VisitStartDate", "-");
  8813. designer.SetDataSource("Day", "0");
  8814. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8815. designer.SetDataSource("ReturnCodeAir", "-");
  8816. int startIndex = 10;
  8817. const int startIndexcopy = 10;
  8818. if (dac2.Count == dac3.Count)//国家 币种 金额
  8819. {
  8820. for (int i = 0; i < dac2.Count; i++)
  8821. {
  8822. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8823. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8824. }
  8825. }
  8826. DataTable dtdac1 = new DataTable();
  8827. List<string> place = new List<string>();
  8828. dtdac1.Columns.AddRange(new DataColumn[] {
  8829. new DataColumn(){ ColumnName = "city"},
  8830. new DataColumn(){ ColumnName = "curr"},
  8831. new DataColumn(){ ColumnName = "criterion"},
  8832. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8833. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8834. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8835. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8836. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8837. });
  8838. DataTable dtdac2 = new DataTable();
  8839. dtdac2.Columns.AddRange(new DataColumn[] {
  8840. new DataColumn(){ ColumnName = "city"},
  8841. new DataColumn(){ ColumnName = "curr"},
  8842. new DataColumn(){ ColumnName = "criterion"},
  8843. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8844. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8845. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8846. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8847. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8848. });
  8849. dtdac1.TableName = "tb1";
  8850. dtdac2.TableName = "tb2";
  8851. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8852. foreach (var item in dac1)
  8853. {
  8854. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8855. if (place.Contains(item.Place))
  8856. {
  8857. continue;
  8858. }
  8859. DataRow row = dtdac1.NewRow();
  8860. row["city"] = item.Place;
  8861. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8862. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8863. row["curr"] = currency;
  8864. row["rate"] = rate.ToString("#0.0000");
  8865. row["criterion"] = item.Cost.ToString("#0.00");
  8866. row["number"] = 1;
  8867. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8868. //row["costRMB"] = rbmPrice;
  8869. dtdac1.Rows.Add(row);
  8870. place.Add(item.Place);
  8871. }
  8872. place = new List<string>();
  8873. foreach (var item in dac2)
  8874. {
  8875. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8876. if (place.Contains(item.Place))
  8877. {
  8878. continue;
  8879. }
  8880. DataRow row = dtdac2.NewRow();
  8881. row["city"] = item.Place;
  8882. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8883. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8884. row["curr"] = currency;
  8885. row["rate"] = rate.ToString("#0.0000");
  8886. row["criterion"] = item.Cost.ToString("#0.00");
  8887. row["number"] = 1;
  8888. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8889. //row["cost"] = item.SubTotal;
  8890. //row["costRMB"] = rbmPrice;
  8891. dtdac2.Rows.Add(row);
  8892. place.Add(item.Place);
  8893. //dac2totalPrice += rbmPrice;
  8894. }
  8895. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8896. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8897. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8898. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8899. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8900. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8901. string cell4Str1 = string.Empty;
  8902. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8903. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8904. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8905. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8906. string cellStr = $" 5.其他费用(";
  8907. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8908. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8909. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8910. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8911. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8912. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8913. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8914. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8915. foreach (var otherInfo in dac5)
  8916. {
  8917. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8918. }
  8919. #endregion
  8920. if (cellStr.Length > 8)
  8921. {
  8922. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8923. }
  8924. cellStr += ")";
  8925. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8926. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8927. decimal pxFee = dac4.Sum(it => it.Cost);
  8928. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8929. string celllastStr1 = "";
  8930. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8931. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8932. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8933. celllastStr1 += $",国际旅费 元";
  8934. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8935. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8936. designer.SetDataSource("cell4Str", cell4Str);
  8937. designer.SetDataSource("cellStr", cellStr);
  8938. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8939. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8940. designer.SetDataSource("celllastStr", celllastStr);
  8941. Workbook wb = designer.Workbook;
  8942. var sheet = wb.Worksheets[0];
  8943. //绑定datatable数据集
  8944. designer.SetDataSource(dtdac1);
  8945. designer.SetDataSource(dtdac2);
  8946. designer.Process();
  8947. var rowStart = dtdac1.Rows.Count;
  8948. while (rowStart > 0)
  8949. {
  8950. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8951. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8952. startIndex++;
  8953. rowStart--;
  8954. }
  8955. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8956. startIndex += 1; //总计行
  8957. rowStart = dtdac2.Rows.Count;
  8958. while (rowStart > 0)
  8959. {
  8960. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8961. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8962. startIndex++;
  8963. rowStart--;
  8964. }
  8965. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8966. wb.CalculateFormula(true);
  8967. //模板文件名
  8968. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8969. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8971. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8972. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8973. }
  8974. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8975. {
  8976. //获取模板
  8977. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8978. //载入模板
  8979. Document doc = new Document(tempPath);
  8980. DocumentBuilder builder = new DocumentBuilder(doc);
  8981. Dictionary<string, string> dic = new Dictionary<string, string>();
  8982. dic.Add("GroupName", "-");
  8983. dic.Add("ClientUnit", "-");
  8984. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8985. //string missionLeaderJob = "";//负责人job
  8986. //int groupNumber = 0; //团人数
  8987. dic.Add("MissionLeader", "-"); //团负责人
  8988. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8989. dic.Add("GroupNumber", "0"); //团人数
  8990. dic.Add("Day", "0");
  8991. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8992. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8993. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8994. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8995. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8996. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8997. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8998. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8999. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  9000. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  9001. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  9002. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9003. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9004. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9005. //其他费用
  9006. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9007. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9008. //其他费用合计
  9009. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9010. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9011. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9012. //公务舱合计
  9013. //国际旅费
  9014. //string outsideJJ = "";
  9015. //string allPriceJJ = "";
  9016. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9017. {
  9018. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9019. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9020. }
  9021. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9022. {
  9023. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9024. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9025. }
  9026. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9027. {
  9028. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9029. dic.Add("AirFeeTotal", airFeeTotalStr);
  9030. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9031. dic.Add("FeeTotal", feeTotalStr);
  9032. }
  9033. foreach (var key in dic.Keys)
  9034. {
  9035. builder.MoveToBookmark(key);
  9036. builder.Write(dic[key]);
  9037. }
  9038. //模板文件名
  9039. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9040. strFileName = CommonFun.ValidFileName(strFileName);
  9041. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9042. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9043. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9044. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9045. }
  9046. }
  9047. else if (dto.ExportType == 2) //表格
  9048. {
  9049. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9050. }
  9051. else if (dto.ExportType == 3)
  9052. {
  9053. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9054. }
  9055. return Ok(JsonView(400, "只可导出明细表!", ""));
  9056. }
  9057. catch (Exception ex)
  9058. {
  9059. return Ok(JsonView(400, ex.Message, ""));
  9060. }
  9061. }
  9062. /// <summary>
  9063. /// 获取三公费用标准city
  9064. /// </summary>
  9065. /// <param name="placeData"></param>
  9066. /// <param name="nationalTravelFeeId"></param>
  9067. /// <returns></returns>
  9068. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9069. {
  9070. string _city = string.Empty;
  9071. if (!placeData.Any()) return _city;
  9072. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9073. if (data == null) return _city;
  9074. string country = data.Country;
  9075. string city = data.City;
  9076. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9077. else _city = city;
  9078. return _city;
  9079. }
  9080. /// <summary>
  9081. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9082. /// </summary>
  9083. /// <returns></returns>
  9084. [HttpPost]
  9085. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9087. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9088. {
  9089. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9090. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9091. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9092. if (_view.Code == 0)
  9093. {
  9094. return Ok(JsonView(true, "操作成功"));
  9095. }
  9096. return Ok(JsonView(false, "操作失败"));
  9097. }
  9098. /// <summary>
  9099. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9100. /// </summary>
  9101. /// <returns></returns>
  9102. [HttpPost]
  9103. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9105. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9106. {
  9107. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9108. if (data.Code != 0)
  9109. {
  9110. return Ok(JsonView(false, data.Msg));
  9111. }
  9112. return Ok(JsonView(true, "操作成功!", data.Data));
  9113. }
  9114. /// <summary>
  9115. /// 三公其他费用草稿 删除
  9116. /// </summary>
  9117. /// <param name="dto"></param>
  9118. /// <returns></returns>
  9119. [HttpPost]
  9120. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9121. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9122. {
  9123. var jw = JsonView(false, "删除失败!");
  9124. var data = new Grp_DayOtherPriceDraft()
  9125. {
  9126. Id = dto.Id,
  9127. IsDel = 1,
  9128. DeleteUserId = dto.DeleteUserId,
  9129. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9130. };
  9131. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9132. if (del > 0)
  9133. {
  9134. jw.Code = 200;
  9135. jw.Msg = "删除成功!";
  9136. }
  9137. return Ok(jw);
  9138. }
  9139. /// <summary>
  9140. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9141. /// </summary>
  9142. /// <returns></returns>
  9143. [HttpPost]
  9144. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9145. {
  9146. var jw = JsonView(false);
  9147. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9148. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9149. jw.Code = StatusCodes.Status200OK;
  9150. jw.Msg = "操作成功!";
  9151. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9152. return Ok(jw);
  9153. }
  9154. /// <summary>
  9155. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9156. /// </summary>
  9157. /// <param name="dto"></param>
  9158. /// <returns></returns>
  9159. [HttpPost]
  9160. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9161. {
  9162. int userId = dto.UserId,
  9163. portId = dto.PortType,
  9164. groupId = dto.GroupId,
  9165. draftId = dto.DraftId;
  9166. _portTypeData.Add(1);
  9167. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9168. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9169. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9170. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9171. _sqlSugar.BeginTran();
  9172. try
  9173. {
  9174. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9175. if (draftDatas == null)
  9176. {
  9177. _sqlSugar.RollbackTran();
  9178. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9179. }
  9180. //验证可覆盖已有数据 两边创建人需为同一人;
  9181. int draftCreateUserId = draftDatas.CreateUserId,
  9182. formalCreateUserId = 0;
  9183. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9184. if (formalData != null)
  9185. {
  9186. formalCreateUserId = formalData.CreateUserId;
  9187. if (draftCreateUserId != formalCreateUserId)
  9188. {
  9189. _sqlSugar.RollbackTran();
  9190. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9191. }
  9192. }
  9193. //默认添加查看、编辑权限(创建人、自己)
  9194. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9195. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9196. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9197. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9198. newExterData.DiId = groupId;
  9199. newExterData.CreateUserId = userId;
  9200. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9201. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9202. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9203. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9204. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9205. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9206. //数据如果存在执行删除
  9207. if (enterExitCostInfo != null)
  9208. {
  9209. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9210. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9211. .Where(x => x.Id == enterExitCostInfo.Id)
  9212. .ExecuteCommand();
  9213. _sqlSugar.Updateable<Grp_DayAndCost>()
  9214. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9215. .Where(x => x.DiId == groupId)
  9216. .ExecuteCommand();
  9217. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9218. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9219. .Where(x => x.Diid == groupId)
  9220. .ExecuteCommand();
  9221. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9222. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9223. .Where(x => x.GroupId == groupId)
  9224. .ExecuteCommand();
  9225. }
  9226. //执行insert
  9227. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9228. if (insertId < 1)
  9229. {
  9230. _sqlSugar.RollbackTran();
  9231. return Ok(JsonView(false, "草稿数据导入失败!"));
  9232. }
  9233. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9234. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9235. #region 默认添加权限
  9236. #endregion
  9237. _sqlSugar.CommitTran();
  9238. //执行操作之后
  9239. //生成默认文件pdf并且通知人员
  9240. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9241. {
  9242. DiId = groupId,
  9243. ExportType = 1,
  9244. SubTypeId = 1005
  9245. }, "pdf");
  9246. //发送通知
  9247. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9248. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9249. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9250. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9251. //汇率信息记录
  9252. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9253. return Ok(JsonView(true));
  9254. }
  9255. catch (Exception ex)
  9256. {
  9257. _sqlSugar.RollbackTran();
  9258. return Ok(JsonView(false, ex.Message));
  9259. }
  9260. }
  9261. #endregion
  9262. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9263. /// <summary>
  9264. /// 获取币种基础数据(含逻辑处理)
  9265. /// </summary>
  9266. /// <returns></returns>
  9267. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9268. {
  9269. return await GeneralMethod.EnterExitCostInitRate();
  9270. }
  9271. /// <summary>
  9272. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9273. /// </summary>
  9274. /// <returns></returns>
  9275. [HttpPost]
  9276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9277. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9278. {
  9279. //验证城市归属并给默认值
  9280. int provinceId = dto.ProvinceId;
  9281. if (provinceId < 1) provinceId = 122;
  9282. var dataSource = await _sqlSugar
  9283. .Queryable<Sys_SetData>()
  9284. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9285. .ToListAsync();
  9286. var fileTypes = new List<EecSetDataInfoView>();
  9287. //三公费用-Word明细类型
  9288. var wordTypeData = dataSource
  9289. .Where(it => it.STid == 72)
  9290. .Select(x => new EecSetDataInfoView
  9291. {
  9292. ParentId = 1,
  9293. Id = x.Id,
  9294. Name = x.Name
  9295. })
  9296. .ToArray();
  9297. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9298. var excelTypeData = dataSource
  9299. .Where(it => it.STid == 73)
  9300. .Select(x => new EecSetDataInfoView
  9301. {
  9302. ParentId = 2,
  9303. Id = x.Id,
  9304. Name = x.Name
  9305. })
  9306. .ToArray();
  9307. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9308. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9309. fileTypes.Add(groupNameList);
  9310. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9311. //默认币种显示
  9312. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9313. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9314. return Ok(JsonView(true, "查询成功!", new
  9315. {
  9316. FileTypeData = fileTypes,
  9317. CurrencyInit = _currencyInfos,
  9318. viewPermissionData = viewPermissionData
  9319. }));
  9320. }
  9321. /// <summary>
  9322. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9323. /// </summary>
  9324. /// <returns></returns>
  9325. [HttpPost]
  9326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9327. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9328. {
  9329. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9331. RefAsync<int> total = 0;
  9332. int diId = 0;
  9333. var status = int.TryParse(dto.GroupName, out diId);
  9334. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9335. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9336. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9337. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9338. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9339. .OrderByDescending(x => x.VisitStartDate)
  9340. .Select(x => new EnterExitCostMobileGroupView()
  9341. {
  9342. Id = x.Id,
  9343. GroupName = x.TeamName,
  9344. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9345. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9346. ProvinceId = x.CityId
  9347. })
  9348. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9349. //处理省份Id
  9350. if (data.Any())
  9351. {
  9352. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9353. if (provCityDatas.Any())
  9354. {
  9355. foreach (var item in data)
  9356. {
  9357. var provinceId = item.ProvinceId;
  9358. var isDefualtVal = true;
  9359. if (provinceId > 0)
  9360. {
  9361. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9362. if (parentId != null)
  9363. {
  9364. isDefualtVal = false;
  9365. item.ProvinceId = (int)parentId;
  9366. }
  9367. }
  9368. if (isDefualtVal)
  9369. {
  9370. item.ProvinceId = 122; //默认四川
  9371. }
  9372. }
  9373. }
  9374. }
  9375. //处理是否显示
  9376. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9377. {
  9378. foreach (var item in data)
  9379. {
  9380. item.IsView = true;
  9381. }
  9382. }
  9383. return Ok(JsonView(true, "查询成功!", data, total));
  9384. }
  9385. /// <summary>
  9386. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9387. /// </summary>
  9388. /// <returns></returns>
  9389. [HttpPost]
  9390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9391. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9392. {
  9393. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9394. RefAsync<int> total = 0;
  9395. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9396. .Where(x => x.IsDel == 0 && x.STid == 66)
  9397. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9398. .Select(x => new
  9399. {
  9400. id = x.Id,
  9401. name = x.Name,
  9402. remark = x.Remark,
  9403. })
  9404. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9405. return Ok(JsonView(true, "查询成功!", data, total));
  9406. }
  9407. /// <summary>
  9408. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9409. /// </summary>
  9410. /// <returns></returns>
  9411. [HttpPost]
  9412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9413. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9414. {
  9415. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9416. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9417. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9418. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9419. var groupOtherRateData = groupRateData.TeamRates;
  9420. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9421. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9422. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9423. groupOtherRateData = groupOtherRateData
  9424. .Select(x => new TeamRateDescAddCurrencyIdView
  9425. {
  9426. CurrencyId = x.CurrencyId,
  9427. CurrencyName = x.CurrencyName,
  9428. CurrencyCode = x.CurrencyCode,
  9429. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9430. }).ToList();
  9431. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9432. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9433. }
  9434. /// <summary>
  9435. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9436. /// </summary>
  9437. /// <returns></returns>
  9438. [HttpPost]
  9439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9440. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9441. {
  9442. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9443. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9444. var tipsData = new List<int>() { 1, 2, 3 };
  9445. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9446. if (dto.TipsType == 1)
  9447. {
  9448. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9449. }
  9450. else if (dto.TipsType == 2)
  9451. {
  9452. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9453. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9454. }
  9455. else if (dto.TipsType == 3)
  9456. {
  9457. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9458. return Ok(JsonView(true, "查询成功!", airData));
  9459. }
  9460. return Ok(JsonView(false));
  9461. }
  9462. /// <summary>
  9463. /// 团组模块 - 出入境国家费用标准-移动端 List
  9464. /// </summary>
  9465. /// <returns></returns>
  9466. [HttpPost]
  9467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9468. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9469. {
  9470. Stopwatch sw = new Stopwatch();
  9471. sw.Start();
  9472. int provinceId = dto.ProvinceId;
  9473. if (provinceId < 1) provinceId = 122; // 默认四川
  9474. RefAsync<int> total = 0;
  9475. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9476. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9477. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9478. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9479. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9480. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9481. .Select((ntf, sd, u, sd1) => new
  9482. {
  9483. Id = ntf.Id,
  9484. Area = $"{ntf.Country}-{ntf.City}",
  9485. Currency = ntf.Currency,
  9486. CurrencyCode = sd.Name,
  9487. CurrencyName = sd.Remark,
  9488. RoomCost = ntf.RoomCost,
  9489. FoodCost = ntf.FoodCost,
  9490. PublicCost = ntf.PublicCost,
  9491. TrainCost = ntf.TrainCost,
  9492. LastUpdateUserId = ntf.LastUpdateUserId,
  9493. LastUpdateUserName = u.CnName,
  9494. LastUpdateTime = ntf.LastUpdateTime
  9495. })
  9496. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9497. sw.Stop();
  9498. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9499. }
  9500. /// <summary>
  9501. /// 团组模块 - 出入境费用-移动端 - Info
  9502. /// </summary>
  9503. /// <returns></returns>
  9504. [HttpPost]
  9505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9506. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9507. {
  9508. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9509. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9510. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9511. return Ok(data);
  9512. }
  9513. /// <summary>
  9514. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9515. /// </summary>
  9516. /// <returns></returns>
  9517. [HttpPost]
  9518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9519. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9520. {
  9521. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9522. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9523. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9524. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9525. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9526. mobileInfo.DiId = dto.DiId;
  9527. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9528. if (eecInfo == null) return Ok(mobileInfo);
  9529. //验证查看权限
  9530. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9531. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9532. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9533. mobileInfo.IsAssignPerm = isSet;
  9534. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9535. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9536. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9537. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9538. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9539. {
  9540. SubId = dac.Id,
  9541. DiId = dac.DiId,
  9542. Type = dac.Type,
  9543. Days = dac.Days,
  9544. NationalTravelFeeId = dac.NationalTravelFeeId,
  9545. Arae = $"{ntf.Country}-{ntf.City}",
  9546. Cost = dac.Cost,
  9547. Currency = dac.Currency,
  9548. CurrencyName = sd.Name,
  9549. SubTotal = dac.SubTotal,
  9550. })
  9551. .ToList();
  9552. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9553. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9554. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9555. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9556. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9557. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9558. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9559. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9560. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9561. //其他款项
  9562. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9563. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9564. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9565. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9566. .OrderBy((dop, sd1, sd2) => dop.Index)
  9567. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9568. {
  9569. SubId = dop.Id,
  9570. DiId = dop.Diid,
  9571. Index = dop.Index,
  9572. SetDataId = dop.SetDataId,
  9573. SetDataName = sd1.Name,
  9574. Cost = dop.Cost,
  9575. Currency = dop.Currency,
  9576. CurrencyName = sd2.Remark,
  9577. SubTotal = dop.SubTotal,
  9578. Remark = dop.Remark,
  9579. })
  9580. .ToArray();
  9581. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9582. return Ok(mobileInfo);
  9583. }
  9584. /// <summary>
  9585. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9586. /// </summary>
  9587. /// <returns></returns>
  9588. [HttpPost]
  9589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9590. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9591. {
  9592. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9593. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9594. //验证查看权限
  9595. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9596. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9597. var userIds = await _sqlSugar
  9598. .Queryable<Grp_EnterExitCostPermission>()
  9599. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9600. .Select(x => x.UserId)
  9601. .ToArrayAsync();
  9602. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9603. var perUsersView = new List<dynamic>();
  9604. foreach (var item in perUsers)
  9605. {
  9606. bool isView1 = false;
  9607. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9608. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9609. }
  9610. return Ok(JsonView(perUsersView));
  9611. }
  9612. /// <summary>
  9613. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9614. /// </summary>
  9615. /// <returns></returns>
  9616. [HttpPost]
  9617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9618. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9619. {
  9620. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9621. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9622. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9623. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9624. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9625. //验证查看权限
  9626. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9627. //if (!isView) return Ok(JsonView(false, msg));
  9628. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9629. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9630. var subType = dto.SubType;
  9631. if (subType == 1) //1:境内费用
  9632. {
  9633. var oneData = new ChoiceOneMobileSubInfoView()
  9634. {
  9635. Id = eecInfo.Id,
  9636. ChoiceOne = eecInfo.ChoiceOne,
  9637. ChoiceOneTotalCost = eecInfo.InsidePay,
  9638. Visa = eecInfo.Visa,
  9639. VisaRemark = eecInfo.VisaRemark,
  9640. YiMiao = eecInfo.YiMiao,
  9641. HeSuan = eecInfo.HeSuan,
  9642. Service = eecInfo.Service,
  9643. Ticket = eecInfo.Ticket,
  9644. Safe = eecInfo.Safe,
  9645. FirstItemRemark = eecInfo.FirstItemRemark
  9646. };
  9647. return Ok(JsonView(oneData));
  9648. }
  9649. else if (subType == 2) //2:国际旅费
  9650. {
  9651. var twoData = new ChoiceTwoMobileSubInfoView()
  9652. {
  9653. Id = eecInfo.Id,
  9654. ChoiceTwoJJ = eecInfo.SumJJC,
  9655. OutsideJJPay = eecInfo.OutsideJJPay,
  9656. ChoiceTwoGW = eecInfo.SumGWC,
  9657. OutsideGWPay = eecInfo.OutsideGWPay,
  9658. ChoiceTwoTD = eecInfo.SumTDC,
  9659. OutsideTDPay = eecInfo.OutsideTDPay,
  9660. AirJJ = eecInfo.AirJJ,
  9661. AirGW = eecInfo.AirGW,
  9662. AirTD = eecInfo.AirTD,
  9663. CityTranffic = eecInfo.CityTranffic,
  9664. TwoItemRemark = eecInfo.TwoItemRemark
  9665. };
  9666. return Ok(JsonView(twoData));
  9667. }
  9668. else if (subType == 3) //3:住宿费
  9669. {
  9670. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9671. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9672. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9673. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9674. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9675. {
  9676. SubId = dac.Id,
  9677. DiId = dac.DiId,
  9678. Type = dac.Type,
  9679. Days = dac.Days,
  9680. NationalTravelFeeId = dac.NationalTravelFeeId,
  9681. Arae = $"{ntf.Country}-{ntf.City}",
  9682. Cost = dac.Cost,
  9683. Currency = dac.Currency,
  9684. CurrencyName = sd.Name,
  9685. SubTotal = dac.SubTotal,
  9686. })
  9687. .ToArray();
  9688. var data = new ChoiceMobileSubInfo3To6View()
  9689. {
  9690. ParentId = eecInfo.Id,
  9691. Choice = eecInfo.ChoiceThree,
  9692. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9693. Details = dayAndCostDatas
  9694. };
  9695. return Ok(JsonView(data));
  9696. }
  9697. else if (subType == 4) //4:伙食费
  9698. {
  9699. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9700. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9701. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9702. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9703. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9704. {
  9705. SubId = dac.Id,
  9706. DiId = dac.DiId,
  9707. Type = dac.Type,
  9708. Days = dac.Days,
  9709. NationalTravelFeeId = dac.NationalTravelFeeId,
  9710. Arae = $"{ntf.Country}-{ntf.City}",
  9711. Cost = dac.Cost,
  9712. Currency = dac.Currency,
  9713. CurrencyName = sd.Name,
  9714. SubTotal = dac.SubTotal,
  9715. })
  9716. .ToArray();
  9717. var data = new ChoiceMobileSubInfo3To6View()
  9718. {
  9719. ParentId = eecInfo.Id,
  9720. Choice = eecInfo.ChoiceFour,
  9721. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9722. Details = dayAndCostDatas
  9723. };
  9724. return Ok(JsonView(data));
  9725. }
  9726. else if (subType == 5) //5:公杂费
  9727. {
  9728. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9729. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9730. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9731. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9732. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9733. {
  9734. SubId = dac.Id,
  9735. DiId = dac.DiId,
  9736. Type = dac.Type,
  9737. Days = dac.Days,
  9738. NationalTravelFeeId = dac.NationalTravelFeeId,
  9739. Arae = $"{ntf.Country}-{ntf.City}",
  9740. Cost = dac.Cost,
  9741. Currency = dac.Currency,
  9742. CurrencyName = sd.Name,
  9743. SubTotal = dac.SubTotal,
  9744. })
  9745. .ToArray();
  9746. var data = new ChoiceMobileSubInfo3To6View()
  9747. {
  9748. ParentId = eecInfo.Id,
  9749. Choice = eecInfo.ChoiceFive,
  9750. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9751. Details = dayAndCostDatas
  9752. };
  9753. return Ok(JsonView(data));
  9754. }
  9755. else if (subType == 6) //6:培训费
  9756. {
  9757. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9758. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9759. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9760. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9761. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9762. {
  9763. SubId = dac.Id,
  9764. DiId = dac.DiId,
  9765. Type = dac.Type,
  9766. Days = dac.Days,
  9767. NationalTravelFeeId = dac.NationalTravelFeeId,
  9768. Arae = $"{ntf.Country}-{ntf.City}",
  9769. Cost = dac.Cost,
  9770. Currency = dac.Currency,
  9771. CurrencyName = sd.Name,
  9772. SubTotal = dac.SubTotal,
  9773. })
  9774. .ToArray();
  9775. var data = new ChoiceMobileSubInfo3To6View()
  9776. {
  9777. ParentId = eecInfo.Id,
  9778. Choice = eecInfo.ChoiceSix,
  9779. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9780. Details = dayAndCostDatas
  9781. };
  9782. return Ok(JsonView(data));
  9783. }
  9784. else if (subType == 7) //7:其他
  9785. {
  9786. //其他款项
  9787. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9788. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9789. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9790. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9791. .OrderBy((dop, sd1, sd2) => dop.Index)
  9792. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9793. {
  9794. SubId = dop.Id,
  9795. DiId = dop.Diid,
  9796. Index = dop.Index,
  9797. SetDataId = dop.SetDataId,
  9798. SetDataName = sd1.Name,
  9799. Cost = dop.Cost,
  9800. Currency = dop.Currency,
  9801. CurrencyName = sd2.Name,
  9802. SubTotal = dop.SubTotal,
  9803. Remark = dop.Remark,
  9804. })
  9805. .ToArray();
  9806. var data = new ChoiceSevenMobileSubInfoView()
  9807. {
  9808. ParentId = eecInfo.Id,
  9809. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9810. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9811. Details = otherData
  9812. };
  9813. return Ok(JsonView(data));
  9814. }
  9815. return Ok(JsonView(false));
  9816. }
  9817. #region op
  9818. /// <summary>
  9819. /// 移动端更新费用消息通知
  9820. /// </summary>
  9821. /// <param name="diid"></param>
  9822. /// <param name="id"></param>
  9823. /// <param name="currUserId"></param>
  9824. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9825. {
  9826. try
  9827. {
  9828. ////生成默认文件pdf并且通知人员
  9829. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9830. //{
  9831. // DiId = diid,
  9832. // ExportType = 1,
  9833. // SubTypeId = 1005
  9834. //}, "pdf");
  9835. ////发送通知
  9836. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9837. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9838. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9839. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9840. ////汇率信息记录
  9841. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9842. }
  9843. catch (Exception ex)
  9844. {
  9845. //记录日志
  9846. throw;
  9847. }
  9848. }
  9849. /// <summary>
  9850. /// 验证出入境费用数据是否存在
  9851. /// 不存在添加
  9852. /// </summary>
  9853. /// <param name="diId"></param>
  9854. /// <param name="currUserId"></param>
  9855. /// <returns></returns>
  9856. /// <exception cref="CustomException"></exception>
  9857. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9858. {
  9859. var parentId = 0;
  9860. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9861. if (info != null)
  9862. {
  9863. parentId = info.Id;
  9864. }
  9865. else
  9866. {
  9867. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9868. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9869. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9870. parentId = addId;
  9871. }
  9872. return parentId;
  9873. }
  9874. /// <summary>
  9875. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9876. /// </summary>
  9877. /// <returns></returns>
  9878. [HttpPost]
  9879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9880. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9881. {
  9882. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9883. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9884. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9885. //验证编辑权限
  9886. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9887. //if (!isEdit) return Ok(JsonView(false, msg));
  9888. var permissions = new List<Grp_EnterExitCostPermission>();
  9889. foreach (var userId in dto.UserIds)
  9890. {
  9891. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9892. }
  9893. if (permissions.Any())
  9894. {
  9895. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9896. {
  9897. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9898. }
  9899. _sqlSugar.BeginTran();
  9900. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9901. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9902. if (result < 1)
  9903. {
  9904. _sqlSugar.RollbackTran();
  9905. return Ok(JsonView(false));
  9906. }
  9907. _sqlSugar.CommitTran();
  9908. return Ok(JsonView(true));
  9909. }
  9910. return Ok(JsonView(false));
  9911. }
  9912. /// <summary>
  9913. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9914. /// </summary>
  9915. /// <returns></returns>
  9916. [HttpPost]
  9917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9918. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9919. {
  9920. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9921. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9922. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9923. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9924. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9925. int id = dto.Id;
  9926. if (id <= 0) //add
  9927. {
  9928. //int provinceId = dto.ProvinceId;
  9929. int groupId = dto.DiId;
  9930. //if (provinceId < 1) provinceId = 122;
  9931. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9932. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9933. if (add < 1) return Ok(JsonView(false));
  9934. id = add;
  9935. }
  9936. else //update
  9937. {
  9938. ////验证编辑权限
  9939. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9940. //if (!isEdit) return Ok(JsonView(false, msg));
  9941. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9942. if (upd < 1) return Ok(JsonView(false));
  9943. }
  9944. #region 汇率变更时更改币种相关费用
  9945. var opDayCosts = new List<Grp_DayAndCost>();
  9946. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9947. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9948. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9949. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9950. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9951. .Select((dac, sd) => new
  9952. {
  9953. dac.Id,
  9954. dac.DiId,
  9955. CurrencyCode = sd.Name,
  9956. dac.Cost
  9957. })
  9958. .ToList();
  9959. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9960. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9961. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9962. .Select((dop, sd) => new
  9963. {
  9964. dop.Id,
  9965. dop.Diid,
  9966. CurrencyCode = sd.Name,
  9967. dop.Cost
  9968. })
  9969. .ToList();
  9970. if (dayCosts.Count > 0)
  9971. {
  9972. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9973. foreach (var dc in new_dayCosts)
  9974. {
  9975. var thisCurrency = dc.Key.ToUpper();
  9976. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9977. if (thisRate == 0.00M) continue;
  9978. foreach (var dcSub in dc)
  9979. {
  9980. opDayCosts.Add(new Grp_DayAndCost()
  9981. {
  9982. Id = dcSub.Id,
  9983. DiId = dcSub.DiId,
  9984. Cost = dcSub.Cost,
  9985. SubTotal = dcSub.Cost * thisRate,
  9986. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9987. });
  9988. }
  9989. }
  9990. if (opDayCosts.Count > 0)
  9991. {
  9992. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9993. }
  9994. }
  9995. if (dayOtherCosts.Count > 0)
  9996. {
  9997. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9998. foreach (var dc in new_dayOtherCosts)
  9999. {
  10000. var thisCurrency = dc.Key.ToUpper();
  10001. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10002. if (thisRate == 0.00M) continue;
  10003. foreach (var dcSub in dc)
  10004. {
  10005. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10006. {
  10007. Id = dcSub.Id,
  10008. Diid = dcSub.Diid,
  10009. Cost = dcSub.Cost,
  10010. SubTotal = dcSub.Cost * thisRate,
  10011. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10012. });
  10013. }
  10014. }
  10015. if (opDayOtherCosts.Count > 0)
  10016. {
  10017. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10018. }
  10019. }
  10020. #endregion
  10021. //消息通知
  10022. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10023. //汇率信息记录
  10024. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10025. return Ok(JsonView(new { parentId = id }));
  10026. }
  10027. /// <summary>
  10028. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10029. /// </summary>
  10030. /// <returns></returns>
  10031. [HttpPost]
  10032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10033. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10034. {
  10035. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10036. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10037. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10038. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10039. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10040. int id = dto.Id;
  10041. if (id <= 0) //add
  10042. {
  10043. checkboxInfo.CreateUserId = dto.CurrUserId;
  10044. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10045. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10046. if (add < 1) return Ok(JsonView(false));
  10047. }
  10048. else //update
  10049. {
  10050. ////验证编辑权限
  10051. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10052. //if (!isEdit) return Ok(JsonView(false, msg));
  10053. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10054. .UpdateColumns(x => new
  10055. {
  10056. x.ChoiceOne,
  10057. x.ChoiceTwo,
  10058. x.SumJJC,
  10059. x.SumGWC,
  10060. x.SumTDC,
  10061. x.ChoiceThree,
  10062. x.ChoiceFour,
  10063. x.ChoiceFive,
  10064. x.ChoiceSix,
  10065. x.OtherExpenses_Checked
  10066. })
  10067. .Where(x => x.Id == id)
  10068. .ExecuteCommandAsync();
  10069. if (upd < 1) return Ok(JsonView(false));
  10070. }
  10071. return Ok(JsonView(new { parentId = id }));
  10072. }
  10073. /// <summary>
  10074. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10075. /// </summary>
  10076. /// <returns></returns>
  10077. [HttpPost]
  10078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10079. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10080. {
  10081. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10082. // if (provinceId < 1) provinceId = 122;
  10083. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10084. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10085. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10086. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10087. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10088. var checkboxInfo = new Grp_EnterExitCost()
  10089. {
  10090. Id = id,
  10091. //ProvinceId = provinceId,
  10092. DiId = diId,
  10093. CreateUserId = currUserId
  10094. };
  10095. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10096. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10097. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10098. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10099. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10100. if (id <= 0) //add
  10101. {
  10102. checkboxInfo.CreateUserId = dto.CurrUserId;
  10103. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10104. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10105. if (add < 1) return Ok(JsonView(false));
  10106. }
  10107. else //update
  10108. {
  10109. ////验证编辑权限
  10110. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10111. //if (!isEdit) return Ok(JsonView(false, msg));
  10112. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10113. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10114. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10115. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10116. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10117. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10118. .Where(x => x.Id == id)
  10119. .ExecuteCommandAsync();
  10120. if (upd < 1) return Ok(JsonView(false));
  10121. }
  10122. return Ok(JsonView(new { parentId = id }));
  10123. }
  10124. /// <summary>
  10125. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10126. /// </summary>
  10127. /// <returns></returns>
  10128. [HttpPost]
  10129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10130. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10131. {
  10132. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10133. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10134. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10135. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10136. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10137. info.FirstItemRemark = dto.FirstItemRemark;
  10138. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10139. int id = dto.Id;
  10140. if (id <= 0) //add
  10141. {
  10142. info.CreateUserId = dto.CurrUserId;
  10143. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10144. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10145. if (add < 1) return Ok(JsonView(false));
  10146. id = add;
  10147. }
  10148. else //update
  10149. {
  10150. ////验证编辑权限
  10151. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10152. //if (!isEdit) return Ok(JsonView(false, msg));
  10153. var upd = await _sqlSugar.Updateable(info)
  10154. .UpdateColumns(x => new
  10155. {
  10156. x.ChoiceOne,
  10157. x.InsidePay,
  10158. x.VisaRemark,
  10159. x.Visa,
  10160. x.Service,
  10161. x.Safe,
  10162. x.Ticket,
  10163. x.HeSuan,
  10164. x.YiMiao,
  10165. x.FirstItemRemark
  10166. })
  10167. .Where(x => x.Id == id)
  10168. .ExecuteCommandAsync();
  10169. if (upd < 1) return Ok(JsonView(false));
  10170. }
  10171. //消息通知
  10172. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10173. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10174. }
  10175. /// <summary>
  10176. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10177. /// </summary>
  10178. /// <returns></returns>
  10179. [HttpPost]
  10180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10181. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10182. {
  10183. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10184. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10185. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10186. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10187. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10188. info.DiId = dto.DiId;
  10189. //info.ProvinceId = dto.ProvinceId;
  10190. info.OutsideJJPay = dto.OutsideJJPay;
  10191. info.OutsideGWPay = dto.OutsideGWPay;
  10192. info.OutsideTDPay = dto.OutsideTDPay;
  10193. info.AirJJ = dto.AirJJ;
  10194. info.AirGW = dto.AirGW;
  10195. info.AirTD = dto.AirTD;
  10196. info.CityTranffic = dto.CityTranffic;
  10197. info.TwoItemRemark = dto.TwoItemRemark;
  10198. info.SumJJC = dto.ChoiceTwoJJ;
  10199. info.SumGWC = dto.ChoiceTwoGW;
  10200. info.SumTDC = dto.ChoiceTwoTD;
  10201. int id = dto.Id;
  10202. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10203. if (id <= 0) //add
  10204. {
  10205. info.CreateUserId = dto.CurrUserId;
  10206. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10207. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10208. if (addId <= 0) return Ok(JsonView(false));
  10209. id = addId;
  10210. }
  10211. else //update
  10212. {
  10213. ////验证编辑权限
  10214. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10215. //if (!isEdit) return Ok(JsonView(false, msg));
  10216. var upd = await _sqlSugar.Updateable(info)
  10217. .UpdateColumns(x => new
  10218. {
  10219. x.SumJJC,
  10220. x.OutsideJJPay,
  10221. x.SumGWC,
  10222. x.OutsideGWPay,
  10223. x.SumTDC,
  10224. x.OutsideTDPay,
  10225. x.AirJJ,
  10226. x.AirGW,
  10227. x.AirTD,
  10228. x.CityTranffic,
  10229. x.TwoItemRemark
  10230. })
  10231. .Where(x => x.Id == id)
  10232. .ExecuteCommandAsync();
  10233. if (upd < 1) return Ok(JsonView(false));
  10234. }
  10235. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10236. gwcItemTotal = info.AirGW + info.CityTranffic;
  10237. tdcItemTotal = info.AirTD + info.CityTranffic;
  10238. //消息通知
  10239. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10240. return Ok(JsonView(new
  10241. {
  10242. parentId = id,
  10243. choiceTwoJJ = dto.ChoiceTwoJJ,
  10244. jjcItemTotal = jjcItemTotal,
  10245. choiceTwoGW = dto.ChoiceTwoGW,
  10246. gwcItemTotal = gwcItemTotal,
  10247. choiceTwoTD = dto.ChoiceTwoTD,
  10248. tdcItemTotal = tdcItemTotal
  10249. }));
  10250. }
  10251. /// <summary>
  10252. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10253. /// </summary>
  10254. /// <returns></returns>
  10255. [HttpPost]
  10256. [ApiExplorerSettings(IgnoreApi = true)]
  10257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10258. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10259. {
  10260. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10261. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10262. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10263. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10264. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10265. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10266. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10267. var infos = infos1.Select(x => new Grp_DayAndCost
  10268. {
  10269. Id = x.Id,
  10270. DiId = dto.DiId,
  10271. Type = dto.FeeType,
  10272. Days = x.Days,
  10273. NationalTravelFeeId = x.NationalTravelFeeId,
  10274. Cost = x.Cost,
  10275. Currency = x.Currency,
  10276. SubTotal = x.SubTotal,
  10277. CreateUserId = dto.CurrUserId
  10278. })
  10279. .ToList();
  10280. var adds = infos.Where(x => x.Id <= 0).ToList();
  10281. var upds = infos.Where(x => x.Id > 0).ToList();
  10282. if (adds.Count > 0)
  10283. {
  10284. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10285. if (add < 1) return Ok(JsonView(false));
  10286. }
  10287. if (upds.Count > 0)
  10288. {
  10289. var upd = await _sqlSugar.Updateable(adds)
  10290. .UpdateColumns(x => new
  10291. {
  10292. x.Days,
  10293. x.NationalTravelFeeId,
  10294. x.Cost,
  10295. x.Currency,
  10296. x.SubTotal
  10297. })
  10298. .WhereColumns(x => new { x.Id })
  10299. .ExecuteCommandAsync();
  10300. if (upd < 1) return Ok(JsonView(false));
  10301. }
  10302. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10303. //消息通知
  10304. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10305. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10306. return Ok(JsonView(new { itemTotal = itemTotal }));
  10307. }
  10308. /// <summary>
  10309. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10310. /// </summary>
  10311. /// <returns></returns>
  10312. [HttpPost]
  10313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10314. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10315. {
  10316. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10317. int subId = dto.SubId, feeType = dto.FeeType;
  10318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10319. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10320. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10321. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10322. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10323. subInfo.Id = subId;
  10324. subInfo.DiId = dto.DiId;
  10325. if (feeType == 3) subInfo.Type = 1;
  10326. else if (feeType == 4) subInfo.Type = 2;
  10327. else if (feeType == 5) subInfo.Type = 3;
  10328. else if (feeType == 6) subInfo.Type = 4;
  10329. subInfo.CreateUserId = dto.CurrUserId;
  10330. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10331. if (parentId < 1) return Ok(JsonView(false));
  10332. //子表op
  10333. if (subId < 1)
  10334. {
  10335. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10336. if (subAdd < 1) return Ok(JsonView(false));
  10337. }
  10338. else
  10339. {
  10340. ////验证编辑权限
  10341. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10342. //if (!isEdit) return Ok(JsonView(false, msg));
  10343. var subUpd = await _sqlSugar.Updateable(subInfo)
  10344. .UpdateColumns(x => new
  10345. {
  10346. x.Days,
  10347. x.NationalTravelFeeId,
  10348. x.Cost,
  10349. x.Currency,
  10350. x.SubTotal
  10351. })
  10352. .WhereColumns(x => new { x.Id })
  10353. .ExecuteCommandAsync();
  10354. if (subUpd < 1) return Ok(JsonView(false));
  10355. }
  10356. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10357. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10358. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10359. }
  10360. /// <summary>
  10361. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10362. /// </summary>
  10363. /// <returns></returns>
  10364. [HttpPost]
  10365. [ApiExplorerSettings(IgnoreApi = true)]
  10366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10367. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10368. {
  10369. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10370. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10371. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10372. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10373. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10374. {
  10375. Id = x.Id,
  10376. Diid = dto.DiId,
  10377. SetDataId = x.SetDataId,
  10378. Index = x.Index,
  10379. Cost = x.Cost,
  10380. Currency = x.Currency,
  10381. SubTotal = x.SubTotal,
  10382. CreateUserId = dto.CurrUserId,
  10383. Remark = x.Remark
  10384. }).ToList();
  10385. var adds = infos.Where(x => x.Id <= 0).ToList();
  10386. var upds = infos.Where(x => x.Id > 0).ToList();
  10387. if (adds.Count > 0)
  10388. {
  10389. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10390. if (add < 1) return Ok(JsonView(false));
  10391. }
  10392. if (upds.Count > 0)
  10393. {
  10394. var upd = await _sqlSugar.Updateable(adds)
  10395. .UpdateColumns(x => new
  10396. {
  10397. x.Index,
  10398. x.SetDataId,
  10399. x.Cost,
  10400. x.Currency,
  10401. x.SubTotal,
  10402. x.Remark
  10403. })
  10404. .WhereColumns(x => new { x.Id })
  10405. .ExecuteCommandAsync();
  10406. if (upd < 1) return Ok(JsonView(false));
  10407. }
  10408. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10409. //消息通知
  10410. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10411. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10412. return Ok(JsonView(new { itemTotal = itemTotal }));
  10413. }
  10414. /// <summary>
  10415. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10416. /// </summary>
  10417. /// <returns></returns>
  10418. [HttpPost]
  10419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10420. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10421. {
  10422. int subId = dto.SubId;
  10423. int diId = dto.Diid;
  10424. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10425. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10426. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10427. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10428. subInfo.Id = subId;
  10429. subInfo.Diid = dto.Diid;
  10430. subInfo.CreateUserId = dto.CurrUserId;
  10431. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10432. if (parentId < 1) return Ok(JsonView(false));
  10433. #region 子表op
  10434. if (subId < 1)//add
  10435. {
  10436. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10437. if (subAdd < 1) return Ok(JsonView(false));
  10438. }
  10439. else //upd
  10440. {
  10441. ////验证编辑权限
  10442. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10443. //if (!isEdit) return Ok(JsonView(false, msg));
  10444. var subUpd = await _sqlSugar.Updateable(subInfo)
  10445. .UpdateColumns(x => new
  10446. {
  10447. x.Index,
  10448. x.SetDataId,
  10449. x.Cost,
  10450. x.Currency,
  10451. x.SubTotal,
  10452. x.Remark
  10453. })
  10454. .WhereColumns(x => new { x.Id })
  10455. .ExecuteCommandAsync();
  10456. if (subUpd < 1) return Ok(JsonView(false));
  10457. }
  10458. #endregion
  10459. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10460. //消息通知
  10461. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10462. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10463. }
  10464. /// <summary>
  10465. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10466. /// </summary>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10471. {
  10472. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10473. if (data.Code != 0)
  10474. {
  10475. return Ok(JsonView(false, data.Msg));
  10476. }
  10477. return Ok(JsonView(true, "操作成功!", data.Data));
  10478. }
  10479. /// <summary>
  10480. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10481. /// </summary>
  10482. /// <param name="dto"></param>
  10483. /// <returns></returns>
  10484. [HttpPost]
  10485. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10486. {
  10487. var data = new Grp_DayOtherPrice()
  10488. {
  10489. Id = dto.Id,
  10490. IsDel = 1,
  10491. DeleteUserId = dto.DeleteUserId,
  10492. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10493. };
  10494. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10495. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10496. return Ok(JsonView(false, "删除失败!"));
  10497. }
  10498. #endregion
  10499. #endregion
  10500. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10501. /// <summary>
  10502. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10503. /// </summary>
  10504. /// <returns></returns>
  10505. [HttpGet]
  10506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10507. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10508. {
  10509. var provData = await _groupRepository.ProvinceBasicSource();
  10510. return Ok(JsonView(true, "查询成功!", provData));
  10511. }
  10512. /// <summary>
  10513. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10514. /// </summary>
  10515. /// <returns></returns>
  10516. [HttpPost]
  10517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10518. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10519. {
  10520. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10521. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10522. RefAsync<int> total = 0;
  10523. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10524. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10525. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10526. .Select(x => new
  10527. {
  10528. Id = x.Id,
  10529. DraftName = x.DraftName,
  10530. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10531. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10532. .Any()
  10533. })
  10534. .OrderByDescending(x => x.Id)
  10535. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10536. return Ok(JsonView(true, "查询成功!", data, total));
  10537. }
  10538. /// <summary>
  10539. /// 出入境费用-草稿 移动端
  10540. /// 获取币种基础数据(含逻辑处理)
  10541. /// </summary>
  10542. /// <returns></returns>
  10543. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10544. {
  10545. return await GeneralMethod.EnterExitCostInitRate();
  10546. }
  10547. /// <summary>
  10548. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10549. /// </summary>
  10550. /// <returns></returns>
  10551. [HttpPost]
  10552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10553. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10554. {
  10555. //验证城市归属并给默认值
  10556. int provinceId = dto.ProvinceId;
  10557. if (provinceId < 1) provinceId = 122;
  10558. var dataSource = await _sqlSugar
  10559. .Queryable<Sys_SetData>()
  10560. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10561. .ToListAsync();
  10562. //三公费用-Word明细类型
  10563. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10564. .Select(x => new SetDataInfoView
  10565. {
  10566. Id = x.Id,
  10567. Name = x.Name,
  10568. Remark = x.Remark
  10569. })
  10570. .ToList();
  10571. //三公费用-Excel明细类型
  10572. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10573. .Select(x => new SetDataInfoView
  10574. {
  10575. Id = x.Id,
  10576. Name = x.Name,
  10577. Remark = x.Remark
  10578. })
  10579. .ToList();
  10580. //默认币种显示
  10581. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10582. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10583. return Ok(JsonView(true, "查询成功!", new
  10584. {
  10585. WordTypeData = wordTypeData,
  10586. ExcelTypeData = excelTypeData,
  10587. CurrencyInit = _currencyInfos,
  10588. viewPermissionData = viewPermissionData
  10589. }));
  10590. }
  10591. /// <summary>
  10592. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10593. /// </summary>
  10594. /// <returns></returns>
  10595. [HttpPost]
  10596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10597. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10598. {
  10599. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10600. RefAsync<int> total = 0;
  10601. int diId = 0;
  10602. var status = int.TryParse(dto.GroupName, out diId);
  10603. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10604. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10605. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10606. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10607. .OrderByDescending(x => x.VisitStartDate)
  10608. .Select(x => new
  10609. {
  10610. Id = x.Id,
  10611. GroupName = x.TeamName
  10612. })
  10613. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10614. return Ok(JsonView(true, "查询成功!", data, total));
  10615. }
  10616. /// <summary>
  10617. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10618. /// </summary>
  10619. /// <returns></returns>
  10620. [HttpPost]
  10621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10622. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10623. {
  10624. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10625. RefAsync<int> total = 0;
  10626. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10627. .Where(x => x.IsDel == 0 && x.STid == 66)
  10628. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10629. .Select(x => new
  10630. {
  10631. id = x.Id,
  10632. name = x.Name,
  10633. remark = x.Remark,
  10634. })
  10635. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10636. return Ok(JsonView(true, "查询成功!", data, total));
  10637. }
  10638. /// <summary>
  10639. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10640. /// </summary>
  10641. /// <returns></returns>
  10642. [HttpPost]
  10643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10644. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10645. {
  10646. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10647. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10648. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10649. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10650. var groupOtherRateData = groupRateData.TeamRates;
  10651. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10652. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10653. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10654. groupOtherRateData = groupOtherRateData
  10655. .Select(x => new TeamRateDescAddCurrencyIdView
  10656. {
  10657. CurrencyId = x.CurrencyId,
  10658. CurrencyName = x.CurrencyName,
  10659. CurrencyCode = x.CurrencyCode,
  10660. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10661. }).ToList();
  10662. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10663. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10664. }
  10665. /// <summary>
  10666. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10667. /// </summary>
  10668. /// <returns></returns>
  10669. [HttpPost]
  10670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10671. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10672. {
  10673. int portType = dto.PortType;
  10674. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10675. var tipsData = new List<int>() { 1, 2, 3 };
  10676. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10677. if (dto.TipsType == 1)
  10678. {
  10679. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10680. }
  10681. else if (dto.TipsType == 2)
  10682. {
  10683. if (portType == 2)
  10684. {
  10685. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10686. }
  10687. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10688. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10689. .Select(x => x.NationalTravelFeeId)
  10690. .Distinct()
  10691. .ToListAsync();
  10692. if (portType == 2)
  10693. {
  10694. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10695. }
  10696. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10697. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10698. .Select(x => x.Country)
  10699. .Distinct()
  10700. .ToArrayAsync();
  10701. if (portType == 2)
  10702. {
  10703. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10704. }
  10705. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10706. return Ok(JsonView(true, "查询成功!", new
  10707. {
  10708. totalAmt = totalAmt,
  10709. remark = remark
  10710. }));
  10711. }
  10712. else if (dto.TipsType == 3)
  10713. {
  10714. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10715. }
  10716. return Ok(JsonView(false));
  10717. }
  10718. /// <summary>
  10719. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10720. /// </summary>
  10721. /// <returns></returns>
  10722. [HttpPost]
  10723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10724. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10725. {
  10726. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10727. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10728. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10729. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10730. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10731. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10732. var info = new Grp_EnterExitCostDraft()
  10733. {
  10734. ProvinceId = dto.ProvinceId,
  10735. DraftName = dto.DraftName,
  10736. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10737. CreateUserId = dto.CurrUserId
  10738. };
  10739. _sqlSugar.BeginTran();
  10740. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10741. if (draftId < 1)
  10742. {
  10743. _sqlSugar.RollbackTran();
  10744. return Ok(JsonView(false, "草稿创建失败!"));
  10745. }
  10746. //添加默认权限
  10747. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10748. _sqlSugar.CommitTran();
  10749. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10750. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10751. mobileInfo.Id = draftId;
  10752. mobileInfo.DraftName = dto.DraftName;
  10753. mobileInfo.Currencys = rateInfos;
  10754. mobileInfo.IsAssignPerm = assignPerm;
  10755. return Ok(JsonView(mobileInfo));
  10756. }
  10757. /// <summary>
  10758. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10759. /// </summary>
  10760. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10761. /// <summary>
  10762. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10763. /// </summary>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10767. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10768. {
  10769. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10770. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10771. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10772. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10773. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10774. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10775. //验证查看编辑权限
  10776. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10777. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10778. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10779. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10780. mobileInfo.IsAssignPerm = assignPerm;
  10781. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10782. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10783. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10784. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10785. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10786. {
  10787. ParentId = dac.ParentId,
  10788. SubId = dac.Id,
  10789. Type = dac.Type,
  10790. Days = dac.Days,
  10791. NationalTravelFeeId = dac.NationalTravelFeeId,
  10792. Arae = $"{ntf.Country}-{ntf.City}",
  10793. Cost = dac.Cost,
  10794. Currency = dac.Currency,
  10795. CurrencyName = sd.Name,
  10796. SubTotal = dac.SubTotal,
  10797. })
  10798. .ToList();
  10799. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10800. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10801. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10802. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10803. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10804. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10805. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10806. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10807. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10808. //其他款项
  10809. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10810. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10811. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10812. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10813. .OrderBy((dop, sd1, sd2) => dop.Index)
  10814. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10815. {
  10816. ParentId = dop.ParentId,
  10817. SubId = dop.Id,
  10818. Index = dop.Index,
  10819. SetDataId = dop.SetDataId,
  10820. SetDataName = sd1.Name,
  10821. Cost = dop.Cost,
  10822. Currency = dop.Currency,
  10823. CurrencyName = sd2.Remark,
  10824. SubTotal = dop.SubTotal,
  10825. Remark = dop.Remark,
  10826. })
  10827. .ToArray();
  10828. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10829. return Ok(mobileInfo);
  10830. }
  10831. /// <summary>
  10832. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10833. /// </summary>
  10834. /// <returns></returns>
  10835. [HttpPost]
  10836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10837. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10838. {
  10839. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10840. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10841. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10842. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10843. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10844. //验证查看编辑权限
  10845. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10846. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10847. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10848. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10849. var subType = dto.SubType;
  10850. if (subType == 1) //1:境内费用
  10851. {
  10852. var oneData = new ChoiceOneMobileSubInfoView()
  10853. {
  10854. Id = eecInfo.Id,
  10855. ChoiceOne = eecInfo.ChoiceOne,
  10856. ChoiceOneTotalCost = eecInfo.InsidePay,
  10857. Visa = eecInfo.Visa,
  10858. VisaRemark = eecInfo.VisaRemark,
  10859. YiMiao = eecInfo.YiMiao,
  10860. HeSuan = eecInfo.HeSuan,
  10861. Service = eecInfo.Service,
  10862. Ticket = eecInfo.Ticket,
  10863. Safe = eecInfo.Safe,
  10864. FirstItemRemark = eecInfo.FirstItemRemark
  10865. };
  10866. return Ok(JsonView(oneData));
  10867. }
  10868. else if (subType == 2) //2:国际旅费
  10869. {
  10870. var twoData = new ChoiceTwoMobileSubInfoView()
  10871. {
  10872. Id = eecInfo.Id,
  10873. ChoiceTwoJJ = eecInfo.SumJJC,
  10874. OutsideJJPay = eecInfo.OutsideJJPay,
  10875. ChoiceTwoGW = eecInfo.SumGWC,
  10876. OutsideGWPay = eecInfo.OutsideGWPay,
  10877. ChoiceTwoTD = eecInfo.SumTDC,
  10878. OutsideTDPay = eecInfo.OutsideTDPay,
  10879. AirJJ = eecInfo.AirJJ,
  10880. AirGW = eecInfo.AirGW,
  10881. AirTD = eecInfo.AirTD,
  10882. CityTranffic = eecInfo.CityTranffic,
  10883. TwoItemRemark = eecInfo.TwoItemRemark
  10884. };
  10885. return Ok(JsonView(twoData));
  10886. }
  10887. else if (subType == 3) //3:住宿费
  10888. {
  10889. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10890. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10891. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10892. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10893. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10894. {
  10895. ParentId = dac.ParentId,
  10896. SubId = dac.Id,
  10897. Type = dac.Type,
  10898. Days = dac.Days,
  10899. NationalTravelFeeId = dac.NationalTravelFeeId,
  10900. Arae = $"{ntf.Country}-{ntf.City}",
  10901. Cost = dac.Cost,
  10902. Currency = dac.Currency,
  10903. CurrencyName = sd.Name,
  10904. SubTotal = dac.SubTotal,
  10905. })
  10906. .ToArray();
  10907. var data = new ChoiceDraftMobileSubInfo3To6View()
  10908. {
  10909. ParentId = eecInfo.Id,
  10910. Choice = eecInfo.ChoiceThree,
  10911. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10912. Details = dayAndCostDatas
  10913. };
  10914. return Ok(JsonView(data));
  10915. }
  10916. else if (subType == 4) //4:伙食费
  10917. {
  10918. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10919. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10920. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10921. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10922. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10923. {
  10924. ParentId = dac.ParentId,
  10925. SubId = dac.Id,
  10926. Type = dac.Type,
  10927. Days = dac.Days,
  10928. NationalTravelFeeId = dac.NationalTravelFeeId,
  10929. Arae = $"{ntf.Country}-{ntf.City}",
  10930. Cost = dac.Cost,
  10931. Currency = dac.Currency,
  10932. CurrencyName = sd.Name,
  10933. SubTotal = dac.SubTotal,
  10934. })
  10935. .ToArray();
  10936. var data = new ChoiceDraftMobileSubInfo3To6View()
  10937. {
  10938. ParentId = eecInfo.Id,
  10939. Choice = eecInfo.ChoiceFour,
  10940. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10941. Details = dayAndCostDatas
  10942. };
  10943. return Ok(JsonView(data));
  10944. }
  10945. else if (subType == 5) //5:公杂费
  10946. {
  10947. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10948. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10949. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10950. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10951. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10952. {
  10953. ParentId = dac.ParentId,
  10954. SubId = dac.Id,
  10955. Type = dac.Type,
  10956. Days = dac.Days,
  10957. NationalTravelFeeId = dac.NationalTravelFeeId,
  10958. Arae = $"{ntf.Country}-{ntf.City}",
  10959. Cost = dac.Cost,
  10960. Currency = dac.Currency,
  10961. CurrencyName = sd.Name,
  10962. SubTotal = dac.SubTotal,
  10963. })
  10964. .ToArray();
  10965. var data = new ChoiceDraftMobileSubInfo3To6View()
  10966. {
  10967. ParentId = eecInfo.Id,
  10968. Choice = eecInfo.ChoiceFive,
  10969. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10970. Details = dayAndCostDatas
  10971. };
  10972. return Ok(JsonView(data));
  10973. }
  10974. else if (subType == 6) //6:培训费
  10975. {
  10976. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10977. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10978. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10979. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10980. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10981. {
  10982. ParentId = dac.ParentId,
  10983. SubId = dac.Id,
  10984. Type = dac.Type,
  10985. Days = dac.Days,
  10986. NationalTravelFeeId = dac.NationalTravelFeeId,
  10987. Arae = $"{ntf.Country}-{ntf.City}",
  10988. Cost = dac.Cost,
  10989. Currency = dac.Currency,
  10990. CurrencyName = sd.Name,
  10991. SubTotal = dac.SubTotal,
  10992. })
  10993. .ToArray();
  10994. var data = new ChoiceDraftMobileSubInfo3To6View()
  10995. {
  10996. ParentId = eecInfo.Id,
  10997. Choice = eecInfo.ChoiceSix,
  10998. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10999. Details = dayAndCostDatas
  11000. };
  11001. return Ok(JsonView(data));
  11002. }
  11003. else if (subType == 7) //7:其他
  11004. {
  11005. //其他款项
  11006. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11007. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11008. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11009. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11010. .OrderBy((dop, sd1, sd2) => dop.Index)
  11011. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11012. {
  11013. ParentId = dop.ParentId,
  11014. SubId = dop.Id,
  11015. Index = dop.Index,
  11016. SetDataId = dop.SetDataId,
  11017. SetDataName = sd1.Name,
  11018. Cost = dop.Cost,
  11019. Currency = dop.Currency,
  11020. CurrencyName = sd2.Name,
  11021. SubTotal = dop.SubTotal,
  11022. Remark = dop.Remark,
  11023. })
  11024. .ToArray();
  11025. var data = new ChoiceSevenDraftMobileSubInfoView()
  11026. {
  11027. ParentId = eecInfo.Id,
  11028. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11029. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11030. Details = otherData
  11031. };
  11032. return Ok(JsonView(data));
  11033. }
  11034. return Ok(JsonView(false));
  11035. }
  11036. #region op
  11037. /// <summary>
  11038. /// 移动端更新费用消息通知
  11039. /// </summary>
  11040. /// <param name="draftId"></param>
  11041. /// <param name="id"></param>
  11042. /// <param name="currUserId"></param>
  11043. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11044. {
  11045. try
  11046. {
  11047. ////生成默认文件pdf并且通知人员
  11048. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11049. //{
  11050. // DiId = draftId,
  11051. // ExportType = 1,
  11052. // SubTypeId = 1005
  11053. //}, "pdf");
  11054. ////发送通知
  11055. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11056. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11057. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11058. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11059. ////汇率信息记录
  11060. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11061. }
  11062. catch (Exception ex)
  11063. {
  11064. //记录日志
  11065. throw;
  11066. }
  11067. }
  11068. /// <summary>
  11069. /// 验证出入境费用数据是否存在
  11070. /// 不存在添加
  11071. /// </summary>
  11072. /// <param name="draftId"></param>
  11073. /// <param name="currUserId"></param>
  11074. /// <returns></returns>
  11075. /// <exception cref="CustomException"></exception>
  11076. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11077. {
  11078. var parentId = 0;
  11079. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11080. if (info != null) parentId = info.Id;
  11081. else
  11082. {
  11083. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11084. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11085. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11086. parentId = addId;
  11087. }
  11088. return parentId;
  11089. }
  11090. /// <summary>
  11091. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11092. /// </summary>
  11093. /// <returns></returns>
  11094. [HttpPost]
  11095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11096. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11097. {
  11098. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11099. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11100. //验证查看权限
  11101. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11102. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11103. var userIds = await _sqlSugar
  11104. .Queryable<Grp_EnterExitCostDraftPermission>()
  11105. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11106. .Select(x => x.UserId)
  11107. .ToArrayAsync();
  11108. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11109. var perUsersView = new List<dynamic>();
  11110. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11111. var viewPermissionData = new List<PermissionViewUserview>();
  11112. if (feeBasePerm.Any())
  11113. {
  11114. foreach (var item in feeBasePerm)
  11115. {
  11116. if (item.Users.Any())
  11117. {
  11118. viewPermissionData.AddRange(item.Users);
  11119. }
  11120. }
  11121. }
  11122. foreach (var item in perUsers)
  11123. {
  11124. bool isView1 = false;
  11125. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11126. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11127. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11128. }
  11129. return Ok(JsonView(perUsersView));
  11130. }
  11131. /// <summary>
  11132. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11133. /// </summary>
  11134. /// <returns></returns>
  11135. [HttpPost]
  11136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11137. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11138. {
  11139. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11140. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11141. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11142. //验证查看编辑权限
  11143. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11144. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11145. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11146. foreach (var userId in dto.UserIds)
  11147. {
  11148. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11149. }
  11150. if (permissions.Any())
  11151. {
  11152. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11153. {
  11154. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11155. }
  11156. _sqlSugar.BeginTran();
  11157. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11158. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11159. if (result < 1)
  11160. {
  11161. _sqlSugar.RollbackTran();
  11162. return Ok(JsonView(false));
  11163. }
  11164. _sqlSugar.CommitTran();
  11165. return Ok(JsonView(true));
  11166. }
  11167. return Ok(JsonView(false));
  11168. }
  11169. /// <summary>
  11170. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11171. /// </summary>
  11172. /// <returns></returns>
  11173. [HttpPost]
  11174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11175. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11176. {
  11177. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11178. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11179. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11180. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11181. int id = dto.DraftId;
  11182. if (id <= 0) //add
  11183. {
  11184. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11185. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11186. if (add < 1) return Ok(JsonView(false));
  11187. id = add;
  11188. }
  11189. else //update
  11190. {
  11191. //验证查看编辑权限
  11192. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11193. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11194. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11195. if (upd < 1) return Ok(JsonView(false));
  11196. }
  11197. return Ok(JsonView(new { parentId = id }));
  11198. }
  11199. /// <summary>
  11200. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11201. /// </summary>
  11202. /// <returns></returns>
  11203. [HttpPost]
  11204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11205. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11206. {
  11207. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11208. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11209. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11210. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11211. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11212. int id = dto.DraftId;
  11213. if (id <= 0) //add
  11214. {
  11215. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11216. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11217. if (add < 1) return Ok(JsonView(false));
  11218. id = add;
  11219. }
  11220. else //update
  11221. {
  11222. //验证查看编辑权限
  11223. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11224. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11225. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11226. if (upd < 1) return Ok(JsonView(false));
  11227. }
  11228. #region 汇率变更时更改币种相关费用
  11229. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11230. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11231. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11232. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11233. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11234. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11235. .Select((dac, sd) => new
  11236. {
  11237. dac.Id,
  11238. dac.ParentId,
  11239. CurrencyCode = sd.Name,
  11240. dac.Cost
  11241. })
  11242. .ToList();
  11243. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11244. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11245. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11246. .Select((dop, sd) => new
  11247. {
  11248. dop.Id,
  11249. dop.ParentId,
  11250. CurrencyCode = sd.Name,
  11251. dop.Cost
  11252. })
  11253. .ToList();
  11254. if (dayCosts.Count > 0)
  11255. {
  11256. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11257. foreach (var dc in new_dayCosts)
  11258. {
  11259. var thisCurrency = dc.Key.ToUpper();
  11260. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11261. if (thisRate == 0.00M) continue;
  11262. foreach (var dcSub in dc)
  11263. {
  11264. opDayCosts.Add(new Grp_DayAndCostDraft()
  11265. {
  11266. Id = dcSub.Id,
  11267. ParentId = dcSub.ParentId,
  11268. Cost = dcSub.Cost,
  11269. SubTotal = dcSub.Cost * thisRate,
  11270. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11271. });
  11272. }
  11273. }
  11274. if (opDayCosts.Count > 0)
  11275. {
  11276. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11277. }
  11278. }
  11279. if (dayOtherCosts.Count > 0)
  11280. {
  11281. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11282. foreach (var dc in new_dayOtherCosts)
  11283. {
  11284. var thisCurrency = dc.Key.ToUpper();
  11285. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11286. if (thisRate == 0.00M) continue;
  11287. foreach (var dcSub in dc)
  11288. {
  11289. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11290. {
  11291. Id = dcSub.Id,
  11292. ParentId = dcSub.ParentId,
  11293. Cost = dcSub.Cost,
  11294. SubTotal = dcSub.Cost * thisRate,
  11295. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11296. });
  11297. }
  11298. }
  11299. if (opDayOtherCosts.Count > 0)
  11300. {
  11301. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11302. }
  11303. }
  11304. #endregion
  11305. ////消息通知
  11306. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11307. ////汇率信息记录
  11308. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11309. return Ok(JsonView(new { parentId = id }));
  11310. }
  11311. /// <summary>
  11312. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11313. /// </summary>
  11314. /// <returns></returns>
  11315. [HttpPost]
  11316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11317. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11318. {
  11319. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11320. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11321. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11322. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11323. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11324. int id = dto.DraftId;
  11325. if (id <= 0) //add
  11326. {
  11327. checkboxInfo.ProvinceId = dto.ProvinceId;
  11328. checkboxInfo.CreateUserId = dto.CurrUserId;
  11329. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11330. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11331. if (add < 1) return Ok(JsonView(false));
  11332. }
  11333. else //update
  11334. {
  11335. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11336. .UpdateColumns(x => new
  11337. {
  11338. x.ChoiceOne,
  11339. x.ChoiceTwo,
  11340. x.SumJJC,
  11341. x.SumGWC,
  11342. x.SumTDC,
  11343. x.ChoiceThree,
  11344. x.ChoiceFour,
  11345. x.ChoiceFive,
  11346. x.ChoiceSix,
  11347. x.OtherExpenses_Checked
  11348. })
  11349. .Where(x => x.Id == id)
  11350. .ExecuteCommandAsync();
  11351. if (upd < 1) return Ok(JsonView(false));
  11352. }
  11353. return Ok(JsonView(new { parentId = id }));
  11354. }
  11355. /// <summary>
  11356. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11357. /// </summary>
  11358. /// <returns></returns>
  11359. [HttpPost]
  11360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11361. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11362. {
  11363. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11364. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11365. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11366. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11367. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11368. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11369. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11370. var checkboxInfo = new Grp_EnterExitCostDraft()
  11371. {
  11372. Id = draftId,
  11373. ProvinceId = dto.ProvinceId,
  11374. CreateUserId = currUserId
  11375. };
  11376. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11377. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11378. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11379. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11380. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11381. if (draftId <= 0) //add
  11382. {
  11383. checkboxInfo.CreateUserId = dto.CurrUserId;
  11384. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11385. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11386. if (add < 1) return Ok(JsonView(false));
  11387. }
  11388. else //update
  11389. {
  11390. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11391. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11392. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11393. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11394. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11395. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11396. .Where(x => x.Id == draftId)
  11397. .ExecuteCommandAsync();
  11398. if (upd < 1) return Ok(JsonView(false));
  11399. }
  11400. return Ok(JsonView(new { parentId = draftId }));
  11401. }
  11402. /// <summary>
  11403. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11404. /// </summary>
  11405. /// <returns></returns>
  11406. [HttpPost]
  11407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11408. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11409. {
  11410. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11411. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11412. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11413. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11414. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11415. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11416. info.ProvinceId = dto.ProvinceId;
  11417. info.FirstItemRemark = dto.FirstItemRemark;
  11418. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11419. if (id <= 0) //add
  11420. {
  11421. info.CreateUserId = dto.CurrUserId;
  11422. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11423. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11424. if (add < 1) return Ok(JsonView(false));
  11425. id = add;
  11426. }
  11427. else //update
  11428. {
  11429. var upd = await _sqlSugar.Updateable(info)
  11430. .UpdateColumns(x => new
  11431. {
  11432. x.ChoiceOne,
  11433. x.InsidePay,
  11434. x.VisaRemark,
  11435. x.Visa,
  11436. x.Service,
  11437. x.Safe,
  11438. x.Ticket,
  11439. x.HeSuan,
  11440. x.YiMiao,
  11441. x.FirstItemRemark
  11442. })
  11443. .Where(x => x.Id == id)
  11444. .ExecuteCommandAsync();
  11445. if (upd < 1) return Ok(JsonView(false));
  11446. }
  11447. ////消息通知
  11448. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11449. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11450. }
  11451. /// <summary>
  11452. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11453. /// </summary>
  11454. /// <returns></returns>
  11455. [HttpPost]
  11456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11457. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11458. {
  11459. int id = dto.DraftId;
  11460. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11461. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11462. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11463. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11464. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11465. info.ProvinceId = dto.ProvinceId;
  11466. info.OutsideJJPay = dto.OutsideJJPay;
  11467. info.OutsideGWPay = dto.OutsideGWPay;
  11468. info.OutsideTDPay = dto.OutsideTDPay;
  11469. info.AirJJ = dto.AirJJ;
  11470. info.AirGW = dto.AirGW;
  11471. info.AirTD = dto.AirTD;
  11472. info.CityTranffic = dto.CityTranffic;
  11473. info.TwoItemRemark = dto.TwoItemRemark;
  11474. info.SumJJC = dto.ChoiceTwoJJ;
  11475. info.SumGWC = dto.ChoiceTwoGW;
  11476. info.SumTDC = dto.ChoiceTwoTD;
  11477. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11478. if (id <= 0) //add
  11479. {
  11480. info.CreateUserId = dto.CurrUserId;
  11481. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11482. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11483. if (addId <= 0) return Ok(JsonView(false));
  11484. id = addId;
  11485. }
  11486. else //update
  11487. {
  11488. var upd = await _sqlSugar.Updateable(info)
  11489. .UpdateColumns(x => new
  11490. {
  11491. x.SumJJC,
  11492. x.OutsideJJPay,
  11493. x.SumGWC,
  11494. x.OutsideGWPay,
  11495. x.SumTDC,
  11496. x.OutsideTDPay,
  11497. x.AirJJ,
  11498. x.AirGW,
  11499. x.AirTD,
  11500. x.CityTranffic,
  11501. x.TwoItemRemark
  11502. })
  11503. .Where(x => x.Id == id)
  11504. .ExecuteCommandAsync();
  11505. if (upd < 1) return Ok(JsonView(false));
  11506. }
  11507. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11508. gwcItemTotal = info.AirGW + info.CityTranffic;
  11509. tdcItemTotal = info.AirTD + info.CityTranffic;
  11510. ////消息通知
  11511. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11512. return Ok(JsonView(new
  11513. {
  11514. parentId = id,
  11515. choiceTwoJJ = dto.ChoiceTwoJJ,
  11516. jjcItemTotal = jjcItemTotal,
  11517. choiceTwoGW = dto.ChoiceTwoGW,
  11518. gwcItemTotal = gwcItemTotal,
  11519. choiceTwoTD = dto.ChoiceTwoTD,
  11520. tdcItemTotal = tdcItemTotal
  11521. }));
  11522. }
  11523. /// <summary>
  11524. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11525. /// </summary>
  11526. /// <returns></returns>
  11527. [HttpPost]
  11528. [ApiExplorerSettings(IgnoreApi = true)]
  11529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11530. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11531. {
  11532. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11533. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11534. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11535. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11536. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11537. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11538. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11539. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11540. {
  11541. Id = x.Id,
  11542. ParentId = dto.DraftId,
  11543. Type = dto.FeeType,
  11544. Days = x.Days,
  11545. NationalTravelFeeId = x.NationalTravelFeeId,
  11546. Cost = x.Cost,
  11547. Currency = x.Currency,
  11548. SubTotal = x.SubTotal,
  11549. CreateUserId = dto.CurrUserId
  11550. })
  11551. .ToList();
  11552. var adds = infos.Where(x => x.Id <= 0).ToList();
  11553. var upds = infos.Where(x => x.Id > 0).ToList();
  11554. if (adds.Count > 0)
  11555. {
  11556. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11557. if (add < 1) return Ok(JsonView(false));
  11558. }
  11559. if (upds.Count > 0)
  11560. {
  11561. var upd = await _sqlSugar.Updateable(adds)
  11562. .UpdateColumns(x => new
  11563. {
  11564. x.Days,
  11565. x.NationalTravelFeeId,
  11566. x.Cost,
  11567. x.Currency,
  11568. x.SubTotal
  11569. })
  11570. .WhereColumns(x => new { x.Id })
  11571. .ExecuteCommandAsync();
  11572. if (upd < 1) return Ok(JsonView(false));
  11573. }
  11574. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11575. ////消息通知
  11576. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11577. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11578. return Ok(JsonView(new { itemTotal = itemTotal }));
  11579. }
  11580. /// <summary>
  11581. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11582. /// </summary>
  11583. /// <returns></returns>
  11584. [HttpPost]
  11585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11586. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11587. {
  11588. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11589. int subId = dto.SubId, feeType = dto.FeeType;
  11590. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11591. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11592. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11593. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11594. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11595. subInfo.Id = subId;
  11596. subInfo.ParentId = dto.DraftId;
  11597. if (feeType == 3) subInfo.Type = 1;
  11598. else if (feeType == 4) subInfo.Type = 2;
  11599. else if (feeType == 5) subInfo.Type = 3;
  11600. else if (feeType == 6) subInfo.Type = 4;
  11601. subInfo.CreateUserId = dto.CurrUserId;
  11602. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11603. if (parentId < 1) return Ok(JsonView(false));
  11604. //子表op
  11605. if (subId < 1)
  11606. {
  11607. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11608. if (subAdd < 1) return Ok(JsonView(false));
  11609. }
  11610. else
  11611. {
  11612. var subUpd = await _sqlSugar.Updateable(subInfo)
  11613. .UpdateColumns(x => new
  11614. {
  11615. x.Days,
  11616. x.NationalTravelFeeId,
  11617. x.Cost,
  11618. x.Currency,
  11619. x.SubTotal
  11620. })
  11621. .WhereColumns(x => new { x.Id })
  11622. .ExecuteCommandAsync();
  11623. if (subUpd < 1) return Ok(JsonView(false));
  11624. }
  11625. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11626. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11627. }
  11628. /// <summary>
  11629. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11630. /// </summary>
  11631. /// <returns></returns>
  11632. [HttpPost]
  11633. [ApiExplorerSettings(IgnoreApi = true)]
  11634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11635. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11636. {
  11637. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11638. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11639. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11640. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11641. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11642. {
  11643. Id = x.Id,
  11644. ParentId = dto.DraftId,
  11645. SetDataId = x.SetDataId,
  11646. Index = x.Index,
  11647. Cost = x.Cost,
  11648. Currency = x.Currency,
  11649. SubTotal = x.SubTotal,
  11650. CreateUserId = dto.CurrUserId,
  11651. Remark = x.Remark
  11652. }).ToList();
  11653. var adds = infos.Where(x => x.Id <= 0).ToList();
  11654. var upds = infos.Where(x => x.Id > 0).ToList();
  11655. if (adds.Count > 0)
  11656. {
  11657. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11658. if (add < 1) return Ok(JsonView(false));
  11659. }
  11660. if (upds.Count > 0)
  11661. {
  11662. var upd = await _sqlSugar.Updateable(adds)
  11663. .UpdateColumns(x => new
  11664. {
  11665. x.Index,
  11666. x.SetDataId,
  11667. x.Cost,
  11668. x.Currency,
  11669. x.SubTotal,
  11670. x.Remark
  11671. })
  11672. .WhereColumns(x => new { x.Id })
  11673. .ExecuteCommandAsync();
  11674. if (upd < 1) return Ok(JsonView(false));
  11675. }
  11676. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11677. //消息通知
  11678. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11679. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11680. return Ok(JsonView(new { itemTotal = itemTotal }));
  11681. }
  11682. /// <summary>
  11683. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11684. /// </summary>
  11685. /// <returns></returns>
  11686. [HttpPost]
  11687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11688. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11689. {
  11690. int subId = dto.SubId, id = dto.DraftId;
  11691. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11692. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11693. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11694. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11695. subInfo.Id = subId;
  11696. subInfo.ParentId = id;
  11697. subInfo.CreateUserId = dto.CurrUserId;
  11698. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11699. if (parentId < 1) return Ok(JsonView(false));
  11700. #region 子表op
  11701. if (subId < 1)//add
  11702. {
  11703. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11704. if (subAdd < 1) return Ok(JsonView(false));
  11705. }
  11706. else //upd
  11707. {
  11708. var subUpd = await _sqlSugar.Updateable(subInfo)
  11709. .UpdateColumns(x => new
  11710. {
  11711. x.Index,
  11712. x.SetDataId,
  11713. x.Cost,
  11714. x.Currency,
  11715. x.SubTotal,
  11716. x.Remark
  11717. })
  11718. .WhereColumns(x => new { x.Id })
  11719. .ExecuteCommandAsync();
  11720. if (subUpd < 1) return Ok(JsonView(false));
  11721. }
  11722. #endregion
  11723. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11724. ////消息通知
  11725. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11726. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11727. }
  11728. /// <summary>
  11729. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11730. /// </summary>
  11731. /// <returns></returns>
  11732. [HttpPost]
  11733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11734. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11735. {
  11736. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11737. if (data.Code != 0)
  11738. {
  11739. return Ok(JsonView(false, data.Msg));
  11740. }
  11741. return Ok(JsonView(true, "操作成功!", data.Data));
  11742. }
  11743. /// <summary>
  11744. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11745. /// </summary>
  11746. /// <param name="dto"></param>
  11747. /// <returns></returns>
  11748. [HttpPost]
  11749. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11750. {
  11751. var data = new Grp_DayOtherPriceDraft()
  11752. {
  11753. Id = dto.Id,
  11754. IsDel = 1,
  11755. DeleteUserId = dto.DeleteUserId,
  11756. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11757. };
  11758. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11759. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11760. return Ok(JsonView(false, "删除失败!"));
  11761. }
  11762. #endregion
  11763. #endregion
  11764. #region 团组经理模块 出入境费用报价表
  11765. /// <summary>
  11766. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11767. /// </summary>
  11768. /// <returns></returns>
  11769. [HttpPost]
  11770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11771. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11772. {
  11773. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11774. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11775. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11776. initRates.Insert(0, cnyInfo);
  11777. liveRates.Insert(0, cnyInfo);
  11778. return Ok(JsonView(true, "查询成功!", new
  11779. {
  11780. InitRates = initRates,
  11781. LiveRates = liveRates
  11782. }));
  11783. }
  11784. /// <summary>
  11785. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11786. /// </summary>
  11787. /// <returns></returns>
  11788. [HttpPost]
  11789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11790. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11791. {
  11792. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11793. }
  11794. /// <summary>
  11795. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11796. /// </summary>
  11797. /// <returns></returns>
  11798. [HttpPost]
  11799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11800. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11801. {
  11802. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11803. }
  11804. /// <summary>
  11805. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11806. /// </summary>
  11807. /// <returns></returns>
  11808. [HttpPost]
  11809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11810. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11811. {
  11812. int groupId = dto.DiId,
  11813. currUserId = dto.CurrUserId;
  11814. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11815. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11816. //验证报价数据是否存在
  11817. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11818. if (isNull != null)
  11819. {
  11820. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11821. if (!info1.Rates.Any())
  11822. {
  11823. var rates = await GeneralMethod.EnterExitCostInitRate();
  11824. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11825. info1.Rates = rates.ToArray();
  11826. }
  11827. return Ok(JsonView(info1));
  11828. }
  11829. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11830. result.GroupId = groupId;
  11831. //处理报价名称
  11832. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11833. if (groupInfo != null)
  11834. {
  11835. var visitCountry = groupInfo.VisitCountry;
  11836. if (!string.IsNullOrEmpty(visitCountry))
  11837. {
  11838. string quoteName = string.Empty;
  11839. if (visitCountry.Contains("|"))
  11840. {
  11841. var countrys = visitCountry.Split("|");
  11842. quoteName = string.Join("、", countrys);
  11843. }
  11844. else quoteName = visitCountry;
  11845. quoteName += $"团组报价表";
  11846. result.Name = quoteName;
  11847. }
  11848. }
  11849. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11850. if (info.Code != StatusCodes.Status200OK)
  11851. {
  11852. if (!result.Rates.Any())
  11853. {
  11854. var rates = await GeneralMethod.EnterExitCostInitRate();
  11855. result.Rates = rates.ToArray();
  11856. }
  11857. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11858. }
  11859. var infoView = info.Data as EnterExitCostInfoView;
  11860. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11861. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11862. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11863. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11864. var eecRates = infoView.Currencys;
  11865. //默认添加人名币
  11866. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11867. {
  11868. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11869. }
  11870. //处理团组人数
  11871. int pplNum = 1;
  11872. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11873. var views = new List<QuoteSubItemInfo>();
  11874. #region 数据填充
  11875. var intTravelCosts = new List<QuoteSubItemInfo>();
  11876. #region 机票费用 1354
  11877. int intTravelIndex = 1;
  11878. if (infoView.SumJJC == 1)
  11879. {
  11880. intTravelCosts.Add(new QuoteSubItemInfo
  11881. {
  11882. ItemId = 1354,
  11883. Index = intTravelIndex,
  11884. FeeName = "经济舱",
  11885. UnitPrice = infoView.AirJJ,
  11886. Currency = "CNY",
  11887. Quantity = 1,
  11888. PplNum = 1,
  11889. TotalAmt = infoView.AirJJ,
  11890. Remark = "",
  11891. });
  11892. intTravelIndex++;
  11893. }
  11894. if (infoView.SumGWC == 1)
  11895. {
  11896. intTravelCosts.Add(new QuoteSubItemInfo
  11897. {
  11898. ItemId = 1354,
  11899. Index = intTravelIndex,
  11900. FeeName = "公务舱",
  11901. UnitPrice = infoView.AirGW,
  11902. Currency = "CNY",
  11903. Quantity = 1,
  11904. PplNum = 1,
  11905. TotalAmt = infoView.AirGW,
  11906. Remark = "",
  11907. });
  11908. intTravelIndex++;
  11909. }
  11910. if (infoView.SumTDC == 1)
  11911. {
  11912. intTravelCosts.Add(new QuoteSubItemInfo
  11913. {
  11914. ItemId = 1354,
  11915. Index = intTravelIndex,
  11916. FeeName = "头等舱",
  11917. UnitPrice = infoView.AirTD,
  11918. Currency = "CNY",
  11919. Quantity = 1,
  11920. PplNum = 1,
  11921. TotalAmt = infoView.AirTD,
  11922. Remark = "",
  11923. });
  11924. intTravelIndex++;
  11925. }
  11926. intTravelCosts.Add(new QuoteSubItemInfo
  11927. {
  11928. ItemId = 1354,
  11929. Index = intTravelIndex,
  11930. FeeName = "城市间交通费用",
  11931. UnitPrice = infoView.CityTranffic,
  11932. Currency = "CNY",
  11933. Quantity = 1,
  11934. PplNum = pplNum,
  11935. TotalAmt = infoView.CityTranffic * pplNum,
  11936. Remark = "",
  11937. });
  11938. views.AddRange(intTravelCosts);
  11939. #endregion
  11940. var accomCosts = new List<QuoteSubItemInfo>();
  11941. #region 住宿费 1355
  11942. if (infoView.QuarterageData.Any())
  11943. {
  11944. int accomIndex = 1;
  11945. int accomItemTypeId = 1355;
  11946. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11947. foreach (var item in groupData)
  11948. {
  11949. string feeName = string.Empty;
  11950. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11951. if (countryInfo != null)
  11952. {
  11953. feeName = countryInfo.Country;
  11954. var city = countryInfo.City;
  11955. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11956. {
  11957. feeName += $"-{city}";
  11958. }
  11959. }
  11960. var hotelInfo = item.FirstOrDefault();
  11961. if (hotelInfo == null) continue;
  11962. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11963. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11964. int quantity = item.ToList().Count;
  11965. accomCosts.Add(new QuoteSubItemInfo
  11966. {
  11967. ItemId = accomItemTypeId,
  11968. Index = accomIndex,
  11969. FeeName = feeName,
  11970. UnitPrice = hotelInfo.Cost,
  11971. Currency = thisCurrency,
  11972. Quantity = quantity,
  11973. PplNum = pplNum,
  11974. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11975. Remark = "",
  11976. });
  11977. accomIndex++;
  11978. }
  11979. views.AddRange(accomCosts);
  11980. }
  11981. #endregion
  11982. var mealCosts = new List<QuoteSubItemInfo>();
  11983. #region 餐饮费 1356
  11984. if (infoView.BoardWagesData.Any())
  11985. {
  11986. var mealIndex = 1;
  11987. int mealItemTypeId = 1356;
  11988. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11989. foreach (var item in groupData)
  11990. {
  11991. string feeName = string.Empty;
  11992. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11993. if (countryInfo != null)
  11994. {
  11995. feeName = countryInfo.Country;
  11996. var city = countryInfo.City;
  11997. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11998. {
  11999. feeName += $"-{city}";
  12000. }
  12001. }
  12002. var mealInfo = item.FirstOrDefault();
  12003. if (mealInfo == null) continue;
  12004. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12005. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12006. int quantity = item.ToList().Count;
  12007. mealCosts.Add(new QuoteSubItemInfo
  12008. {
  12009. ItemId = mealItemTypeId,
  12010. Index = mealIndex,
  12011. FeeName = feeName,
  12012. UnitPrice = mealInfo.Cost,
  12013. Currency = thisCurrency,
  12014. Quantity = quantity,
  12015. PplNum = pplNum,
  12016. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12017. Remark = "",
  12018. });
  12019. mealIndex++;
  12020. }
  12021. views.AddRange(mealCosts);
  12022. }
  12023. #endregion
  12024. var miscCosts = new List<QuoteSubItemInfo>();
  12025. #region 公杂费 1364
  12026. if (infoView.MiscellaneousFeeData.Any())
  12027. {
  12028. var miscIndex = 1;
  12029. int miscItemTypeId = 1364;
  12030. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12031. foreach (var item in groupData)
  12032. {
  12033. string feeName = string.Empty;
  12034. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12035. if (countryInfo != null)
  12036. {
  12037. feeName = countryInfo.Country;
  12038. var city = countryInfo.City;
  12039. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12040. {
  12041. feeName += $"-{city}";
  12042. }
  12043. }
  12044. var miscInfo = item.FirstOrDefault();
  12045. if (miscInfo == null) continue;
  12046. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12047. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12048. int quantity = item.ToList().Count;
  12049. miscCosts.Add(new QuoteSubItemInfo
  12050. {
  12051. ItemId = miscItemTypeId,
  12052. Index = miscIndex,
  12053. FeeName = feeName,
  12054. UnitPrice = miscInfo.Cost,
  12055. Currency = thisCurrency,
  12056. Quantity = quantity,
  12057. PplNum = pplNum,
  12058. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12059. Remark = "",
  12060. });
  12061. miscIndex++;
  12062. }
  12063. views.AddRange(miscCosts);
  12064. }
  12065. #endregion
  12066. #region 签证+保险 1362
  12067. int visaInsIndex = 1;
  12068. int visaInsItemTypeId = 1362;
  12069. if (infoView.Visa > 0)
  12070. {
  12071. views.Add(new QuoteSubItemInfo()
  12072. {
  12073. ItemId = visaInsItemTypeId,
  12074. Index = visaInsIndex,
  12075. FeeName = $"签证",
  12076. UnitPrice = infoView.Visa,
  12077. Currency = $"CNY",
  12078. Quantity = 1,
  12079. PplNum = pplNum,
  12080. TotalAmt = infoView.Visa * pplNum,
  12081. Remark = "",
  12082. });
  12083. visaInsIndex++;
  12084. }
  12085. if (infoView.Safe > 0)
  12086. {
  12087. views.Add(new QuoteSubItemInfo()
  12088. {
  12089. ItemId = visaInsItemTypeId,
  12090. Index = visaInsIndex,
  12091. FeeName = $"保险",
  12092. UnitPrice = infoView.Safe,
  12093. Currency = $"CNY",
  12094. Quantity = 1,
  12095. PplNum = pplNum,
  12096. TotalAmt = infoView.Safe * pplNum,
  12097. Remark = "",
  12098. });
  12099. }
  12100. #endregion
  12101. #region 服务费 1363
  12102. int serviceFeeIndex = 1;
  12103. int serviceFeeItemTypeId = 1363;
  12104. if (infoView.Service > 0)
  12105. {
  12106. views.Add(new QuoteSubItemInfo()
  12107. {
  12108. ItemId = serviceFeeItemTypeId,
  12109. Index = serviceFeeIndex,
  12110. FeeName = $"服务费",
  12111. UnitPrice = infoView.Service,
  12112. Currency = $"CNY",
  12113. Quantity = 1,
  12114. PplNum = pplNum,
  12115. TotalAmt = infoView.Service * pplNum,
  12116. Remark = "",
  12117. });
  12118. }
  12119. #endregion
  12120. #endregion
  12121. if (result.FeeItems.Any())
  12122. {
  12123. result.FeeItems.Select(x =>
  12124. {
  12125. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12126. if (feeInfos.Any()) x.Infos = feeInfos;
  12127. return x;
  12128. }
  12129. ).OrderBy(x => x.Index)
  12130. .ToList();
  12131. if (!result.Rates.Any())
  12132. {
  12133. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12134. else
  12135. {
  12136. var rates = await GeneralMethod.EnterExitCostInitRate();
  12137. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12138. result.Rates = rates.ToArray();
  12139. }
  12140. }
  12141. }
  12142. return Ok(JsonView(result));
  12143. }
  12144. /// <summary>
  12145. /// 团组模块 - 出入境费用报价表 - Info
  12146. /// </summary>
  12147. /// <returns></returns>
  12148. [HttpPost]
  12149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12150. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12151. {
  12152. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12153. if (!info.Rates.Any())
  12154. {
  12155. var rates = await GeneralMethod.EnterExitCostInitRate();
  12156. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12157. info.Rates = rates.ToArray();
  12158. }
  12159. return Ok(JsonView(info));
  12160. }
  12161. /// <summary>
  12162. /// 团组模块 - 出入境费用报价表 - OP
  12163. /// </summary>
  12164. /// <returns></returns>
  12165. [HttpPost]
  12166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12167. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12168. {
  12169. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12170. }
  12171. /// <summary>
  12172. /// 团组模块 - 出入境费用报价表 - 删除 项
  12173. /// </summary>
  12174. /// <returns></returns>
  12175. [HttpPost]
  12176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12177. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12178. {
  12179. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12180. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12181. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12182. }
  12183. /// <summary>
  12184. /// 团组模块 - 出入境费用报价表 - 导出
  12185. /// </summary>
  12186. /// <returns></returns>
  12187. [HttpPost]
  12188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12189. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12190. {
  12191. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12192. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12193. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12194. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12195. var rates = info.Rates;
  12196. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12197. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12198. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12199. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12200. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12201. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12202. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12203. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12204. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12205. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12206. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12207. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12208. //获取模板
  12209. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12210. var designer = new WorkbookDesigner();
  12211. designer.Workbook = new Workbook(tempPath);
  12212. designer.SetDataSource("QuoteName", info.Name);
  12213. designer.SetDataSource("CompanyTitle", "公司名称");
  12214. designer.SetDataSource("CompanyLabel", "");
  12215. #region 国际旅费
  12216. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12217. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12218. {
  12219. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12220. StringBuilder label = new StringBuilder();
  12221. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12222. if (infos.Any())
  12223. {
  12224. label.Append(infos.Sum(x => x.PplNum));
  12225. label.Append("人全程机票:");
  12226. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12227. label.AppendLine("元");
  12228. }
  12229. foreach (var item in intTravelCosts.Infos)
  12230. {
  12231. label.Append(item.FeeName);
  12232. label.Append(":");
  12233. label.Append(item.UnitPrice.TruncDecimals(2));
  12234. label.Append("元/人*");
  12235. label.Append(item.PplNum);
  12236. label.AppendLine("人");
  12237. }
  12238. if (label.HasValue())
  12239. {
  12240. label.Append("\r\n以上小计:");
  12241. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12242. label.Append("元");
  12243. }
  12244. designer.SetDataSource("IntTravelLabel", label.ToString());
  12245. }
  12246. #endregion
  12247. #region 住宿费
  12248. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12249. if (accomCosts != null && accomCosts.Infos.Any())
  12250. {
  12251. string currencyName = string.Empty,
  12252. countryName = string.Empty;
  12253. decimal rate = 1.0000M;
  12254. StringBuilder label = new StringBuilder();
  12255. label.AppendLine("全程五星酒店,每人1间房");
  12256. foreach (var item in accomCosts.Infos)
  12257. {
  12258. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12259. string name = string.Empty, thisCountryName = string.Empty;
  12260. if (item.FeeName.Contains("-"))
  12261. {
  12262. var feeName = item.FeeName.Split('-');
  12263. thisCountryName = feeName[0];
  12264. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12265. name = feeName[1];
  12266. }
  12267. else name = item.FeeName;
  12268. string thisFeeName = string.Empty;
  12269. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12270. else thisFeeName = $"\r\n{name}:";
  12271. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12272. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12273. rate = rateInfo?.Rate ?? 1.0000M;
  12274. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12275. label.AppendLine(subLabel);
  12276. }
  12277. if (label.HasValue())
  12278. {
  12279. //以上小计:52440元(美金汇率:7.5 )
  12280. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12281. label.AppendLine(subLabel);
  12282. }
  12283. designer.SetDataSource("AccomLabel", label.ToString());
  12284. }
  12285. #endregion
  12286. #region 餐饮费
  12287. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12288. if (mealCosts != null && mealCosts.Infos.Any())
  12289. {
  12290. string currencyName = string.Empty;
  12291. decimal rate = 1.0000M;
  12292. StringBuilder label = new StringBuilder();
  12293. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12294. foreach (var item in mealCosts.Infos)
  12295. {
  12296. string name = string.Empty;
  12297. if (item.FeeName.Contains("-"))
  12298. {
  12299. var feeName = item.FeeName.Split('-');
  12300. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12301. }
  12302. else name = $"\r\n{item.FeeName}:";
  12303. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12304. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12305. rate = rateInfo?.Rate ?? 1.0000M;
  12306. label.Append(name);
  12307. label.Append(item.UnitPrice.TruncDecimals(2));
  12308. label.Append(currencyName);
  12309. label.Append("/天*");
  12310. label.Append(item.Quantity.ToString("#0"));
  12311. label.Append("*");
  12312. label.Append(item.PplNum);
  12313. label.Append("人\r\n");
  12314. }
  12315. if (label.HasValue())
  12316. {
  12317. label.Append("\r\n以上小计:");
  12318. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12319. label.Append("元\r\n(");
  12320. label.Append("汇率:");
  12321. label.Append(rate.TruncDecimals(4));
  12322. label.Append(")");
  12323. }
  12324. designer.SetDataSource("MealLabel", label.ToString());
  12325. }
  12326. #endregion
  12327. #region 车辆安排
  12328. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12329. if (vehArranges != null && vehArranges.Infos.Any())
  12330. {
  12331. string currencyName = string.Empty;
  12332. //decimal rate = 1.0000M;
  12333. StringBuilder label = new StringBuilder();
  12334. foreach (var item in vehArranges.Infos)
  12335. {
  12336. label.AppendLine();
  12337. label.AppendLine();
  12338. label.Append(item.FeeName);
  12339. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12340. }
  12341. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12342. }
  12343. #endregion
  12344. #region 邀请函发放对象
  12345. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12346. designer.SetDataSource("InviteToContent", "");
  12347. #endregion
  12348. #region 邀请函费
  12349. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12350. StringBuilder is_label = new StringBuilder();
  12351. if (inviteCosts != null && inviteCosts.Infos.Any())
  12352. {
  12353. string currencyName = string.Empty;
  12354. decimal rate = 1.0000M;
  12355. foreach (var item in inviteCosts.Infos)
  12356. {
  12357. //乌兹别克斯坦:2000美金
  12358. currencyName = item.Currency;
  12359. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12360. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12361. is_label.AppendLine(label);
  12362. }
  12363. if (is_label.HasValue())
  12364. {
  12365. //以上小计:28500元(美金汇率:7.5)
  12366. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12367. is_label.AppendLine(label);
  12368. }
  12369. }
  12370. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12371. #endregion
  12372. #region 邀请函发放时间
  12373. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12374. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12375. #endregion
  12376. #region 公务活动(含翻译)
  12377. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12378. StringBuilder oa_label = new StringBuilder();
  12379. if (officialActs != null && officialActs.Infos.Any())
  12380. {
  12381. string currencyName = string.Empty;
  12382. decimal rate = 1.0000M;
  12383. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12384. foreach (var item in officialActs.Infos)
  12385. {
  12386. //乌兹别克斯坦:1000美金/场
  12387. currencyName = item.Currency;
  12388. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12389. string label_remark = string.Empty;
  12390. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12391. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12392. }
  12393. label_content += "*总费用中未含超出公务活动价格";
  12394. //8场公务活动(以上小计:60000元)
  12395. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12396. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12397. oa_label.AppendLine(label_title);
  12398. oa_label.AppendLine(label_content);
  12399. }
  12400. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12401. #endregion
  12402. #region 签证+保险
  12403. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12404. StringBuilder vi_label = new StringBuilder();
  12405. if (visaIns != null && visaIns.Infos.Any())
  12406. {
  12407. foreach (var item in visaIns.Infos)
  12408. {
  12409. //签证:500元/人
  12410. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12411. vi_label.AppendLine(label);
  12412. }
  12413. if (vi_label.HasValue())
  12414. {
  12415. //以上小计:6000元
  12416. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12417. vi_label.AppendLine(label);
  12418. }
  12419. }
  12420. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12421. #endregion
  12422. #region 服务费
  12423. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12424. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12425. #endregion
  12426. #region 公杂费
  12427. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12428. StringBuilder pm_label = new StringBuilder();
  12429. if (pubMiscs != null && pubMiscs.Infos.Any())
  12430. {
  12431. string currencyName = string.Empty,
  12432. countryName = string.Empty;
  12433. decimal rate = 1.0000M;
  12434. foreach (var item in pubMiscs.Infos)
  12435. {
  12436. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12437. string name = string.Empty, thisCountryName = string.Empty;
  12438. if (item.FeeName.Contains("-"))
  12439. {
  12440. var feeName = item.FeeName.Split('-');
  12441. thisCountryName = feeName[0];
  12442. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12443. name = feeName[1];
  12444. }
  12445. else name = item.FeeName;
  12446. string thisFeeName = string.Empty;
  12447. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12448. else thisFeeName = $"\r\n{name}:";
  12449. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12450. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12451. rate = rateInfo?.Rate ?? 1.0000M;
  12452. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12453. pm_label.AppendLine(label);
  12454. }
  12455. if (pm_label.HasValue())
  12456. {
  12457. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12458. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12459. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12460. pm_label.AppendLine(string.Format("部分发放成员"));
  12461. }
  12462. }
  12463. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12464. #endregion
  12465. #region 税费
  12466. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12467. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12468. #endregion
  12469. #region 合计(单位:元)
  12470. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12471. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12472. #endregion
  12473. #region 汇率 Remark
  12474. var rate_label = new StringBuilder();
  12475. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12476. foreach (var item in rateGroups)
  12477. {
  12478. //美元汇率按\r\n1:7.5
  12479. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12480. rate_label.AppendLine(label);
  12481. }
  12482. designer.SetDataSource("RateLabel", rate_label.ToString());
  12483. #endregion
  12484. designer.Process();
  12485. //文件名
  12486. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12487. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12488. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12489. return Ok(JsonView(true, "成功", url));
  12490. }
  12491. #endregion
  12492. #region 签证费用录入
  12493. /// <summary>
  12494. /// 根据diid查询签证费用列表
  12495. /// </summary>
  12496. /// <param name="dto"></param>
  12497. /// <returns></returns>
  12498. [HttpPost]
  12499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12500. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12501. {
  12502. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12503. if (groupData.Code != 0)
  12504. {
  12505. return Ok(JsonView(false, groupData.Msg));
  12506. }
  12507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12508. }
  12509. /// <summary>
  12510. /// 根据签证费用Id查询单条数据及c表数据
  12511. /// </summary>
  12512. /// <param name="dto"></param>
  12513. /// <returns></returns>
  12514. [HttpPost]
  12515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12516. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12517. {
  12518. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12519. if (groupData.Code != 0)
  12520. {
  12521. return Ok(JsonView(false, groupData.Msg));
  12522. }
  12523. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12524. }
  12525. /// <summary>
  12526. /// 签证费用删除
  12527. /// </summary>
  12528. /// <param name="dto"></param>
  12529. /// <returns></returns>
  12530. [HttpPost]
  12531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12532. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12533. {
  12534. _sqlSugar.BeginTran();
  12535. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12536. if (!res)
  12537. {
  12538. _sqlSugar.RollbackTran();
  12539. return Ok(JsonView(false, "删除失败"));
  12540. }
  12541. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12542. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12543. .SetColumns(a => new Grp_CreditCardPayment()
  12544. {
  12545. IsDel = 1,
  12546. DeleteUserId = dto.DeleteUserId,
  12547. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12548. })
  12549. .ExecuteCommand();
  12550. if (resSub < 1)
  12551. {
  12552. _sqlSugar.RollbackTran();
  12553. return Ok(JsonView(false, "删除失败"));
  12554. }
  12555. _sqlSugar.CommitTran();
  12556. return Ok(JsonView(true, "删除成功!"));
  12557. }
  12558. /// <summary>
  12559. /// 签证费用录入下拉框初始化
  12560. /// </summary>
  12561. /// <returns></returns>
  12562. [HttpPost]
  12563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12564. public async Task<IActionResult> VisaPriceAddSelect()
  12565. {
  12566. //支付方式
  12567. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12568. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12569. //币种
  12570. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12571. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12572. //乘客类型
  12573. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12574. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12575. //卡类型
  12576. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12577. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12578. //代办费类型
  12579. var agencyFeeTypeData = new List<dynamic>() {
  12580. new { id = 0 , Text = "未选择" },
  12581. new { id = 1 , Text = "小公务" },
  12582. new { id = 2 , Text = "大公务" },
  12583. };
  12584. //签证费用标准国家Data
  12585. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12586. var data = new
  12587. {
  12588. Payment = _Payment,
  12589. CurrencyList = _CurrencyList,
  12590. PassengerType = _PassengerType,
  12591. BankCard = _BankCard,
  12592. AgencyFeeType = agencyFeeTypeData,
  12593. CountryFeeData = visaCountryFeeData
  12594. };
  12595. return Ok(JsonView(true, "查询成功!", data));
  12596. }
  12597. /// <summary>
  12598. /// 签证费用录入操作(Status:1.新增,2.修改)
  12599. /// </summary>
  12600. /// <param name="dto"></param>
  12601. /// <returns></returns>
  12602. [HttpPost]
  12603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12604. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12605. {
  12606. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12607. if (groupData.Code != 0)
  12608. {
  12609. return Ok(JsonView(false, groupData.Msg));
  12610. }
  12611. #region 应用推送
  12612. try
  12613. {
  12614. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12615. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12616. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12617. //2024-10-21 新增LZ UID
  12618. var userIds = new List<int>() { 21 };
  12619. string title = $"系统通知";
  12620. string content = "";
  12621. var diId = dto.DiId;
  12622. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12623. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12624. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12625. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12626. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12627. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12628. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12629. }
  12630. catch (Exception ex)
  12631. {
  12632. }
  12633. #endregion
  12634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12635. }
  12636. #endregion
  12637. #region 签证提成录入
  12638. /// <summary>
  12639. /// 签证提成录入
  12640. /// 基础数据
  12641. /// </summary>
  12642. /// <returns></returns>
  12643. [HttpGet]
  12644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12645. public async Task<IActionResult> VisaCommissionInit()
  12646. {
  12647. return Ok(await _visaCommissionRep.Init());
  12648. }
  12649. /// <summary>
  12650. /// 签证提成录入
  12651. /// Item
  12652. /// </summary>
  12653. /// <param name="_dto"></param>
  12654. /// <returns></returns>
  12655. [HttpPost]
  12656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12657. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12658. {
  12659. var validator = new VisaCommissionItemDtoValidator();
  12660. var validatorRes = await validator.ValidateAsync(_dto);
  12661. if (!validatorRes.IsValid)
  12662. {
  12663. StringBuilder sb = new StringBuilder();
  12664. foreach (var item in validatorRes.Errors)
  12665. {
  12666. sb.AppendLine(item.ErrorMessage);
  12667. }
  12668. return Ok(JsonView(false, sb.ToString()));
  12669. }
  12670. return Ok(await _visaCommissionRep.Item(_dto));
  12671. }
  12672. /// <summary>
  12673. /// 签证提成录入
  12674. /// Save
  12675. /// </summary>
  12676. /// <param name="_dto"></param>
  12677. /// <returns></returns>
  12678. [HttpPost]
  12679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12680. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12681. {
  12682. //参数验证
  12683. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12684. foreach (var item in _dto.Items)
  12685. {
  12686. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12687. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12688. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12689. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12690. }
  12691. return Ok(await _visaCommissionRep.Save(_dto));
  12692. }
  12693. /// <summary>
  12694. /// 签证提成录入
  12695. /// Create
  12696. /// </summary>
  12697. /// <param name="_dto"></param>
  12698. /// <returns></returns>
  12699. [HttpPost]
  12700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12701. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12702. {
  12703. var validator = new VisaCommissionCreateDtoValidator();
  12704. var validatorRes = await validator.ValidateAsync(_dto);
  12705. if (!validatorRes.IsValid)
  12706. {
  12707. StringBuilder sb = new StringBuilder();
  12708. foreach (var item in validatorRes.Errors)
  12709. {
  12710. sb.AppendLine(item.ErrorMessage);
  12711. }
  12712. return Ok(JsonView(false, sb.ToString()));
  12713. }
  12714. return Ok(await _visaCommissionRep.Create(_dto));
  12715. }
  12716. /// <summary>
  12717. /// 签证提成录入
  12718. /// Put(编辑)
  12719. /// </summary>
  12720. /// <param name="id"></param>
  12721. /// <param name="_dto"></param>
  12722. /// <returns></returns>
  12723. [HttpPut]
  12724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12725. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12726. {
  12727. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12728. var validator = new VisaCommissionCreateDtoValidator();
  12729. var validatorRes = await validator.ValidateAsync(_dto);
  12730. if (!validatorRes.IsValid)
  12731. {
  12732. StringBuilder sb = new StringBuilder();
  12733. foreach (var item in validatorRes.Errors)
  12734. {
  12735. sb.AppendLine(item.ErrorMessage);
  12736. }
  12737. return Ok(JsonView(false, sb.ToString()));
  12738. }
  12739. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12740. }
  12741. /// <summary>
  12742. /// 签证提成录入
  12743. /// Del
  12744. /// </summary>
  12745. /// <param name="id"></param>
  12746. /// <param name="currUserId"></param>
  12747. /// <returns></returns>
  12748. [HttpPost]
  12749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12750. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12751. {
  12752. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12753. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12754. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12755. }
  12756. #endregion
  12757. #region op费用录入
  12758. /// <summary>
  12759. /// 根据diid查询op费用列表
  12760. /// </summary>
  12761. /// <param name="dto"></param>
  12762. /// <returns></returns>
  12763. [HttpPost]
  12764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12765. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12766. {
  12767. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12768. if (groupData.Code != 0)
  12769. {
  12770. return Ok(JsonView(false, groupData.Msg));
  12771. }
  12772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12773. }
  12774. /// <summary>
  12775. /// 根据op费用Id查询单条数据及c表数据
  12776. /// </summary>
  12777. /// <param name="dto"></param>
  12778. /// <returns></returns>
  12779. [HttpPost]
  12780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12781. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12782. {
  12783. try
  12784. {
  12785. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12786. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12787. var data = new
  12788. {
  12789. CarTouristGuideGround = _groupData,
  12790. CreditCardPayment = _creditCardPayment
  12791. };
  12792. return Ok(JsonView(true, "查询成功!", data));
  12793. }
  12794. catch (Exception ex)
  12795. {
  12796. return Ok(JsonView(false, "程序错误!"));
  12797. }
  12798. }
  12799. /// <summary>
  12800. /// op费用删除
  12801. /// </summary>
  12802. /// <param name="dto"></param>
  12803. /// <returns></returns>
  12804. [HttpPost]
  12805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12806. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12807. {
  12808. try
  12809. {
  12810. _sqlSugar.BeginTran();
  12811. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12812. if (!res)
  12813. {
  12814. return Ok(JsonView(false, "删除失败"));
  12815. }
  12816. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12817. {
  12818. IsDel = 1,
  12819. DeleteUserId = dto.DeleteUserId,
  12820. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12821. }).ExecuteCommandAsync();
  12822. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12823. {
  12824. IsDel = 1,
  12825. DeleteUserId = dto.DeleteUserId,
  12826. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12827. }).ExecuteCommandAsync();
  12828. #region 删除超支相关数据
  12829. //删除导入的超支数据
  12830. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12831. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12832. {
  12833. IsDel = 1,
  12834. DeleteUserId = dto.DeleteUserId,
  12835. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12836. }).ExecuteCommand();
  12837. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12838. {
  12839. IsDel = 1,
  12840. DeleteUserId = dto.DeleteUserId,
  12841. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12842. }).ExecuteCommand();
  12843. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12844. {
  12845. IsDel = 1,
  12846. DeleteUserId = dto.DeleteUserId,
  12847. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12848. }).ExecuteCommand();
  12849. #endregion
  12850. _sqlSugar.CommitTran();
  12851. return Ok(JsonView(true, "删除成功!"));
  12852. }
  12853. catch (Exception ex)
  12854. {
  12855. _sqlSugar.RollbackTran();
  12856. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12857. }
  12858. }
  12859. /// <summary>
  12860. /// op费用录入操作(Status:1.新增,2.修改)
  12861. /// </summary>
  12862. /// <param name="dto"></param>
  12863. /// <returns></returns>
  12864. [HttpPost]
  12865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12866. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12867. {
  12868. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12869. if (groupData.Code != 0)
  12870. {
  12871. return Ok(JsonView(false, groupData.Msg));
  12872. }
  12873. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12874. }
  12875. /// <summary>
  12876. /// 填写费用详细页面初始化绑定
  12877. /// </summary>
  12878. /// <param name="dto"></param>
  12879. /// <returns></returns>
  12880. [HttpPost]
  12881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12882. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12883. {
  12884. try
  12885. {
  12886. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12887. if (groupData.Code != 0)
  12888. {
  12889. return Ok(JsonView(false, groupData.Msg));
  12890. }
  12891. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12892. }
  12893. catch (Exception ex)
  12894. {
  12895. return Ok(JsonView(false, ex.Message));
  12896. }
  12897. }
  12898. /// <summary>
  12899. /// 根据op费用Id查询详细数据
  12900. /// </summary>
  12901. /// <param name="dto"></param>
  12902. /// <returns></returns>
  12903. [HttpPost]
  12904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12905. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12906. {
  12907. try
  12908. {
  12909. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12910. if (groupData.Code != 0)
  12911. {
  12912. return Ok(JsonView(false, groupData.Msg));
  12913. }
  12914. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12915. }
  12916. catch (Exception ex)
  12917. {
  12918. return Ok(JsonView(false, ex.Message));
  12919. }
  12920. }
  12921. /// <summary>
  12922. /// OP费用录入填写详情
  12923. /// </summary>
  12924. /// <param name="dto"></param>
  12925. /// <returns></returns>
  12926. [HttpPost]
  12927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12928. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12929. {
  12930. try
  12931. {
  12932. #region 参数校验
  12933. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12934. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12935. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12936. #endregion
  12937. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12938. if (groupData.Code != 0)
  12939. {
  12940. return Ok(JsonView(false, groupData.Msg));
  12941. }
  12942. //自动审核
  12943. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12944. #region 应用推送
  12945. try
  12946. {
  12947. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12948. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12949. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12950. //2024-10-21 新增LZ UID
  12951. var userIds = new List<int>() { 21 };
  12952. string title = $"系统通知";
  12953. var diId = dto.DiId;
  12954. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12955. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12956. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12957. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12958. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12959. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12960. }
  12961. catch (Exception ex)
  12962. {
  12963. }
  12964. #endregion
  12965. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12966. }
  12967. catch (Exception ex)
  12968. {
  12969. return Ok(JsonView(false, ex.Message));
  12970. }
  12971. }
  12972. /// <summary>
  12973. /// 获取三公详细所有城市
  12974. /// </summary>
  12975. /// <returns></returns>
  12976. [HttpGet]
  12977. public IActionResult OpCarCityResult()
  12978. {
  12979. var jw = JsonView(false);
  12980. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12981. {
  12982. x.Id,
  12983. x.Country,
  12984. x.City,
  12985. }).ToList();
  12986. if (data.Count > 0)
  12987. {
  12988. jw = JsonView(true, "获取成功!", data);
  12989. }
  12990. else
  12991. {
  12992. jw.Msg = "城市数据为空!";
  12993. jw.Data = new string[0];
  12994. }
  12995. return Ok(jw);
  12996. }
  12997. /// <summary>
  12998. /// 导出地接费用明细
  12999. /// </summary>
  13000. /// <param name="dto"></param>
  13001. /// <returns></returns>
  13002. [HttpPost]
  13003. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13004. {
  13005. var jw = JsonView(false);
  13006. if (dto.Diid < 1)
  13007. {
  13008. jw.Msg = "请输入正确的diid!";
  13009. return Ok(jw);
  13010. }
  13011. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13012. if (group == null)
  13013. {
  13014. jw.Msg = "未找到团组信息!";
  13015. return Ok(jw);
  13016. }
  13017. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13018. if (localGuideArr.Count == 0)
  13019. {
  13020. jw.Msg = "该团组暂无地接信息!";
  13021. return Ok(jw);
  13022. }
  13023. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13024. var overspendSoure = new Dictionary<int, int>
  13025. {
  13026. { 91, 982 }, //车
  13027. { 92 , 1059} ,//导游
  13028. { 994 , 1073}, //翻译
  13029. { 988 , 1074 }, //早餐
  13030. { 93 , 1075 }, //午餐
  13031. { 989 , 1076 }, //晚餐
  13032. };
  13033. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  13034. foreach (var groupArr in localGroup)
  13035. {
  13036. var keyValue = groupArr.Key;
  13037. if (int.TryParse(keyValue, out int cityid))
  13038. {
  13039. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13040. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13041. }
  13042. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13043. foreach (var item in groupArr)
  13044. {
  13045. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13046. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13047. new Grp_CarTouristGuideGroundReservationsContentExtend
  13048. {
  13049. Count = a.Count,
  13050. CreateTime = a.CreateTime,
  13051. CreateUserId = a.CreateUserId,
  13052. CTGGRId = a.CTGGRId,
  13053. Currency = a.Currency,
  13054. DatePrice = a.DatePrice,
  13055. DeleteTime = a.DeleteTime,
  13056. DeleteUserId = a.DeleteUserId,
  13057. DiId = a.DiId,
  13058. Id = a.Id,
  13059. IsDel = a.IsDel,
  13060. Price = a.Price,
  13061. PriceContent = a.PriceContent,
  13062. Remark = a.Remark,
  13063. SId = a.SId,
  13064. SidName = b.Name,
  13065. Units = a.Units,
  13066. }
  13067. ).ToList();
  13068. if (content.Count > 0)
  13069. {
  13070. contentArr.Add(content);
  13071. }
  13072. }
  13073. //open excel
  13074. //set excel
  13075. //save excel
  13076. try
  13077. {
  13078. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13079. IWorkbook workbook;
  13080. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13081. {
  13082. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13083. }
  13084. else
  13085. {
  13086. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13087. }
  13088. ISheet sheet = workbook.GetSheetAt(0);
  13089. var rowStartIndex = 2;
  13090. var clounmCount = 10;
  13091. var initStyleRow = sheet.GetRow(2);
  13092. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13093. //var overspendArrDetail =
  13094. var existsId = new List<CarCompare>();
  13095. var lastElem = arr.Last();
  13096. var thisSid = -1;
  13097. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13098. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13099. {
  13100. Name = "未知币种!",
  13101. Remark = "未知币种!",
  13102. };
  13103. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13104. Action cloneRowFn = () =>
  13105. {
  13106. rowStartIndex++;
  13107. var cloneRow = sheet.CreateRow(rowStartIndex);
  13108. // 复制样式
  13109. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13110. {
  13111. ICell sourceCell = initStyleRow.GetCell(i);
  13112. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13113. // 确保单元格存在样式
  13114. if (sourceCell.CellStyle != null)
  13115. {
  13116. targetCell.CellStyle = sourceCell.CellStyle;
  13117. }
  13118. }
  13119. };
  13120. var mergeRow = () =>
  13121. {
  13122. for (int i = 2; i < sheet.LastRowNum; i++)
  13123. {
  13124. var row = sheet.GetRow(i);
  13125. var cellFirst = row.GetCell(0);
  13126. var thisIndex = i + 1;
  13127. while (thisIndex < sheet.LastRowNum)
  13128. {
  13129. var nextRow = sheet.GetRow(thisIndex);
  13130. var nextCellFirst = nextRow.GetCell(0);
  13131. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13132. {
  13133. thisIndex++;
  13134. }
  13135. else
  13136. {
  13137. break;
  13138. }
  13139. }
  13140. thisIndex--;
  13141. if (thisIndex != i)
  13142. {
  13143. //合并row
  13144. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13145. i, // 起始行索引(0-based)
  13146. thisIndex, // 结束行索引(0-based)
  13147. 0, // 起始列索引(0-based)
  13148. 0 // 结束列索引(0-based)
  13149. );
  13150. sheet.AddMergedRegion(cellRangeAddress);
  13151. i = thisIndex;
  13152. }
  13153. }
  13154. };
  13155. var chaoshiNumber = 0;
  13156. var totalNumber = 0.00M;
  13157. string lastStr = "";
  13158. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13159. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13160. {
  13161. b.IsAuditGM,
  13162. x.Id,
  13163. x.Area,
  13164. b.PayPercentage,
  13165. b.PayMoney,
  13166. }).ToList();
  13167. string yesPayment = "", noPayment = "";
  13168. foreach (var item in queryCarArrByCityAndDiid)
  13169. {
  13170. if (item.IsAuditGM == 1)
  13171. {
  13172. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13173. }
  13174. else
  13175. {
  13176. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13177. }
  13178. }
  13179. lastStr = yesPayment + noPayment;
  13180. foreach (var item in arr)
  13181. {
  13182. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  13183. {
  13184. if (thisSid != item.SId)
  13185. {
  13186. if (thisSid == -1)
  13187. {
  13188. thisSid = item.SId;
  13189. }
  13190. else
  13191. {
  13192. //合并小计行
  13193. //创建合并区域的实例
  13194. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13195. rowStartIndex, // 起始行索引(0-based)
  13196. rowStartIndex, // 结束行索引(0-based)
  13197. 0, // 起始列索引(0-based)
  13198. 3 // 结束列索引(0-based)
  13199. );
  13200. sheet.AddMergedRegion(cellRangeAddress);
  13201. var CellStyle = workbook.CreateCellStyle();
  13202. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13203. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13204. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13205. for (int i = 0; i <= clounmCount; i++)
  13206. {
  13207. if (i > 6)
  13208. {
  13209. var CellStyle1 = workbook.CreateCellStyle();
  13210. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13211. IFont Font = workbook.CreateFont(); // 创建字体
  13212. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13213. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13214. CellStyle1.SetFont(Font);
  13215. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13216. }
  13217. else
  13218. {
  13219. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13220. }
  13221. }
  13222. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13223. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13224. //超时合计
  13225. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13226. //超时数
  13227. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13228. //超时合计费用
  13229. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13230. thisSid = item.SId;
  13231. cloneRowFn();
  13232. chaoshiNumber = 0;
  13233. totalNumber = 0;
  13234. }
  13235. }
  13236. IRow row = sheet.GetRow(rowStartIndex);
  13237. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13238. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13239. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13240. if (isOpenOverspendSoure)
  13241. {
  13242. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13243. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13244. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13245. }
  13246. for (int i = 0; i <= clounmCount; i++)
  13247. {
  13248. var cell = row.GetCell(i);
  13249. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13250. if (cell == null)
  13251. {
  13252. cell = row.CreateCell(i);
  13253. }
  13254. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13255. fontRed.CloneStyleFrom(cell.CellStyle);
  13256. IFont Font = workbook.CreateFont(); // 创建字体
  13257. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13258. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13259. fontRed.SetFont(Font);
  13260. byte[] rgb = new byte[3] { 255, 242, 204 };
  13261. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13262. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13263. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13264. if (workbook is XSSFWorkbook)
  13265. {
  13266. BackgroundColor255_242_204.FillForegroundColor = 0;
  13267. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13268. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13269. }
  13270. else
  13271. {
  13272. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13273. }
  13274. if (i == 1 || i > 6)
  13275. {
  13276. if (i > 6)
  13277. {
  13278. fontRed.FillForegroundColor = 0;
  13279. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13280. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13281. }
  13282. cell.CellStyle = fontRed;
  13283. }
  13284. if (i > 2 && i < 7)
  13285. {
  13286. cell.CellStyle = BackgroundColor255_242_204;
  13287. }
  13288. cell.SetCellValue(setCellValue); //写入单元格
  13289. }
  13290. if (overspendSoure.ContainsKey(thisSid))
  13291. {
  13292. var overspendId = overspendSoure[thisSid];
  13293. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13294. }
  13295. cloneRowFn();
  13296. existsId.Add(new CarCompare
  13297. {
  13298. DataPrice = item.DatePrice.ObjToDate(),
  13299. Sid = item.SId
  13300. });
  13301. }
  13302. if (item.Equals(lastElem))
  13303. {
  13304. //合并小计行
  13305. //创建合并区域的实例
  13306. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13307. rowStartIndex, // 起始行索引(0-based)
  13308. rowStartIndex, // 结束行索引(0-based)
  13309. 0, // 起始列索引(0-based)
  13310. 3 // 结束列索引(0-based)
  13311. );
  13312. sheet.AddMergedRegion(cellRangeAddress);
  13313. var CellStyle = workbook.CreateCellStyle();
  13314. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13315. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13316. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13317. for (int i = 0; i <= clounmCount; i++)
  13318. {
  13319. if (i > 6)
  13320. {
  13321. var CellStyle1 = workbook.CreateCellStyle();
  13322. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13323. IFont Font = workbook.CreateFont(); // 创建字体
  13324. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13325. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13326. CellStyle1.SetFont(Font);
  13327. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13328. }
  13329. else
  13330. {
  13331. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13332. }
  13333. }
  13334. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13335. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13336. //超时合计
  13337. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13338. //超时数
  13339. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13340. //超时合计费用
  13341. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13342. cloneRowFn();
  13343. // 创建合并区域的实例
  13344. cellRangeAddress = new CellRangeAddress(
  13345. rowStartIndex, // 起始行索引(0-based)
  13346. rowStartIndex, // 结束行索引(0-based)
  13347. 0, // 起始列索引(0-based)
  13348. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13349. );
  13350. // 添加合并区域
  13351. sheet.AddMergedRegion(cellRangeAddress);
  13352. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13353. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13354. }
  13355. }
  13356. mergeRow();
  13357. // 保存修改后的Excel文件到新文件
  13358. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13359. // new FileStream(newFilePath, FileMode.CreateNew)
  13360. using (var stream = new MemoryStream())
  13361. {
  13362. workbook.Write(stream, true);
  13363. stream.Flush();
  13364. stream.Seek(0, SeekOrigin.Begin);
  13365. MemoryStream memoryStream = new MemoryStream();
  13366. stream.CopyTo(memoryStream);
  13367. memoryStream.Seek(0, SeekOrigin.Begin);
  13368. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13369. }
  13370. workbook.Close();
  13371. workbook.Dispose();
  13372. }
  13373. catch (Exception ex)
  13374. {
  13375. jw.Msg = "出现异常!" + ex.Message;
  13376. return Ok(jw);
  13377. }
  13378. }
  13379. if (Zips.Count > 0)
  13380. {
  13381. IOOperatorHelper io = new IOOperatorHelper();
  13382. var byts = io.ConvertZipStream(Zips);
  13383. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13384. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13385. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13386. }
  13387. else
  13388. {
  13389. jw.Msg = "暂无生成文件!";
  13390. }
  13391. return Ok(jw);
  13392. }
  13393. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13394. {
  13395. string outStr = string.Empty;
  13396. switch (i)
  13397. {
  13398. case 0:
  13399. outStr = arr[0].SidName;
  13400. break;
  13401. case 1:
  13402. outStr = arr[0].DataPriceStr;
  13403. break;
  13404. case 2:
  13405. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13406. break;
  13407. case 4:
  13408. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13409. break;
  13410. case 7:
  13411. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13412. {
  13413. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13414. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13415. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13416. }
  13417. break;
  13418. case 8:
  13419. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13420. {
  13421. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13422. }
  13423. break;
  13424. case 9:
  13425. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13426. {
  13427. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13428. }
  13429. break;
  13430. case 10:
  13431. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13432. {
  13433. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13434. }
  13435. break;
  13436. }
  13437. return outStr;
  13438. }
  13439. #region OP行程单
  13440. /// <summary>
  13441. /// OP行程单初始化
  13442. /// </summary>
  13443. /// <param name="dto"></param>
  13444. /// <returns></returns>
  13445. [HttpPost]
  13446. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13447. {
  13448. var jw = JsonView(false);
  13449. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13450. var group = groupList.First();
  13451. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13452. if (group == null)
  13453. {
  13454. jw.Msg = "暂无团组!";
  13455. return Ok(jw);
  13456. }
  13457. group = groupList.Find(x => x.Id == diid);
  13458. if (group == null)
  13459. {
  13460. jw.Msg = "请输入正确的团组ID!";
  13461. return Ok(jw);
  13462. }
  13463. string city = string.Empty;
  13464. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13465. if (blackCode.Count > 0)
  13466. {
  13467. var black = blackCode.First();
  13468. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13469. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13470. if (blackSp.Length > 0)
  13471. {
  13472. try
  13473. {
  13474. var cityArrCode = new List<string>(20);
  13475. foreach (var item in blackSp)
  13476. {
  13477. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13478. var IndexSelect = itemSp[2];
  13479. var cityArrCodeLength = cityArrCode.Count - 1;
  13480. var startCity = IndexSelect.Substring(0, 3);
  13481. if (cityArrCodeLength > 0)
  13482. {
  13483. var arrEndCity = cityArrCode[cityArrCodeLength];
  13484. if (arrEndCity != startCity)
  13485. {
  13486. cityArrCode.Add(startCity.ToUpper());
  13487. }
  13488. }
  13489. else
  13490. {
  13491. cityArrCode.Add(startCity.ToUpper());
  13492. }
  13493. var endCity = IndexSelect.Substring(3, 3);
  13494. cityArrCode.Add(endCity.ToUpper());
  13495. }
  13496. var cityThree = string.Empty;
  13497. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13498. cityThree = cityThree.TrimEnd(',');
  13499. if (string.IsNullOrWhiteSpace(cityThree))
  13500. {
  13501. throw new
  13502. Exception("error");
  13503. }
  13504. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13505. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13506. foreach (var item in cityArrCode)
  13507. {
  13508. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13509. if (find != null)
  13510. {
  13511. city += find.City + "/";
  13512. }
  13513. else
  13514. {
  13515. city += item + "三字码未收入/";
  13516. }
  13517. }
  13518. city = city.TrimEnd('/');
  13519. }
  13520. catch (Exception e)
  13521. {
  13522. city = "黑屏代码格式不正确!";
  13523. }
  13524. }
  13525. }
  13526. else
  13527. {
  13528. city = "未录入黑屏代码";
  13529. }
  13530. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13531. {
  13532. Date = x.Date,
  13533. Days = x.Days,
  13534. Diffgroup = x.Diffgroup,
  13535. Diid = x.Diid,
  13536. Traffic_First = x.Traffic_First,
  13537. Traffic_Second = x.Traffic_Second,
  13538. Trip = x.Trip,
  13539. WeekDay = x.WeekDay,
  13540. Id = x.Id
  13541. }).ToList();
  13542. jw.Data = new
  13543. {
  13544. groupList = groupList.Select(x => new
  13545. {
  13546. x.Id,
  13547. x.TeamName,
  13548. x.TourCode
  13549. }).ToList(),
  13550. groupInfo = new
  13551. {
  13552. group.VisitDays,
  13553. group.TourCode,
  13554. group.VisitPNumber,
  13555. group.TeamName,
  13556. city
  13557. },
  13558. OpTravelList
  13559. };
  13560. jw.Code = 200;
  13561. jw.Msg = "操作成功!";
  13562. return Ok(jw);
  13563. }
  13564. /// <summary>
  13565. /// 删除团组行程单
  13566. /// </summary>
  13567. /// <returns></returns>
  13568. [HttpPost]
  13569. public IActionResult DelTravel(DelOpTravelDto dto)
  13570. {
  13571. var jw = JsonView(false);
  13572. if (dto.UserId <= 0 || dto.Diid <= 0)
  13573. {
  13574. jw.Msg = "请输入正确的参数!";
  13575. return Ok(jw);
  13576. }
  13577. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13578. .SetColumns(x => new Grp_TravelList
  13579. {
  13580. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13581. DeleteUserId = dto.UserId,
  13582. IsDel = 1,
  13583. }).ExecuteCommand();
  13584. jw = JsonView(true);
  13585. return Ok(jw);
  13586. }
  13587. /// <summary>
  13588. /// 行程单保存
  13589. /// </summary>
  13590. /// <returns></returns>
  13591. [HttpPost]
  13592. public IActionResult TravelSave(TravelSaveDto dto)
  13593. {
  13594. var jw = JsonView(false);
  13595. if (dto.Arr.Count > 0)
  13596. {
  13597. try
  13598. {
  13599. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13600. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13601. .ToList();
  13602. _sqlSugar.BeginTran();
  13603. foreach (var item in dto.Arr)
  13604. {
  13605. if (item.Id == 0)
  13606. {
  13607. throw new Exception("请传入正确的Id");
  13608. }
  13609. //比较上一次的差异
  13610. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13611. if (findTravel != null)
  13612. {
  13613. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13614. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13615. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13616. }
  13617. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13618. .SetColumns(x => new Grp_TravelList
  13619. {
  13620. Trip = item.Trip
  13621. }).ExecuteCommand();
  13622. }
  13623. _sqlSugar.CommitTran();
  13624. jw = JsonView(true);
  13625. }
  13626. catch (Exception ex)
  13627. {
  13628. _sqlSugar.RollbackTran();
  13629. jw.Msg = "程序异常!" + ex.Message;
  13630. }
  13631. }
  13632. else
  13633. {
  13634. jw.Msg = "请传入正确的参数!";
  13635. }
  13636. return Ok(jw);
  13637. }
  13638. private string CheckStr(string original, string changed)
  13639. {
  13640. // 创建diff_match_patch对象
  13641. var dmp = new diff_match_patch();
  13642. // 计算差异
  13643. List<Diff> diffs = dmp.diff_main(original, changed);
  13644. // 清理和合并差异
  13645. dmp.diff_cleanupSemantic(diffs);
  13646. // 使用StringBuilder构建最终的字符串
  13647. StringBuilder finalString = new StringBuilder();
  13648. // 输出差异结果,并构建变动后的字符串
  13649. foreach (Diff diff in diffs)
  13650. {
  13651. switch (diff.operation)
  13652. {
  13653. case Operation.EQUAL:
  13654. // 相等的部分,直接添加到最终字符串
  13655. finalString.Append(diff.text);
  13656. break;
  13657. case Operation.INSERT:
  13658. // 插入的部分,添加标记并添加到最终字符串
  13659. finalString.Append("[++]" + diff.text + "[++]");
  13660. break;
  13661. case Operation.DELETE:
  13662. // 删除的部分,不添加到最终字符串
  13663. //finalString.Append("[++]" + diff.text + "[++]");
  13664. break;
  13665. }
  13666. }
  13667. // 输出变动后的字符串
  13668. return finalString.ToString();
  13669. }
  13670. private class tagContent
  13671. {
  13672. public DateTime Date { get; set; }
  13673. public string StartTag { get; set; }
  13674. public string EndTag { get; set; }
  13675. public string Content { get; set; }
  13676. public static int tagLength { get { return 3; } }
  13677. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13678. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13679. public bool IsFinally { get; set; }
  13680. }
  13681. private List<string> ExtractContentBetweenTags(string input, string tag)
  13682. {
  13683. List<string> results = new List<string>();
  13684. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13685. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13686. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13687. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13688. string[] strValueArr = new string[1];
  13689. foreach (System.Text.RegularExpressions.Match match in matches)
  13690. {
  13691. var strValue = match.Groups[1].Value;
  13692. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13693. }
  13694. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13695. return results;
  13696. }
  13697. /// <summary>
  13698. /// 导出行程单
  13699. /// </summary>
  13700. /// <param name="dto"></param>
  13701. /// <returns></returns>
  13702. [HttpPost]
  13703. public IActionResult ExportTravel(ExportTravelDto dto)
  13704. {
  13705. var jw = JsonView(false);
  13706. jw.Data = "";
  13707. int diid = 0;
  13708. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13709. if (Find == null)
  13710. {
  13711. jw.Msg = "请选择正确的团组!";
  13712. return Ok(jw);
  13713. }
  13714. else
  13715. {
  13716. diid = Find.Id;
  13717. }
  13718. //数据源
  13719. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13720. DataTable dtBlack = null;
  13721. try
  13722. {
  13723. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13724. }
  13725. catch (Exception)
  13726. {
  13727. jw.Msg = "机票黑屏代码有误!";
  13728. return Ok(jw);
  13729. }
  13730. string CityStr = string.Empty;
  13731. if (dtBlack.Rows.Count == 0)
  13732. {
  13733. jw.Msg = "机票黑屏代码有误!";
  13734. return Ok(jw);
  13735. }
  13736. else
  13737. {
  13738. foreach (DataRow row in dtBlack.Rows)
  13739. {
  13740. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13741. {
  13742. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13743. return Ok(jw);
  13744. }
  13745. }
  13746. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13747. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13748. }
  13749. // 指定的文字
  13750. var targetTextDic = new Dictionary<string, List<string>>();
  13751. //创建数据源Table
  13752. DataTable dtSource = new DataTable();
  13753. dtSource.Columns.Add("Days", typeof(string));
  13754. dtSource.Columns.Add("Date", typeof(string));
  13755. dtSource.Columns.Add("Week", typeof(string));
  13756. dtSource.Columns.Add("Traffic", typeof(string));
  13757. dtSource.Columns.Add("Trip", typeof(string));
  13758. //获取数据,放到datatable
  13759. foreach (var item in _travelList)
  13760. {
  13761. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13762. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13763. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13764. .Replace("[++]", string.Empty);
  13765. DataRow dr = dtSource.NewRow();
  13766. dr["Days"] = item.Days;
  13767. dr["Date"] = item.Date;
  13768. dr["Week"] = item.WeekDay;
  13769. dr["Traffic"] = item.Traffic_First
  13770. + "\r\n"
  13771. + item.Traffic_Second;
  13772. dr["Trip"] = item.Trip;
  13773. dtSource.Rows.Add(dr);
  13774. }
  13775. Dictionary<string, string> dic = new Dictionary<string, string>();
  13776. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13777. dic.Add("City", CityStr);
  13778. dic.Add("Days", Find.VisitDays.ToString());
  13779. dic.Add("DeleCode", Find.TourCode);
  13780. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13781. //模板路径
  13782. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13783. //载入模板
  13784. Document doc = null;
  13785. DocumentBuilder builder = null;
  13786. try
  13787. {
  13788. //载入模板
  13789. doc = new Document(tempPath);
  13790. builder = new DocumentBuilder(doc);
  13791. }
  13792. catch (Exception)
  13793. {
  13794. jw.Msg = "模板位置不存在!";
  13795. return Ok(jw);
  13796. }
  13797. foreach (var key in dic.Keys)
  13798. {
  13799. Bookmark bookmark = doc.Range.Bookmarks[key];
  13800. if (bookmark != null)
  13801. {
  13802. builder.MoveToBookmark(key);
  13803. builder.Write(dic[key]);
  13804. }
  13805. }
  13806. //获取word里所有表格
  13807. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13808. //获取所填表格的序数
  13809. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13810. try
  13811. {
  13812. //循环赋值
  13813. for (int i = 0; i < dtSource.Rows.Count; i++)
  13814. {
  13815. builder.MoveToCell(0, i + 1, 0, 0);
  13816. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13817. builder.MoveToCell(0, i + 1, 1, 0);
  13818. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13819. builder.MoveToCell(0, i + 1, 2, 0);
  13820. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13821. var trip = dtSource.Rows[i]["Trip"].ToString();
  13822. builder.MoveToCell(0, i + 1, 3, 0);
  13823. builder.Write(trip);
  13824. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13825. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13826. // 获取特定索引的段落
  13827. Paragraph paragraph = (Paragraph)paragraphs[0];
  13828. Run run = paragraph.Runs[0];
  13829. Aspose.Words.Font font = run.Font;
  13830. font.Name = "黑体";
  13831. //设置双休红色
  13832. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13833. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13834. paragraph = (Paragraph)paragraphs[1];
  13835. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13836. {
  13837. run = paragraph.Runs[0];
  13838. font = run.Font;
  13839. font.Color = Color.Red;
  13840. }
  13841. }
  13842. }
  13843. catch (Exception ex)
  13844. {
  13845. }
  13846. //删除多余行
  13847. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13848. {
  13849. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13850. }
  13851. var targetTextList = new List<string>();
  13852. // 遍历文档中的表格
  13853. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13854. {
  13855. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13856. {
  13857. var cellIndex = 0;
  13858. foreach (Cell cell in row.Cells)
  13859. {
  13860. if (cellIndex == 1 && row.Cells.Count == 4)
  13861. {
  13862. foreach (var target in targetTextDic.Keys)
  13863. {
  13864. if (cell.GetText().Contains(target))
  13865. {
  13866. targetTextList = targetTextDic[target];
  13867. break;
  13868. }
  13869. }
  13870. }
  13871. // 遍历单元格中的所有段落
  13872. foreach (Paragraph paragraph in cell.Paragraphs)
  13873. {
  13874. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13875. List<Run> runs = new List<Run>();
  13876. foreach (Run run in paragraph.Runs)
  13877. {
  13878. runs.Add(run);
  13879. }
  13880. foreach (Run run in runs)
  13881. {
  13882. foreach (var targetText in targetTextList)
  13883. {
  13884. // 检查文字是否包含指定文字
  13885. if (run.Text.Contains(targetText))
  13886. {
  13887. // 将包含的部分设置为红色
  13888. HighlightText(run, targetText, Color.Red);
  13889. }
  13890. }
  13891. }
  13892. }
  13893. cellIndex++;
  13894. }
  13895. }
  13896. }
  13897. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13898. if (!Directory.Exists(savePath))
  13899. {
  13900. try
  13901. {
  13902. Directory.CreateDirectory(savePath);
  13903. }
  13904. catch
  13905. {
  13906. }
  13907. }
  13908. string path = savePath + Find.TeamName + "出访日程";
  13909. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13910. try
  13911. {
  13912. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13913. string postfix = ".docx";
  13914. if (dto.IsPDF == 1)
  13915. {
  13916. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13917. postfix = ".pdf";
  13918. }
  13919. doc.Save(path + postfix, saveFormat);
  13920. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13921. }
  13922. catch (Exception)
  13923. {
  13924. jw = JsonView(false);
  13925. }
  13926. return Ok(jw);
  13927. }
  13928. /// <summary>
  13929. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13930. /// </summary>
  13931. /// <param name="num"></param>
  13932. /// <returns></returns>
  13933. string GetNum(string num)
  13934. {
  13935. string str = "";
  13936. switch (num)
  13937. {
  13938. case "1":
  13939. str = "一";
  13940. break;
  13941. case "2":
  13942. str = "二";
  13943. break;
  13944. case "3":
  13945. str = "三";
  13946. break;
  13947. case "4":
  13948. str = "四";
  13949. break;
  13950. case "5":
  13951. str = "五";
  13952. break;
  13953. case "6":
  13954. str = "六";
  13955. break;
  13956. case "7":
  13957. str = "七";
  13958. break;
  13959. case "8":
  13960. str = "八";
  13961. break;
  13962. case "9":
  13963. str = "九";
  13964. break;
  13965. case "10":
  13966. str = "十";
  13967. break;
  13968. case "11":
  13969. str = "十一";
  13970. break;
  13971. case "12":
  13972. str = "十二";
  13973. break;
  13974. case "一":
  13975. str = "1";
  13976. break;
  13977. case "二":
  13978. str = "2";
  13979. break;
  13980. case "三":
  13981. str = "3";
  13982. break;
  13983. case "四":
  13984. str = "4";
  13985. break;
  13986. case "五":
  13987. str = "5";
  13988. break;
  13989. case "六":
  13990. str = "6";
  13991. break;
  13992. case "七":
  13993. str = "7";
  13994. break;
  13995. case "八":
  13996. str = "8";
  13997. break;
  13998. case "九":
  13999. str = "9";
  14000. break;
  14001. case "十":
  14002. str = "10";
  14003. break;
  14004. case "十一":
  14005. str = "11";
  14006. break;
  14007. case "十二":
  14008. str = "12";
  14009. break;
  14010. }
  14011. return str;
  14012. }
  14013. // 高亮包含指定文字的部分
  14014. void HighlightText(Run run, string targetText, Color color)
  14015. {
  14016. string text = run.Text;
  14017. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14018. if (startIndex >= 0)
  14019. {
  14020. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14021. // 前部分
  14022. if (startIndex > 0)
  14023. {
  14024. Run beforeRun = (Run)run.Clone(true);
  14025. beforeRun.Text = text.Substring(0, startIndex);
  14026. parentParagraph.InsertBefore(beforeRun, run);
  14027. }
  14028. // 匹配部分
  14029. Run matchRun = (Run)run.Clone(true);
  14030. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14031. matchRun.Font.Color = color;
  14032. parentParagraph.InsertBefore(matchRun, run);
  14033. // 后部分
  14034. if (startIndex + targetText.Length < text.Length)
  14035. {
  14036. Run afterRun = (Run)run.Clone(true);
  14037. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14038. parentParagraph.InsertBefore(afterRun, run);
  14039. }
  14040. // 删除原始Run
  14041. run.Remove();
  14042. }
  14043. }
  14044. #endregion
  14045. #endregion
  14046. #region 团组成本
  14047. /// <summary>
  14048. /// 团组成本数据初始化
  14049. /// </summary>
  14050. /// <param name="dto"></param>
  14051. /// <returns></returns>
  14052. [HttpPost]
  14053. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14054. {
  14055. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14056. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14057. WHEN COUNT(*) >= 0 THEN 'True'
  14058. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14059. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14060. ").ToList(); //团组列表
  14061. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14062. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14063. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14064. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14065. if (groupinfoValue != null)
  14066. {
  14067. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14068. var spArr = new string[1] { countryArr };
  14069. if (countryArr.Contains("|"))
  14070. {
  14071. spArr = countryArr.Split("|");
  14072. }
  14073. else if (countryArr.Contains("、"))
  14074. {
  14075. spArr = countryArr.Split("、");
  14076. }
  14077. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14078. {
  14079. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14080. if (dbQueryCountry != null)
  14081. {
  14082. visaCountryInfoArr.Add(dbQueryCountry);
  14083. }
  14084. }
  14085. }
  14086. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14087. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14088. #region 屏蔽黑屏代码生成
  14089. //var create = _GroupCostRepository.
  14090. // CreateGroupCostByBlackCode(dto.Diid);
  14091. //if (groupCost.Count == 0 && create.Code == 0)
  14092. //{
  14093. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14094. //}
  14095. #endregion
  14096. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14097. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14098. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14099. groupCostMap = groupCostMap.Select(x =>
  14100. {
  14101. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14102. {
  14103. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14104. }
  14105. return x;
  14106. }).ToList();
  14107. //GroupCostParameter.Add(new
  14108. // Grp_GroupCostParameter());
  14109. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14110. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14111. return Ok(JsonView(new
  14112. {
  14113. groupList,
  14114. groupInfo,
  14115. groupChecks,
  14116. groupCost = groupCostMap,
  14117. hotelNumber,
  14118. GroupCostParameter = GroupCostParameterMap,
  14119. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14120. {
  14121. x.VisaCountry,
  14122. x.VisaPrice,
  14123. x.Id,
  14124. IsVisaExemption = x.IsVisaExemption == 1 ? "否" : "是", //免签
  14125. IsElectronicSignature = x.IsElectronicSignature == 1 ? "否" : "是", //电子签
  14126. IsVisaOnArrival = x.IsVisaOnArrival == 1 ? "否" : "是", //落地签
  14127. x.VisaTime, // 一般签证时间
  14128. }).ToList(),
  14129. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14130. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14131. hotelIsTrue = hotelIsTrue,
  14132. }));
  14133. }
  14134. /// <summary>
  14135. /// 团组成本信息保存
  14136. /// </summary>
  14137. /// <param name="dto"></param>
  14138. /// <returns></returns>
  14139. [HttpPost]
  14140. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14141. {
  14142. if (dto.Diid <= 0 || dto.Userid <= 0)
  14143. {
  14144. return Ok(JsonView(false));
  14145. }
  14146. JsonView jw = null;
  14147. bool isTrue = false;
  14148. #region 复制团组成本
  14149. //if (dto.Diid == 2581)
  14150. //{
  14151. // dto.Diid = 2599;
  14152. // dto.CheckBoxs.ForEach(x =>
  14153. // {
  14154. // x.Diid = 2599;
  14155. // });
  14156. // dto.GroupCosts.ForEach(x =>
  14157. // {
  14158. // x.Diid = 2599;
  14159. // });
  14160. // dto.CostTypeHotelNumbers.ForEach(x =>
  14161. // {
  14162. // x.Diid = 2599;
  14163. // });
  14164. // dto.GroupCostParameters.ForEach(x =>
  14165. // {
  14166. // x.DiId = 2599;
  14167. // });
  14168. //}
  14169. #endregion
  14170. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14171. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14172. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14173. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14174. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14175. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14176. try
  14177. {
  14178. _sqlSugar.BeginTran();
  14179. isTrue = await _GroupCostRepository.
  14180. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14181. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14182. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14183. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14184. _sqlSugar.CommitTran();
  14185. jw = JsonView(true, "保存成功!", isTrue);
  14186. }
  14187. catch (Exception)
  14188. {
  14189. _sqlSugar.RollbackTran();
  14190. jw = JsonView(false);
  14191. }
  14192. return Ok(jw);
  14193. }
  14194. /// <summary>
  14195. /// 复制团组成本信息
  14196. /// </summary>
  14197. /// <param name="dto"></param>
  14198. /// <returns></returns>
  14199. [HttpPost]
  14200. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14201. {
  14202. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14203. {
  14204. return Ok(JsonView(false, "参数有误!"));
  14205. }
  14206. #region 复制团组成本
  14207. dto.Diid = dto.ToGroupId;
  14208. dto.CheckBoxs.ForEach(x =>
  14209. {
  14210. x.Diid = dto.ToGroupId;
  14211. });
  14212. dto.GroupCosts.ForEach(x =>
  14213. {
  14214. x.Diid = dto.ToGroupId;
  14215. });
  14216. dto.CostTypeHotelNumbers.ForEach(x =>
  14217. {
  14218. x.Diid = dto.ToGroupId;
  14219. });
  14220. dto.GroupCostParameters.ForEach(x =>
  14221. {
  14222. x.DiId = dto.ToGroupId;
  14223. });
  14224. #endregion
  14225. JsonView jw = null;
  14226. bool isTrue = false;
  14227. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14228. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14229. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14230. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14231. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14232. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14233. try
  14234. {
  14235. _sqlSugar.BeginTran();
  14236. isTrue = await _GroupCostRepository.
  14237. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14238. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14239. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14240. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14241. _sqlSugar.CommitTran();
  14242. jw = JsonView(true, "保存成功!", isTrue);
  14243. }
  14244. catch (Exception)
  14245. {
  14246. _sqlSugar.RollbackTran();
  14247. jw = JsonView(false);
  14248. }
  14249. return Ok(jw);
  14250. }
  14251. /// <summary>
  14252. /// 司兼导数据
  14253. /// </summary>
  14254. /// <param name="dto"></param>
  14255. /// <returns></returns>
  14256. [HttpPost]
  14257. public IActionResult GetCarGuides(CarGuidesDto dto)
  14258. {
  14259. JsonView jw = null;
  14260. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14261. jw = JsonView(true, "获取成功!", Data);
  14262. return Ok(jw);
  14263. }
  14264. /// <summary>
  14265. /// 导游数据
  14266. /// </summary>
  14267. /// <param name="dto"></param>
  14268. /// <returns></returns>
  14269. [HttpPost]
  14270. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14271. {
  14272. JsonView jw = null;
  14273. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14274. // 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
  14275. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14276. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14277. jw = JsonView(true, "获取成功!", Data);
  14278. return Ok(jw);
  14279. }
  14280. /// <summary>
  14281. /// 成本车数据
  14282. /// </summary>
  14283. /// <param name="dto"></param>
  14284. /// <returns></returns>
  14285. [HttpPost]
  14286. public IActionResult GetCarInfo(CarGuidesDto dto)
  14287. {
  14288. JsonView jw = null;
  14289. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14290. jw = JsonView(true, "获取成功!", Data);
  14291. return Ok(jw);
  14292. }
  14293. /// <summary>
  14294. /// 景点数据
  14295. /// </summary>
  14296. /// <param name="dto"></param>
  14297. /// <returns></returns>
  14298. [HttpPost]
  14299. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14300. {
  14301. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14302. return Ok(JsonView(true, "获取成功!", Data));
  14303. }
  14304. /// <summary>
  14305. /// 成本通知
  14306. /// </summary>
  14307. /// <param name="dto"></param>
  14308. /// <returns></returns>
  14309. [HttpPost]
  14310. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14311. {
  14312. if (dto.Diid < 0)
  14313. {
  14314. return Ok(JsonView(false));
  14315. }
  14316. JsonView jw = null;
  14317. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14318. if (GroupCostParameter != null)
  14319. {
  14320. int IsShare = 0;
  14321. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14322. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14323. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14324. string msg = string.Empty;
  14325. if (isTrue)
  14326. {
  14327. if (IsShare == 0)
  14328. {
  14329. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14330. }
  14331. else
  14332. {
  14333. #region 企微通知对应岗位用户
  14334. try
  14335. {
  14336. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14337. }
  14338. catch (Exception ex)
  14339. {
  14340. }
  14341. #endregion
  14342. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14343. }
  14344. jw = JsonView(isTrue, msg, new { IsShare });
  14345. }
  14346. else
  14347. {
  14348. msg = "修改失败!";
  14349. jw = JsonView(isTrue, msg);
  14350. }
  14351. }
  14352. else
  14353. {
  14354. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14355. }
  14356. return Ok(jw);
  14357. }
  14358. /// <summary>
  14359. /// 导出报价单
  14360. /// </summary>
  14361. /// <param name="dto"></param>
  14362. /// <returns></returns>
  14363. [HttpPost]
  14364. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14365. {
  14366. if (dto.Diid == 0)
  14367. {
  14368. return Ok(JsonView(false, "请传递团组id"));
  14369. }
  14370. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14371. if (deleInfo.Code != 0)
  14372. {
  14373. return Ok(JsonView(false, "团组信息查询失败!"));
  14374. }
  14375. var di = deleInfo.Data as DelegationInfoWebView;
  14376. if (di != null)
  14377. {
  14378. di.TeamName = di.TeamName.Replace("|", "、");
  14379. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14380. //文件名
  14381. string strFileName = di.TeamName + "-收款账单.doc";
  14382. //获取模板
  14383. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14384. //载入模板
  14385. Document doc = new Document(tmppath);
  14386. decimal TotalPrice = 0.00M;
  14387. string itemStr = string.Empty;
  14388. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14389. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14390. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14391. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14392. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14393. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14394. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14395. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14396. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14397. foreach (var cost in groupCostType)
  14398. {
  14399. var List = cost.ToList();
  14400. if (cost.Key == "A")
  14401. {
  14402. foreach (var ListItem in List)
  14403. {
  14404. if (ListItem.number > 0)
  14405. {
  14406. if (ListItem.code.Contains("TBR"))
  14407. {
  14408. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14409. }
  14410. else
  14411. {
  14412. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14413. }
  14414. TotalPrice += (ListItem.number * ListItem.price);
  14415. }
  14416. }
  14417. }
  14418. else
  14419. {
  14420. itemStr = itemStr.Insert(0, "A段\r\n");
  14421. itemStr += "B段\r\n";
  14422. foreach (var ListItem in List)
  14423. {
  14424. if (ListItem.number > 0)
  14425. {
  14426. if (ListItem.code.Contains("TBR"))
  14427. {
  14428. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14429. }
  14430. else
  14431. {
  14432. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14433. }
  14434. TotalPrice += (ListItem.number * ListItem.price);
  14435. }
  14436. }
  14437. }
  14438. }
  14439. #region 替换Word模板书签内容
  14440. Dictionary<string, string> marks = new Dictionary<string, string>();
  14441. marks.Add("To", di.ClientUnit);//付款方
  14442. marks.Add("ToTel", di.TellPhone);//付款方电话
  14443. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14444. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14445. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14446. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14447. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14448. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14449. marks.Add("PayItemContent", itemStr);//详细信息
  14450. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14451. #endregion
  14452. ////注
  14453. //if (doc.Range.Bookmarks["Attention"] != null)
  14454. //{
  14455. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14456. // mark.Text = frList[0].Attention;
  14457. //}
  14458. foreach (var item in marks.Keys)
  14459. {
  14460. if (doc.Range.Bookmarks[item] != null)
  14461. {
  14462. Bookmark mark = doc.Range.Bookmarks[item];
  14463. mark.Text = marks[item];
  14464. }
  14465. }
  14466. byte[] bytes = null;
  14467. using (MemoryStream stream = new MemoryStream())
  14468. {
  14469. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14470. bytes = stream.ToArray();
  14471. }
  14472. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14473. return Ok(JsonView(true, "", new
  14474. {
  14475. Data = bytes,
  14476. strFileName,
  14477. }));
  14478. }
  14479. else
  14480. {
  14481. return Ok(JsonView(false, "团组信息不存在!"));
  14482. }
  14483. }
  14484. /// <summary>
  14485. /// 导出团组成本
  14486. /// </summary>
  14487. /// <param name="dto"></param>
  14488. /// <returns></returns>
  14489. [HttpPost]
  14490. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14491. {
  14492. var jw = JsonView(false);
  14493. if (dto.Diid == 0)
  14494. {
  14495. return Ok(JsonView(false, "请传递团组id"));
  14496. }
  14497. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14498. if (deleInfo.Code != 0)
  14499. {
  14500. return Ok(JsonView(false, "团组信息查询失败!"));
  14501. }
  14502. var di = deleInfo.Data as DelegationInfoWebView;
  14503. if (di == null)
  14504. {
  14505. return Ok(JsonView(false, "团组信息查询失败!"));
  14506. }
  14507. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14508. WorkbookDesigner designer = new WorkbookDesigner();
  14509. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14510. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14511. for (int i = 0; i < List_GC.Count; i++)
  14512. {
  14513. GroupCost_Excel gc = new GroupCost_Excel();
  14514. gc.Id = List_GC[i].Id;
  14515. gc.Diid = List_GC[i].Diid.ToString();
  14516. gc.DAY = List_GC[i].DAY;
  14517. string week = "";
  14518. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14519. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14520. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14521. gc.ITIN = List_GC[i].ITIN;
  14522. gc.CarType = List_GC[i].CarType;
  14523. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14524. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14525. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14526. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14527. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14528. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14529. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14530. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14531. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14532. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14533. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14534. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14535. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14536. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14537. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14538. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14539. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14540. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14541. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14542. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14543. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14544. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14545. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14546. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14547. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14548. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14549. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14550. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14551. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14552. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14553. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14554. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14555. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14556. List_GC1.Add(gc);
  14557. }
  14558. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14559. dt.TableName = "TB";
  14560. //报表标题等不用dt的值
  14561. designer.SetDataSource("TeamName", dto.title.TeamName);
  14562. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14563. designer.SetDataSource("Tax", dto.title.Tax);
  14564. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14565. designer.SetDataSource("Currency", dto.title.Currency);
  14566. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14567. designer.SetDataSource("Rate", dto.title.Rate);
  14568. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14569. var Aparams = hotels.Find(x => x.Type == "Default");
  14570. if (Aparams == null)
  14571. {
  14572. return Ok(jw);
  14573. }
  14574. //酒店数量
  14575. var txtSGRNumber = Aparams.SGR.ToString();
  14576. var txtTBRNumber = Aparams.TBR.ToString();
  14577. var txtJSESNumber = Aparams.JSES.ToString();
  14578. var txtSUITENumbe = Aparams.SUITE.ToString();
  14579. if (dto.costType == "B")
  14580. {
  14581. Aparams = hotels.Find(x => x.Type == "A");
  14582. var Bparams = hotels.Find(x => x.Type == "B");
  14583. if (Aparams == null || Bparams == null)
  14584. {
  14585. return Ok(jw);
  14586. }
  14587. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14588. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14589. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14590. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14591. }
  14592. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14593. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14594. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14595. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14596. var ws = designer.Workbook.Worksheets[0];
  14597. int Row = List_GC.Count;
  14598. int startIndex = 11;
  14599. int HideRows = 0;
  14600. List<int> hideRowsList = new List<int>();
  14601. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14602. #region A段left数据
  14603. var left = dto.leftInfo.Find(x => x.Type == "A");
  14604. if (left == null)
  14605. {
  14606. return Ok(jw);
  14607. }
  14608. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14609. if (leftBindData != null)
  14610. {
  14611. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14612. designer.SetDataSource("VisaRS", leftBindData.rs);
  14613. designer.SetDataSource("VisaXS", leftBindData.xs);
  14614. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14615. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14616. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14617. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14618. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14619. }
  14620. else
  14621. {
  14622. hideRowsList.Add(Row + startIndex + HideRows);
  14623. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14624. }
  14625. HideRows += 2;
  14626. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14627. if (leftBindData != null)
  14628. {
  14629. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14630. designer.SetDataSource("BXRS", leftBindData.rs);
  14631. designer.SetDataSource("BXXS", leftBindData.xs);
  14632. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14633. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14634. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14635. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14636. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14637. }
  14638. else
  14639. {
  14640. hideRowsList.Add(Row + startIndex + HideRows);
  14641. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14642. }
  14643. HideRows += 2;
  14644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14645. if (leftBindData != null)
  14646. {
  14647. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14648. designer.SetDataSource("HSRS", leftBindData.rs);
  14649. designer.SetDataSource("HSXS", leftBindData.xs);
  14650. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14651. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14652. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14653. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14654. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14655. }
  14656. else
  14657. {
  14658. hideRowsList.Add(Row + startIndex + HideRows);
  14659. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14660. }
  14661. HideRows += 2;
  14662. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14663. if (leftBindData != null)
  14664. {
  14665. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14666. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14667. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14668. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14669. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14670. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14671. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14672. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14673. }
  14674. else
  14675. {
  14676. hideRowsList.Add(Row + startIndex + HideRows);
  14677. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14678. }
  14679. HideRows += 2;
  14680. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14681. if (leftBindData != null)
  14682. {
  14683. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14684. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14685. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14686. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14687. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14688. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14689. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14690. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14691. }
  14692. else
  14693. {
  14694. hideRowsList.Add(Row + startIndex + HideRows);
  14695. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14696. }
  14697. HideRows += 2;
  14698. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14699. if (leftBindData != null)
  14700. {
  14701. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14702. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14703. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14704. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14705. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14706. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14707. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14708. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14709. }
  14710. else
  14711. {
  14712. hideRowsList.Add(Row + startIndex + HideRows);
  14713. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14714. }
  14715. HideRows += 2;
  14716. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14717. if (leftBindData != null)
  14718. {
  14719. ////TBR
  14720. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14721. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14722. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14723. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14724. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14725. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14726. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14727. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14728. }
  14729. else
  14730. {
  14731. hideRowsList.Add(Row + startIndex + HideRows);
  14732. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14733. }
  14734. HideRows += 2;
  14735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14736. if (leftBindData != null)
  14737. {
  14738. ////SGR
  14739. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14740. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14741. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14742. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14743. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14744. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14745. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14746. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14747. }
  14748. else
  14749. {
  14750. hideRowsList.Add(Row + startIndex + HideRows);
  14751. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14752. }
  14753. HideRows += 2;
  14754. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14755. if (leftBindData != null)
  14756. {
  14757. ////JS/ES
  14758. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14759. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14760. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14761. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14762. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14763. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14764. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14765. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14766. }
  14767. else
  14768. {
  14769. hideRowsList.Add(Row + startIndex + HideRows);
  14770. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14771. }
  14772. HideRows += 2;
  14773. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14774. if (leftBindData != null)
  14775. {
  14776. ////SUITE
  14777. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14778. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14779. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14780. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14781. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14782. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14783. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14784. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14785. }
  14786. else
  14787. {
  14788. hideRowsList.Add(Row + startIndex + HideRows);
  14789. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14790. }
  14791. HideRows += 2;
  14792. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14793. if (leftBindData != null)
  14794. {
  14795. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14796. designer.SetDataSource("DJRS", leftBindData.rs);
  14797. designer.SetDataSource("DJXS", leftBindData.xs);
  14798. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14799. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14800. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14801. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14802. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14803. }
  14804. else
  14805. {
  14806. hideRowsList.Add(Row + startIndex + HideRows);
  14807. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14808. }
  14809. HideRows += 2;
  14810. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14811. if (leftBindData != null)
  14812. {
  14813. designer.SetDataSource("HCPCB", leftBindData.cb);
  14814. designer.SetDataSource("HCPRS", leftBindData.rs);
  14815. designer.SetDataSource("HCPXS", leftBindData.xs);
  14816. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14817. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14818. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14819. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14820. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14821. }
  14822. else
  14823. {
  14824. hideRowsList.Add(Row + startIndex + HideRows);
  14825. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14826. }
  14827. HideRows += 2;
  14828. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14829. if (leftBindData != null)
  14830. {
  14831. designer.SetDataSource("CPCB", leftBindData.cb);
  14832. designer.SetDataSource("CPRS", leftBindData.rs);
  14833. designer.SetDataSource("CPXS", leftBindData.xs);
  14834. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14835. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14836. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14837. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14838. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14839. }
  14840. else
  14841. {
  14842. hideRowsList.Add(Row + startIndex + HideRows);
  14843. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14844. }
  14845. HideRows += 2;
  14846. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14847. if (leftBindData != null)
  14848. {
  14849. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14850. designer.SetDataSource("GWRS", leftBindData.rs);
  14851. designer.SetDataSource("GWXS", leftBindData.xs);
  14852. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14853. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14854. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14855. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14856. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14857. }
  14858. else
  14859. {
  14860. hideRowsList.Add(Row + startIndex + HideRows);
  14861. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14862. }
  14863. HideRows += 2;
  14864. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14865. if (leftBindData != null)
  14866. {
  14867. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14868. designer.SetDataSource("LYJRS", leftBindData.rs);
  14869. designer.SetDataSource("LYJXS", leftBindData.xs);
  14870. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14871. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14872. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14873. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14874. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14875. }
  14876. else
  14877. {
  14878. hideRowsList.Add(Row + startIndex + HideRows);
  14879. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14880. }
  14881. #endregion
  14882. #region A段Right信息
  14883. var right = dto.rightInfo.Find(x => x.Type == "A");
  14884. if (right == null)
  14885. {
  14886. return Ok(jw);
  14887. }
  14888. HideRows += 4;
  14889. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14890. if (rightBindData != null)
  14891. {
  14892. //经济舱 + 双人间 TBR
  14893. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14894. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14895. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14896. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14897. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14898. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14899. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14900. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14901. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14902. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14903. }
  14904. else
  14905. {
  14906. hideRowsList.Add(Row + startIndex + HideRows);
  14907. }
  14908. HideRows += 2;
  14909. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14910. if (rightBindData != null)
  14911. {
  14912. //经济舱 + 单人间 SGR
  14913. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14914. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14915. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14916. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14917. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14918. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14919. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14920. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14921. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14922. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14923. }
  14924. else
  14925. {
  14926. hideRowsList.Add(Row + startIndex + HideRows);
  14927. }
  14928. HideRows += 2;
  14929. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14930. if (rightBindData != null)
  14931. {
  14932. //公务舱 + 单人间 SGR
  14933. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14934. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14935. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14936. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14937. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14938. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14939. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14940. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14941. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14942. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14943. }
  14944. else
  14945. {
  14946. hideRowsList.Add(Row + startIndex + HideRows);
  14947. }
  14948. HideRows += 2;
  14949. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14950. if (rightBindData != null)
  14951. {
  14952. //公务舱 + 小套房 JSES
  14953. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14954. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14955. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14956. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14957. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14958. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14959. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14960. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14961. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14962. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14963. }
  14964. else
  14965. {
  14966. hideRowsList.Add(Row + startIndex + HideRows);
  14967. }
  14968. HideRows += 2;
  14969. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14970. if (rightBindData != null)
  14971. {
  14972. //公务舱 + 小套房 JSES
  14973. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14974. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14975. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14976. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14977. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14978. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14979. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14980. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14981. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14982. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14983. }
  14984. else
  14985. {
  14986. hideRowsList.Add(Row + startIndex + HideRows);
  14987. }
  14988. HideRows += 2;
  14989. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14990. if (rightBindData != null)
  14991. {
  14992. //经济舱 + 大套房
  14993. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14994. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14995. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14996. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14997. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14998. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14999. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15000. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15001. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15002. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15003. }
  15004. else
  15005. {
  15006. hideRowsList.Add(Row + startIndex + HideRows);
  15007. }
  15008. HideRows += 2;
  15009. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15010. if (rightBindData != null)
  15011. {
  15012. //头等舱 + 小套房 JSES
  15013. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15014. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15015. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15016. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15017. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15018. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15019. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15020. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15021. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15022. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15023. }
  15024. else
  15025. {
  15026. hideRowsList.Add(Row + startIndex + HideRows);
  15027. }
  15028. HideRows += 2;
  15029. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15030. if (rightBindData != null)
  15031. {
  15032. //头等舱 + 大套房
  15033. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15034. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15035. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15036. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15037. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15038. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15039. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15040. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15041. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15042. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15043. }
  15044. else
  15045. {
  15046. hideRowsList.Add(Row + startIndex + HideRows);
  15047. }
  15048. #endregion
  15049. #region B段标题清空
  15050. designer.SetDataSource("CostBDRCB", "");
  15051. designer.SetDataSource("CostBRS", "");
  15052. designer.SetDataSource("CostBXS", "");
  15053. designer.SetDataSource("CostBZCB", "");
  15054. designer.SetDataSource("CostBDRBJ", "");
  15055. designer.SetDataSource("CostBZBJ", "");
  15056. designer.SetDataSource("CostBDRLR", "");
  15057. designer.SetDataSource("CostBZLR", "");
  15058. designer.SetDataSource("CostBDRCBOM", "");
  15059. designer.SetDataSource("CostBRSOM", "");
  15060. designer.SetDataSource("CostBZCBOM", "");
  15061. designer.SetDataSource("CostBDRBJOM", "");
  15062. designer.SetDataSource("CostBZBJOM", "");
  15063. designer.SetDataSource("CostBDRLROM", "");
  15064. designer.SetDataSource("CostBZLROM", "");
  15065. #endregion
  15066. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15067. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15068. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15069. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15070. designer.SetDataSource("DJName", "地接(CNY)");
  15071. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15072. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15073. designer.SetDataSource("GWName", "公务(CNY)");
  15074. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15075. designer.SetDataSource("LYJName", "零用金(CNY)");
  15076. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15077. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15078. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15079. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15080. designer.SetDataSource("BXName", "保险(CNY)");
  15081. designer.SetDataSource("VisaName", "签证(CNY)");
  15082. #region B段基本数据
  15083. if (dto.costType == "B")
  15084. {
  15085. left = dto.leftInfo.Find(x => x.Type == "B");
  15086. if (left == null)
  15087. {
  15088. return Ok(jw);
  15089. }
  15090. #region B段left数据
  15091. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15092. if (leftBindData != null)
  15093. {
  15094. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15095. designer.SetDataSource("BHSRS", leftBindData.rs);
  15096. designer.SetDataSource("BHSXS", leftBindData.xs);
  15097. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15098. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15099. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15100. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15101. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15102. }
  15103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15104. if (leftBindData != null)
  15105. {
  15106. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15107. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15108. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15109. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15110. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15111. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15112. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15113. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15114. }
  15115. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15116. if (leftBindData != null)
  15117. {
  15118. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15119. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15120. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15121. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15122. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15123. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15124. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15125. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15126. }
  15127. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15128. if (leftBindData != null)
  15129. {
  15130. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15131. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15132. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15133. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15134. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15135. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15136. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15137. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15138. }
  15139. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15140. if (leftBindData != null)
  15141. {
  15142. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15143. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15144. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15145. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15146. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15147. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15148. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15149. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15150. }
  15151. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15152. if (leftBindData != null)
  15153. {
  15154. designer.SetDataSource("BCPCB", leftBindData.cb);
  15155. designer.SetDataSource("BCPRS", leftBindData.rs);
  15156. designer.SetDataSource("BCPXS", leftBindData.xs);
  15157. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15158. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15159. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15160. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15161. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15162. }
  15163. //TBR
  15164. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15165. if (leftBindData != null)
  15166. {
  15167. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15168. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15169. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15170. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15171. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15172. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15173. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15174. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15175. }
  15176. //SGR
  15177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15178. if (leftBindData != null)
  15179. {
  15180. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15181. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15182. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15183. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15184. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15185. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15186. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15187. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15188. }
  15189. //JS/ES
  15190. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15191. if (leftBindData != null)
  15192. {
  15193. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15194. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15195. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15196. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15197. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15198. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15199. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15200. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15201. }
  15202. //SUITE
  15203. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15204. if (leftBindData != null)
  15205. {
  15206. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15207. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15208. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15209. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15210. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15211. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15212. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15213. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15214. }
  15215. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15216. if (leftBindData != null)
  15217. {
  15218. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15219. designer.SetDataSource("BDJRS", leftBindData.rs);
  15220. designer.SetDataSource("BDJXS", leftBindData.xs);
  15221. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15222. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15223. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15224. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15225. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15226. }
  15227. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15228. if (leftBindData != null)
  15229. {
  15230. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15231. designer.SetDataSource("BGWRS", leftBindData.rs);
  15232. designer.SetDataSource("BGWXS", leftBindData.xs);
  15233. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15234. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15235. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15236. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15237. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15238. }
  15239. #region 优化方案
  15240. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15241. //excelBind.Add("零用金", new {
  15242. //cb="",
  15243. //rs="",
  15244. //xs ="",
  15245. //zcb = "",
  15246. //});
  15247. #endregion
  15248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15249. if (leftBindData != null)
  15250. {
  15251. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15252. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15253. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15254. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15255. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15256. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15257. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15258. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15259. }
  15260. #endregion
  15261. #region B段Right信息
  15262. right = dto.rightInfo.Find(x => x.Type == "B");
  15263. if (right == null)
  15264. {
  15265. return Ok(jw);
  15266. }
  15267. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15268. if (rightBindData != null)
  15269. {
  15270. //经济舱 + 双人间 TBR
  15271. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15272. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15273. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15274. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15275. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15276. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15277. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15278. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15279. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15280. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15281. }
  15282. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15283. if (rightBindData != null)
  15284. {
  15285. //经济舱 + 单人间 SGR
  15286. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15287. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15288. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15289. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15290. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15291. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15292. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15293. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15294. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15295. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15296. }
  15297. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15298. if (rightBindData != null)
  15299. {
  15300. //公务舱 + 单人间 SGR
  15301. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15302. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15303. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15304. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15305. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15306. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15307. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15308. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15309. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15310. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15311. }
  15312. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15313. if (rightBindData != null)
  15314. {
  15315. //公务舱 + 小套房 JSES
  15316. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15317. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15318. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15319. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15320. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15321. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15322. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15323. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15324. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15325. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15326. }
  15327. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15328. if (rightBindData != null)
  15329. {
  15330. //公务舱 + 小套房 JSES
  15331. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15332. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15333. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15334. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15335. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15336. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15337. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15338. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15339. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15340. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15341. }
  15342. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15343. if (rightBindData != null)
  15344. {
  15345. //经济舱 + 大套房
  15346. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15347. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15348. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15349. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15350. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15351. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15352. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15353. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15354. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15355. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15356. }
  15357. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15358. if (rightBindData != null)
  15359. {
  15360. //头等舱 + 小套房 JSES
  15361. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15362. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15363. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15364. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15365. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15366. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15367. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15368. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15369. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15370. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15371. }
  15372. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15373. if (rightBindData != null)
  15374. {
  15375. //头等舱 + 大套房
  15376. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15377. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15378. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15379. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15380. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15381. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15382. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15383. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15384. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15385. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15386. }
  15387. #endregion
  15388. #region 标题
  15389. designer.SetDataSource("CostBDRCB", "单人成本");
  15390. designer.SetDataSource("CostBRS", "人数");
  15391. designer.SetDataSource("CostBXS", "系数");
  15392. designer.SetDataSource("CostBZCB", "总成本");
  15393. designer.SetDataSource("CostBDRBJ", "单人报价");
  15394. designer.SetDataSource("CostBZBJ", "总报价");
  15395. designer.SetDataSource("CostBDRLR", "单人利润");
  15396. designer.SetDataSource("CostBZLR", "总利润");
  15397. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15398. designer.SetDataSource("CostBRSOM", "人数");
  15399. designer.SetDataSource("CostBZCBOM", "总成本");
  15400. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15401. designer.SetDataSource("CostBZBJOM", "总报价");
  15402. designer.SetDataSource("CostBDRLROM", "单人利润");
  15403. designer.SetDataSource("CostBZLROM", "总利润");
  15404. #endregion
  15405. }
  15406. #endregion
  15407. designer.SetDataSource("TzZCB2", TzZCB2);
  15408. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15409. designer.SetDataSource("TzZLR2", TzZLR2);
  15410. string[] dataSourceKeys = new string[]
  15411. {
  15412. "VF",
  15413. "TGS",
  15414. "TGOF",
  15415. "TGM",
  15416. "TGA",
  15417. "TGTF",
  15418. "TGEF",
  15419. "CFM",
  15420. "CFOF",
  15421. "B",
  15422. "L",
  15423. "D",
  15424. "TBR",
  15425. "SGR",
  15426. "JSES",
  15427. "Suite",
  15428. "TV",
  15429. "1L",
  15430. "IF",
  15431. "EF",
  15432. "BRF",
  15433. "TE",
  15434. "TGT",
  15435. "DRVT",
  15436. "PC",
  15437. "TLF",
  15438. "ECT"
  15439. };
  15440. foreach (var item in dataSourceKeys)
  15441. {
  15442. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15443. if (find != null)
  15444. {
  15445. designer.SetDataSource(item, find.text);
  15446. }
  15447. else
  15448. {
  15449. designer.SetDataSource(item, 0);
  15450. }
  15451. }
  15452. designer.SetDataSource(dt);
  15453. //根据数据源处理生成报表内容
  15454. designer.Process();
  15455. designer.Workbook.Worksheets[0].Name = "清单";
  15456. Worksheet sheet = designer.Workbook.Worksheets[0];
  15457. foreach (var Rowindex in hideRowsList)
  15458. {
  15459. ws.Cells.HideRows(Rowindex, 2);
  15460. }
  15461. byte[] bytes = null;
  15462. string strFileName = di.TeamName + "-团组-成本.xls";
  15463. using (MemoryStream stream = new MemoryStream())
  15464. {
  15465. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15466. bytes = stream.ToArray();
  15467. }
  15468. return Ok(JsonView(true, "", new
  15469. {
  15470. Data = bytes,
  15471. strFileName,
  15472. }));
  15473. }
  15474. /// <summary>
  15475. /// 导出客户报表
  15476. /// </summary>
  15477. /// <returns></returns>
  15478. [HttpPost]
  15479. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15480. {
  15481. var jw = JsonView(false);
  15482. if (dto.Diid == 0)
  15483. {
  15484. return Ok(JsonView(false, "请传递团组id"));
  15485. }
  15486. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15487. if (deleInfo.Code != 0)
  15488. {
  15489. return Ok(JsonView(false, "团组信息查询失败!"));
  15490. }
  15491. var di = deleInfo.Data as DelegationInfoWebView;
  15492. if (di == null)
  15493. {
  15494. return Ok(JsonView(false, "团组信息查询失败!"));
  15495. }
  15496. //文件名
  15497. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15498. //获取模板
  15499. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15500. //载入模板
  15501. Document doc = new Document(tmppath);
  15502. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15503. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15504. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15505. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15506. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15507. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15508. if (AParameter == null)
  15509. {
  15510. return Ok(JsonView(false, "系数不存在!"));
  15511. }
  15512. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15513. , TzAirDesc, TzZCost;
  15514. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15515. = TzAirDesc = TzZCost = string.Empty;
  15516. TzNumber = AParameter.CostTypenumber.ToString();
  15517. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15518. CarGuides1 = dto.CarGuides1;
  15519. Meal = dto.Meal;
  15520. SubsidizedMeals = dto.SubsidizedMeals;
  15521. NightRepair = dto.NightRepair;
  15522. AttractionsTickets = dto.AttractionsTickets;
  15523. MiscellaneousFees = dto.MiscellaneousFees;
  15524. ATip = dto.ATip;
  15525. TzHotelDesc = "";
  15526. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15527. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15528. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15529. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15530. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15531. TzAirDesc = "";
  15532. TzZCost = dto.TzZCost;
  15533. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15534. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15535. var index = 1;
  15536. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15537. foreach (var item in TzHotelDescArr)
  15538. {
  15539. if (AinfoArr != null)
  15540. {
  15541. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15542. if (Ainfo != null)
  15543. {
  15544. if (int.Parse(Ainfo.rs) <= 0)
  15545. {
  15546. continue;
  15547. }
  15548. var hotelText = string.Empty;
  15549. switch (item)
  15550. {
  15551. case "SGR":
  15552. hotelText = "单人间";
  15553. break;
  15554. case "JSES":
  15555. hotelText = "小套房";
  15556. break;
  15557. case "SUITE":
  15558. hotelText = "套房";
  15559. break;
  15560. case "TBR":
  15561. hotelText = "双人间";
  15562. break;
  15563. }
  15564. if (item != "TBR")
  15565. {
  15566. 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";
  15567. }
  15568. else
  15569. {
  15570. 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";
  15571. }
  15572. index++;
  15573. }
  15574. }
  15575. }
  15576. index = 1;
  15577. foreach (var item in TzAirDescArr)
  15578. {
  15579. if (AinfoArr != null)
  15580. {
  15581. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15582. if (Ainfo != null)
  15583. {
  15584. if (int.Parse(Ainfo.rs) <= 0)
  15585. {
  15586. continue;
  15587. }
  15588. 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";
  15589. index++;
  15590. }
  15591. }
  15592. }
  15593. if (dto.costType == "B")
  15594. {
  15595. if (BParameter == null)
  15596. {
  15597. return Ok(JsonView(false, "B段系数不存在!"));
  15598. }
  15599. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15600. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15601. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15602. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15603. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15604. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15605. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15606. foreach (var item in TzHotelDescArr)
  15607. {
  15608. if (AinfoArr != null)
  15609. {
  15610. TzHotelDesc += "B段信息 \r\n";
  15611. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15612. if (Ainfo != null)
  15613. {
  15614. if (int.Parse(Ainfo.rs) <= 0)
  15615. {
  15616. continue;
  15617. }
  15618. var hotelText = string.Empty;
  15619. switch (item)
  15620. {
  15621. case "SGR":
  15622. hotelText = "单人间";
  15623. break;
  15624. case "JSES":
  15625. hotelText = "小套房";
  15626. break;
  15627. case "SUITE":
  15628. hotelText = "套房";
  15629. break;
  15630. case "TBR":
  15631. hotelText = "双人间";
  15632. break;
  15633. }
  15634. if (item != "TBR")
  15635. {
  15636. 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";
  15637. }
  15638. else
  15639. {
  15640. 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";
  15641. }
  15642. index++;
  15643. }
  15644. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15645. }
  15646. }
  15647. index = 1;
  15648. foreach (var item in TzAirDescArr)
  15649. {
  15650. if (AinfoArr != null)
  15651. {
  15652. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15653. if (Ainfo != null)
  15654. {
  15655. if (int.Parse(Ainfo.rs) <= 0)
  15656. {
  15657. continue;
  15658. }
  15659. 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";
  15660. index++;
  15661. }
  15662. }
  15663. }
  15664. }
  15665. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15666. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15667. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15668. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15669. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15670. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15671. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15672. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15673. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15674. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15675. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15676. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15677. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15678. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15679. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15680. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15681. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15682. DickeyValue.Add("TzZCost", TzZCost);
  15683. foreach (var key in DickeyValue.Keys)
  15684. {
  15685. if (doc.Range.Bookmarks[key] != null)
  15686. {
  15687. Bookmark mark = doc.Range.Bookmarks[key];
  15688. mark.Text = DickeyValue[key];
  15689. }
  15690. }
  15691. byte[] bytes = null;
  15692. string strFileName = di.TeamName + "-客户报价.doc";
  15693. using (MemoryStream stream = new MemoryStream())
  15694. {
  15695. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15696. bytes = stream.ToArray();
  15697. }
  15698. return Ok(JsonView(true, "", new
  15699. {
  15700. Data = bytes,
  15701. strFileName,
  15702. }));
  15703. }
  15704. /// <summary>
  15705. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15706. /// </summary>
  15707. /// <param name="dto"></param>
  15708. /// <returns></returns>
  15709. [HttpPost]
  15710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15711. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15712. {
  15713. try
  15714. {
  15715. #region 参数验证
  15716. if (dto.DiId < 0)
  15717. {
  15718. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15719. }
  15720. List<int> cTableIds = new List<int>() {
  15721. 76 ,//酒店预订
  15722. 77 ,//行程
  15723. 79 ,//车/导游地接
  15724. 80 ,//签证
  15725. 81 ,//邀请/公务活
  15726. 82 ,//团组客户保险
  15727. 85 ,//机票预订
  15728. 98 ,//其他款项
  15729. 285 ,//收款退还
  15730. 751 ,//酒店早餐
  15731. 1015 // 超支费用
  15732. };
  15733. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15734. {
  15735. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15736. }
  15737. #endregion
  15738. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15739. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15740. if (_GroupCostParameters.Count <= 0)
  15741. {
  15742. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15743. }
  15744. if (_GroupCostParameters[0].IsShare == 0)
  15745. {
  15746. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15747. }
  15748. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15749. //处理date为空问题
  15750. if (_GroupCosts.Count > 0)
  15751. {
  15752. for (int i = 0; i < _GroupCosts.Count; i++)
  15753. {
  15754. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15755. {
  15756. if (i > 0)
  15757. {
  15758. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15759. }
  15760. }
  15761. }
  15762. }
  15763. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15764. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15765. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15766. string currCode = "";
  15767. #region currCode 验证
  15768. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15769. if (isInt)
  15770. {
  15771. var currData = currDatas.Find(it => it.Id == intCurrency);
  15772. if (currData != null)
  15773. {
  15774. currCode = currData.Name;
  15775. }
  15776. }
  15777. else
  15778. {
  15779. currCode = _GroupCostParameters[0].Currency.Trim();
  15780. }
  15781. #endregion
  15782. //op,酒店单段模式存储
  15783. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15784. {
  15785. CurrencyCode = currCode,
  15786. Rate = _GroupCostParameters[0].Rate,
  15787. CostType = _GroupCostParameters[0].CostType,
  15788. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15789. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15790. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15791. };
  15792. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15793. if (_GroupCostParameters.Count == 2)
  15794. {
  15795. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15796. }
  15797. foreach (var item in _GroupCostParameters)
  15798. {
  15799. decimal _rate = 1;
  15800. decimal _rate1 = item.Rate;
  15801. decimal _scale = 1;
  15802. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15803. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15804. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15805. //if (userInfo != null)
  15806. //{
  15807. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15808. // {
  15809. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15810. // {
  15811. // _scale = 1.00M;
  15812. // }
  15813. // }
  15814. //}
  15815. #endregion
  15816. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15817. {
  15818. CurrencyCode = currCode,
  15819. Rate = _rate1,
  15820. CostType = item.CostType,
  15821. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15822. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15823. CostTypeNumber = item.CostTypenumber
  15824. };
  15825. if (_GroupCostParameters.Count > 1)
  15826. {
  15827. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15828. }
  15829. else
  15830. {
  15831. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15832. }
  15833. if (dto.CTable == 79)//
  15834. {
  15835. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15836. modulePromptInfo.TotalCost = item.DJCB;
  15837. }
  15838. List<string> costTypes = new List<string>() { "A", "B" };
  15839. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15840. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15841. if (_GroupCostsDuplicates.Count() == 1)
  15842. {
  15843. _GroupCostsTypeData = _GroupCosts;
  15844. }
  15845. else
  15846. {
  15847. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15848. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15849. }
  15850. /*
  15851. * 76 酒店预订
  15852. * 77 行程
  15853. * 79 车/导游地接
  15854. * 80 签证
  15855. * 81 邀请/公务活动
  15856. * 82 团组客户保险
  15857. * 85 机票预订
  15858. * 98 其他款项
  15859. * 285 收款退还
  15860. * 751 酒店早餐
  15861. * 1015 超支费用
  15862. */
  15863. switch (dto.CTable)
  15864. {
  15865. case 76: // 酒店预订
  15866. _ModuleSubPromptInfo.AddRange(
  15867. _GroupCostsTypeData.Select(it => new
  15868. {
  15869. it.DAY,
  15870. it.Date,
  15871. it.ACCON,
  15872. it.ITIN,
  15873. it.SGR,
  15874. it.TBR,
  15875. it.JS_ES,
  15876. it.Suite
  15877. })
  15878. );
  15879. break;
  15880. case 79: // 车/导游地接
  15881. _ModuleSubPromptInfo.AddRange(
  15882. _GroupCostsTypeData.Select(it => new
  15883. {
  15884. Date = it.Date, //日期
  15885. CarFee = it.CarCost * _rate * _scale, //车费用
  15886. CarType = it.CarType, //车型
  15887. DriverFee = it.CFS * _rate * _scale, //司机工资
  15888. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15889. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15890. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15891. GuideFee = it.TGS * _rate * _scale, //导游费用
  15892. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15893. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15894. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15895. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15896. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15897. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15898. Breakfast = it.B * _rate * _scale, //早餐费
  15899. Lunch = it.L * _rate * _scale, //午餐费
  15900. Dinner = it.D * _rate * _scale, //晚餐费
  15901. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15902. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15903. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15904. TicketFee = it.EF * _rate * _scale, //门票费
  15905. TicketRemark = it.EFR, //门票费描述
  15906. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15907. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15908. SpentCash = it.PC * _rate * _scale, //零用金
  15909. LeadersFee = it.TLF * _rate * _scale, //领队费
  15910. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15911. })
  15912. );
  15913. break;
  15914. case 85: // 机票
  15915. List<dynamic> datas = new List<dynamic>();
  15916. datas.Add(
  15917. new
  15918. {
  15919. AirType = "经济舱",
  15920. AirNum = item.JJCRS,
  15921. AirDRCB = item.JJCCB,
  15922. AirZCB = (item.JJCRS * item.JJCCB)
  15923. }
  15924. );
  15925. datas.Add(
  15926. new
  15927. {
  15928. AirType = "公务舱",
  15929. AirNum = item.GWCRS,
  15930. AirDRCB = item.GWCCB,
  15931. AirZCB = (item.GWCRS * item.GWCCB)
  15932. }
  15933. );
  15934. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15935. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15936. modulePromptInfo.Data = new
  15937. {
  15938. airFeeData = datas,
  15939. airInitData = initDatas
  15940. };
  15941. _ModulePromptInfos.Add(modulePromptInfo);
  15942. break;
  15943. default:
  15944. break;
  15945. }
  15946. }
  15947. if (dto.CTable != 85)
  15948. {
  15949. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15950. _ModulePromptInfos.Add(_ModulePromptInfo);
  15951. }
  15952. _view.ModulePromptInfos = _ModulePromptInfos;
  15953. return Ok(JsonView(true, "操作成功!", _view));
  15954. }
  15955. catch (Exception ex)
  15956. {
  15957. return Ok(JsonView(false, ex.Message));
  15958. }
  15959. }
  15960. /// <summary>
  15961. /// 根据黑屏代码重新生成行程
  15962. /// </summary>
  15963. /// <param name="dto"></param>
  15964. /// <returns></returns>
  15965. [HttpPost]
  15966. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15967. {
  15968. var jw = JsonView(false, "Error");
  15969. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15970. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15971. .Select(x => new
  15972. {
  15973. x.Id,
  15974. x.Title
  15975. })
  15976. .ToList();
  15977. if (Create.Any())
  15978. {
  15979. jw.Msg = "获取成功!";
  15980. jw.Code = 200;
  15981. jw.Data = new
  15982. {
  15983. BlackCodeListSelect = Create,
  15984. blackCodeIsTrue = true
  15985. };
  15986. }
  15987. else
  15988. {
  15989. jw.Code = 400;
  15990. jw.Data = new
  15991. {
  15992. BlackCodeListSelect = Create,
  15993. blackCodeIsTrue = false,
  15994. };
  15995. }
  15996. return Ok(jw);
  15997. }
  15998. /// <summary>
  15999. /// 根据黑屏代码Id重新生成行程
  16000. /// </summary>
  16001. /// <param name="dto"></param>
  16002. /// <returns></returns>
  16003. [HttpPost]
  16004. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  16005. {
  16006. var jw = JsonView(false, "Error");
  16007. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16008. if (result.Code == 0)
  16009. {
  16010. jw.Msg = "获取成功!";
  16011. jw.Code = 200;
  16012. jw.Data = new
  16013. {
  16014. groupCost = result.Data,
  16015. blackCodeIsTrue = true
  16016. };
  16017. }
  16018. else
  16019. {
  16020. jw.Code = 400;
  16021. jw.Data = new
  16022. {
  16023. groupCost = result.Data,
  16024. blackCodeIsTrue = false,
  16025. };
  16026. }
  16027. return Ok(jw);
  16028. }
  16029. /// <summary>
  16030. /// 成本获取OP历史车费用
  16031. /// </summary>
  16032. /// <param name="dto"></param>
  16033. /// <returns></returns>
  16034. [HttpPost]
  16035. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16036. {
  16037. var jw = JsonView(false);
  16038. try
  16039. {
  16040. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16041. //获取现有所有车的数据
  16042. if (!dto.Param.IsNullOrWhiteSpace())
  16043. {
  16044. string sql = $@"
  16045. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16046. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16047. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16048. 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
  16049. AND gctggr.ServiceEndTime is not NULL
  16050. ORDER by gctggrc.id DESC
  16051. ";
  16052. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16053. var numeberResult = await Task.Run(() =>
  16054. {
  16055. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16056. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16057. return numberArr;
  16058. });
  16059. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16060. foreach (var item in numeberResult)
  16061. {
  16062. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16063. {
  16064. Country = "数据异常!",
  16065. City = string.Empty,
  16066. };
  16067. item.Area = find.Country + " " + find.City;
  16068. }
  16069. dbResult.AddRange(numeberResult);
  16070. if (dto.Param.Contains("、"))
  16071. {
  16072. var sp = dto.Param.Split("、");
  16073. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16074. .Where(x =>
  16075. {
  16076. return System.Array.Exists(sp, e =>
  16077. {
  16078. bool where = false;
  16079. if (x.Area != null)
  16080. {
  16081. where = x.Area.Contains(e);
  16082. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16083. {
  16084. return false;
  16085. }
  16086. }
  16087. if (x.PriceName != null && !where)
  16088. {
  16089. where = x.PriceName.Contains(e);
  16090. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16091. {
  16092. return false;
  16093. }
  16094. }
  16095. return where;
  16096. });
  16097. }).ToList();
  16098. }
  16099. else
  16100. {
  16101. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16102. .Where(x =>
  16103. {
  16104. bool where = false;
  16105. if (x.Area != null)
  16106. {
  16107. where = x.Area.Contains(dto.Param);
  16108. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16109. {
  16110. return false;
  16111. }
  16112. }
  16113. if (x.PriceName != null && !where)
  16114. {
  16115. where = x.PriceName.Contains(dto.Param);
  16116. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16117. {
  16118. return false;
  16119. }
  16120. }
  16121. return where;
  16122. }
  16123. )
  16124. .ToList();
  16125. }
  16126. }
  16127. var view = dbResult.Select(x =>
  16128. {
  16129. decimal dp = 0.00M;
  16130. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16131. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16132. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16133. {
  16134. if (startB && endB)
  16135. {
  16136. var timesp = endD.Subtract(startD);
  16137. if ((timesp.Days + 1) != 0)
  16138. {
  16139. dp = x.Price / (timesp.Days + 1);
  16140. }
  16141. }
  16142. }
  16143. else
  16144. {
  16145. dp = x.Price;
  16146. }
  16147. return new
  16148. {
  16149. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16150. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16151. x.Area,
  16152. x.id,
  16153. price = x.Price.ToString("F2"),
  16154. x.PriceName,
  16155. x.PriceContent,
  16156. x.TeamName,
  16157. x.DatePrice,
  16158. dayPrice = dp.ToString("F2"),
  16159. };
  16160. }).OrderByDescending(x => x.id).ToList();
  16161. jw = JsonView(true, "获取成功!", view);
  16162. }
  16163. catch (Exception e)
  16164. {
  16165. jw = JsonView(false, e.Message);
  16166. }
  16167. return Ok(jw);
  16168. }
  16169. [HttpPost]
  16170. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16171. {
  16172. var jw = JsonView(true);
  16173. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16174. #region SQL语句
  16175. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  16176. //{
  16177. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16178. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16179. // WHEN COUNT(*) >= 0 THEN 'True'
  16180. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16181. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16182. // ")
  16183. // .ToList();
  16184. //}
  16185. //else
  16186. //{
  16187. // string likeKey = string.Empty;
  16188. // foreach (var item in dto.Keyword)
  16189. // {
  16190. // likeKey += "%" + item;
  16191. // }
  16192. // likeKey += "%";
  16193. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16194. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16195. // WHEN COUNT(*) >= 0 THEN 'True'
  16196. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16197. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16198. // ")
  16199. // .ToList();
  16200. //}
  16201. #endregion
  16202. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  16203. {
  16204. @KeyWord = dto.Keyword
  16205. });
  16206. if (table != null && table.Rows.Count > 0)
  16207. {
  16208. foreach (DataRow row in table.Rows)
  16209. {
  16210. matches.Add(new DelegationInfoAndIsTrueView
  16211. {
  16212. Id = row.Field<int>("Id"),
  16213. GroupName = row.Field<string>("GroupName"),
  16214. isTrue = row.Field<string>("isTrue")
  16215. });
  16216. }
  16217. }
  16218. if (matches.Any())
  16219. {
  16220. jw.Data = matches;
  16221. }
  16222. else
  16223. {
  16224. jw.Code = 201;
  16225. jw.Msg = "empty list";
  16226. jw.Data = new List<string>(1);
  16227. }
  16228. return Ok(jw);
  16229. }
  16230. /// <summary>
  16231. /// 报价Word下载
  16232. /// </summary>
  16233. /// <param name="dto"></param>
  16234. /// <returns></returns>
  16235. [HttpPost]
  16236. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16237. {
  16238. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16239. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16240. if (di == null)
  16241. {
  16242. return Ok(JsonView(false, "团组不存在!"));
  16243. }
  16244. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16245. if (mainPrice == null || mainPrice.IsShare == 0)
  16246. {
  16247. return Ok(JsonView(false, "团组成本不存在!"));
  16248. }
  16249. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16250. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16251. if (costTypeHotelNumbers == null)
  16252. {
  16253. return Ok(JsonView(false, "团组成本不存在!"));
  16254. }
  16255. //文件名
  16256. string strFileName = di.TeamName + "-收款账单.doc";
  16257. //获取模板
  16258. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16259. //载入模板
  16260. Document doc = new Document(tmppath);
  16261. decimal allPrice = 0.00M;
  16262. string itemStr = string.Empty;
  16263. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16264. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16265. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16266. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16267. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16268. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16269. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16270. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16271. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16272. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16273. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16274. {
  16275. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16276. ("BXRS", "BXCB", "BXXS", "bx"),
  16277. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16278. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16279. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16280. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16281. ("CPRS", "CPCB", "CPXS", "cp"),
  16282. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16283. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16284. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16285. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16286. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16287. ("DJRS", "DJCB", "DJXS", "dj"),
  16288. ("GWRS", "GWCB", "GWXS", "gw"),
  16289. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16290. };
  16291. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16292. var rightSum = 0.00M;
  16293. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16294. {
  16295. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16296. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16297. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16298. if (prefix == "tbr")
  16299. {
  16300. rsValue *= 2;
  16301. cbValue /= 2;
  16302. }
  16303. if (OtherCostPropertyBJ.Contains(prefix))
  16304. {
  16305. rightSum += cbValue * xsValue;
  16306. }
  16307. }
  16308. var hotelRooms = new Dictionary<string, int>
  16309. {
  16310. { "SGR", costTypeHotelNumbers.SGR },
  16311. { "TBR", costTypeHotelNumbers.TBR },
  16312. { "JSES", costTypeHotelNumbers.JSES },
  16313. { "SUITE", costTypeHotelNumbers.SUITE }
  16314. };
  16315. var flights = new Dictionary<string, int>
  16316. {
  16317. { "经济舱", mainPrice.JJCRS },
  16318. { "公务舱", mainPrice.GWCRS },
  16319. { "头等舱", mainPrice.TDCRS }
  16320. };
  16321. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16322. {
  16323. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16324. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16325. { "头等舱", new[] { "SUITE", "JSES" } }
  16326. };
  16327. var result = new Dictionary<string, int>();
  16328. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16329. foreach (var flight in flights.Keys)
  16330. {
  16331. // 获取当前舱位的匹配规则
  16332. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16333. {
  16334. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16335. }
  16336. }
  16337. #region right计算
  16338. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16339. {
  16340. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16341. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16342. airHotelPriceList.Add(new
  16343. AirHotelPrice
  16344. {
  16345. Name = "经济舱TBR",
  16346. Price = rightSum + air + hotel,
  16347. Count = result["经济舱TBR"] * 2
  16348. });
  16349. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16350. }
  16351. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16352. {
  16353. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16354. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16355. airHotelPriceList.Add(new
  16356. AirHotelPrice
  16357. {
  16358. Name = "经济舱SGR",
  16359. Price = rightSum + air + hotel,
  16360. Count = result["经济舱SGR"]
  16361. });
  16362. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16363. }
  16364. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16365. {
  16366. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16367. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16368. airHotelPriceList.Add(new
  16369. AirHotelPrice
  16370. {
  16371. Name = "公务舱SGR",
  16372. Price = rightSum + air + hotel,
  16373. Count = result["公务舱SGR"]
  16374. });
  16375. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16376. }
  16377. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16378. {
  16379. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16380. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16381. airHotelPriceList.Add(new
  16382. AirHotelPrice
  16383. {
  16384. Name = "公务舱JSES",
  16385. Price = rightSum + air + hotel,
  16386. Count = result["公务舱JSES"]
  16387. });
  16388. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16389. }
  16390. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16391. {
  16392. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16393. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16394. airHotelPriceList.Add(new
  16395. AirHotelPrice
  16396. {
  16397. Name = "公务舱SUITE",
  16398. Price = rightSum + air + hotel,
  16399. Count = result["公务舱SUITE"]
  16400. });
  16401. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16402. }
  16403. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16404. {
  16405. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16406. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16407. airHotelPriceList.Add(new
  16408. AirHotelPrice
  16409. {
  16410. Name = "经济舱SUITE",
  16411. Price = rightSum + air + hotel,
  16412. Count = result["经济舱SUITE"]
  16413. });
  16414. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16415. }
  16416. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16417. {
  16418. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16419. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16420. airHotelPriceList.Add(new
  16421. AirHotelPrice
  16422. {
  16423. Name = "头等舱JSES",
  16424. Price = rightSum + air + hotel,
  16425. Count = result["头等舱JSES"]
  16426. });
  16427. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16428. }
  16429. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16430. {
  16431. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16432. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16433. airHotelPriceList.Add(new
  16434. AirHotelPrice
  16435. {
  16436. Name = "头等舱SUITE",
  16437. Price = rightSum + air + hotel,
  16438. Count = result["头等舱SUITE"]
  16439. });
  16440. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16441. }
  16442. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16443. {
  16444. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16445. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16446. airHotelPriceList.Add(new
  16447. AirHotelPrice
  16448. {
  16449. Name = "经济舱JSES",
  16450. Price = rightSum + air + hotel,
  16451. Count = result["经济舱JSES"]
  16452. });
  16453. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16454. }
  16455. #endregion
  16456. foreach (var item in airSouer.Keys)
  16457. {
  16458. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16459. if (find != null && find.Count > 0)
  16460. {
  16461. if (item.Contains("TBR"))
  16462. {
  16463. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16464. }
  16465. else
  16466. {
  16467. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16468. }
  16469. }
  16470. }
  16471. #region 替换Word模板书签内容
  16472. Dictionary<string, string> marks = new Dictionary<string, string>();
  16473. marks.Add("To", di.ClientUnit);//付款方
  16474. marks.Add("ToTel", di.TellPhone);//付款方电话
  16475. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16476. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16477. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16478. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16479. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16480. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16481. marks.Add("PayItemContent", itemStr);//详细信息
  16482. marks.Add("Total", allPrice.ToString("F2"));//合计
  16483. #endregion
  16484. foreach (var item in marks.Keys)
  16485. {
  16486. if (doc.Range.Bookmarks[item] != null)
  16487. {
  16488. Bookmark mark = doc.Range.Bookmarks[item];
  16489. mark.Text = marks[item];
  16490. }
  16491. }
  16492. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16493. doc.Save(savePaht);
  16494. var jw = new JsonView();
  16495. jw.Msg = "生成成功!";
  16496. jw.Code = 200;
  16497. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16498. return Ok(jw);
  16499. }
  16500. /// <summary>
  16501. /// 详细报价费用Excel下载
  16502. /// </summary>
  16503. /// <param name="dto"></param>
  16504. /// <returns></returns>
  16505. [HttpPost]
  16506. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16507. {
  16508. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16509. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16510. if (di == null)
  16511. {
  16512. return Ok(JsonView(false, "团组不存在!"));
  16513. }
  16514. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16515. if (mainPrice == null || mainPrice.IsShare == 0)
  16516. {
  16517. return Ok(JsonView(false, "团组成本不存在!"));
  16518. }
  16519. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16520. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16521. if (costTypeHotelNumbers == null)
  16522. {
  16523. return Ok(JsonView(false, "团组成本不存在!"));
  16524. }
  16525. WorkbookDesigner designer = new WorkbookDesigner();
  16526. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16527. List<int> hideRowsList = new List<int>();
  16528. int conterStartIndex = 3;
  16529. int rowIndex = conterStartIndex;
  16530. designer.SetDataSource("GroupName", di.TeamName);
  16531. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16532. {
  16533. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16534. ("BXRS", "BXCB", "BXXS", "bx"),
  16535. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16536. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16537. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16538. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16539. ("CPRS", "CPCB", "CPXS", "cp") ,
  16540. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16541. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16542. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16543. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16544. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16545. ("DJRS", "DJCB", "DJXS", "dj") ,
  16546. ("GWRS", "GWCB", "GWXS", "gw") ,
  16547. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16548. };
  16549. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16550. var rightSum = 0.00M;
  16551. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16552. {
  16553. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16554. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16555. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16556. if (prefix == "tbr")
  16557. {
  16558. rsValue *= 2;
  16559. cbValue /= 2;
  16560. }
  16561. if (OtherCostPropertyBJ.Contains(prefix))
  16562. {
  16563. rightSum += cbValue * xsValue;
  16564. }
  16565. if (rsValue == 0)
  16566. {
  16567. hideRowsList.Add(rowIndex);
  16568. }
  16569. else
  16570. {
  16571. designer.SetDataSource($"{prefix}rs", rsValue);
  16572. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16573. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16574. }
  16575. rowIndex += 2;
  16576. }
  16577. var hotelRooms = new Dictionary<string, int>
  16578. {
  16579. { "SGR", costTypeHotelNumbers.SGR },
  16580. { "TBR", costTypeHotelNumbers.TBR },
  16581. { "JSES", costTypeHotelNumbers.JSES },
  16582. { "SUITE", costTypeHotelNumbers.SUITE }
  16583. };
  16584. var flights = new Dictionary<string, int>
  16585. {
  16586. { "经济舱", mainPrice.JJCRS },
  16587. { "公务舱", mainPrice.GWCRS },
  16588. { "头等舱", mainPrice.TDCRS }
  16589. };
  16590. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16591. {
  16592. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16593. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16594. { "头等舱", new[] { "SUITE", "JSES" } }
  16595. };
  16596. var result = new Dictionary<string, int>();
  16597. foreach (var flight in flights.Keys)
  16598. {
  16599. // 获取当前舱位的匹配规则
  16600. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16601. {
  16602. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16603. }
  16604. }
  16605. var allPrice = 0.00M;
  16606. #region right计算
  16607. int airRowIndex = 35;
  16608. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16609. {
  16610. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16611. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16612. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16613. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16614. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16615. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16616. }
  16617. else
  16618. {
  16619. hideRowsList.Add(airRowIndex);
  16620. }
  16621. airRowIndex += 2;
  16622. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16623. {
  16624. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16625. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16626. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16627. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16628. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16629. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16630. }
  16631. else
  16632. {
  16633. hideRowsList.Add(airRowIndex);
  16634. }
  16635. airRowIndex += 2;
  16636. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16637. {
  16638. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16639. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16640. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16641. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16642. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16643. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16644. }
  16645. else
  16646. {
  16647. hideRowsList.Add(airRowIndex);
  16648. }
  16649. airRowIndex += 2;
  16650. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16651. {
  16652. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16653. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16654. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16655. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16656. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16657. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16658. }
  16659. else
  16660. {
  16661. hideRowsList.Add(airRowIndex);
  16662. }
  16663. airRowIndex += 2;
  16664. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16665. {
  16666. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16667. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16668. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16669. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16670. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16671. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16672. }
  16673. else
  16674. {
  16675. hideRowsList.Add(airRowIndex);
  16676. }
  16677. airRowIndex += 2;
  16678. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16679. {
  16680. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16681. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16682. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16683. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16684. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16685. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16686. }
  16687. else
  16688. {
  16689. hideRowsList.Add(airRowIndex);
  16690. }
  16691. airRowIndex += 2;
  16692. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16693. {
  16694. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16695. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16696. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16697. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16698. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16699. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16700. }
  16701. else
  16702. {
  16703. hideRowsList.Add(airRowIndex);
  16704. }
  16705. airRowIndex += 2;
  16706. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16707. {
  16708. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16709. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16710. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16711. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16712. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16713. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16714. }
  16715. else
  16716. {
  16717. hideRowsList.Add(airRowIndex);
  16718. }
  16719. airRowIndex += 2;
  16720. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16721. {
  16722. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16723. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16724. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16725. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16726. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16727. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16728. }
  16729. else
  16730. {
  16731. hideRowsList.Add(airRowIndex);
  16732. }
  16733. #endregion
  16734. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16735. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16736. var ws = designer.Workbook.Worksheets[0];
  16737. foreach (var Rowindex in hideRowsList)
  16738. {
  16739. ws.Cells.HideRows(Rowindex, 2);
  16740. }
  16741. designer.Process();
  16742. designer.Workbook.Save(savePaht);
  16743. return Ok(JsonView(true, "生成成功!", new
  16744. {
  16745. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16746. }));
  16747. }
  16748. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16749. {
  16750. foreach (var roomType in roomTypes)
  16751. {
  16752. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16753. {
  16754. hotelRooms[roomType]--;
  16755. flights[flightType]--;
  16756. if (roomType == "TBR")
  16757. {
  16758. flights[flightType]--; // 双人间在减少1
  16759. }
  16760. string key = flightType + roomType;
  16761. if (result.Keys.Contains(key))
  16762. {
  16763. result[key]++;
  16764. }
  16765. else
  16766. {
  16767. result.Add(key, 1);
  16768. }
  16769. }
  16770. }
  16771. }
  16772. private class AirHotelPrice
  16773. {
  16774. public string Name { get; set; }
  16775. public decimal Price { get; set; }
  16776. public int Count { get; set; }
  16777. }
  16778. private class HotelSum
  16779. {
  16780. internal decimal SGR { get; set; }
  16781. internal decimal TBR { get; set; }
  16782. internal decimal JSES { get; set; }
  16783. internal decimal SUITE { get; set; }
  16784. internal decimal AllPrice {
  16785. get { return SGR + TBR + JSES + SUITE; }
  16786. }
  16787. }
  16788. [HttpPost]
  16789. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  16790. {
  16791. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16792. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16793. if (di == null)
  16794. {
  16795. return Ok(JsonView(false, "团组不存在!"));
  16796. }
  16797. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>()
  16798. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16799. .ToList();
  16800. var groupHotelNumber = _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16801. .Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16802. .ToList();
  16803. var groupHotelNumberDefault = groupHotelNumber.FirstOrDefault(x => x.Type == "Default");
  16804. HotelSum hotelSumP = new ();
  16805. if (groupCost.Any())
  16806. {
  16807. hotelSumP.SGR = groupHotelNumberDefault.SGR > 0 ? groupCost.Sum(x => x.SGR) * groupHotelNumberDefault.SGR : 0 ;
  16808. hotelSumP.TBR = groupHotelNumberDefault.TBR > 0 ? groupCost.Sum(x => x.TBR) * groupHotelNumberDefault.TBR : 0;
  16809. hotelSumP.JSES = groupHotelNumberDefault.JSES > 0 ? groupCost.Sum(x => x.JS_ES) * groupHotelNumberDefault.JSES : 0;
  16810. hotelSumP.SUITE = groupHotelNumberDefault.SUITE > 0 ? groupCost.Sum(x => x.Suite) * groupHotelNumberDefault.SUITE : 0;
  16811. }
  16812. #region 地接系数
  16813. Func<int, decimal> coefficientByDJ = (number) =>
  16814. {
  16815. if (number < 1) return 0.00M;
  16816. return number switch
  16817. {
  16818. < 6 => 2.5M,
  16819. 6 => 2.4M,
  16820. 7 => 1.8M,
  16821. 8 => 2.0M,
  16822. 9 => 3.0M,
  16823. 10 => 1.75M,
  16824. > 10 => 1.9M,
  16825. };
  16826. };
  16827. #endregion
  16828. #region 酒店系数
  16829. #endregion
  16830. return Ok(JsonView(true, "查询成功", new
  16831. {
  16832. HotelSum = hotelSumP,
  16833. CoefficientByDJ = coefficientByDJ(di.VisitPNumber) // 示例调用
  16834. }));
  16835. }
  16836. #endregion
  16837. #region 酒店预订 New 2023-12-28 17:45
  16838. /// <summary>
  16839. /// 酒店预订
  16840. /// 酒店费用列表 根据团组Id查询
  16841. /// </summary>
  16842. /// <param name="_dto"></param>
  16843. /// <returns></returns>
  16844. [HttpPost]
  16845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16846. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16847. {
  16848. #region 参数验证
  16849. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16850. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16851. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16852. #region 团组操作权限验证 76 酒店预定模块
  16853. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16854. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16855. #endregion
  16856. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16857. #region 页面操作权限验证
  16858. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16859. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16860. #endregion
  16861. #endregion
  16862. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16863. }
  16864. /// <summary>
  16865. /// 酒店预订
  16866. /// 基础数据
  16867. /// </summary>
  16868. /// <param name="_dto"></param>
  16869. /// <returns></returns>
  16870. [HttpPost]
  16871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16872. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16873. {
  16874. #region 参数验证
  16875. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16876. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16877. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16878. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16879. #region 页面操作权限验证
  16880. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16881. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16882. #endregion
  16883. #region 团组操作权限验证 76 酒店预定模块
  16884. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16885. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16886. #endregion
  16887. #endregion
  16888. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16889. }
  16890. /// <summary>
  16891. /// 酒店预订
  16892. /// 创建 入住卷号码
  16893. /// </summary>
  16894. /// <param name="_dto"></param>
  16895. /// <returns></returns>
  16896. [HttpPost]
  16897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16898. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16899. {
  16900. #region 参数验证
  16901. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16902. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16903. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16904. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16905. #region 页面操作权限验证
  16906. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16907. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16908. #endregion
  16909. #region 团组操作权限验证 76 酒店预定模块
  16910. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16911. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16912. #endregion
  16913. #endregion
  16914. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16915. if (data.Code != 0)
  16916. {
  16917. return Ok(JsonView(false, data.Msg));
  16918. }
  16919. return Ok(JsonView(true, data.Msg, data.Data));
  16920. }
  16921. /// <summary>
  16922. /// 酒店预订
  16923. /// 详情
  16924. /// </summary>
  16925. /// <param name="_dto"></param>
  16926. /// <returns></returns>
  16927. [HttpPost]
  16928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16929. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16930. {
  16931. #region 参数验证
  16932. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16933. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16934. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16935. #region 团组操作权限验证 76 酒店预定模块
  16936. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16937. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16938. #endregion
  16939. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16940. #region 页面操作权限验证
  16941. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16942. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16943. #endregion
  16944. #endregion
  16945. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16946. }
  16947. /// <summary>
  16948. /// 酒店预订
  16949. /// Add Or Edit
  16950. /// </summary>
  16951. /// <param name="_dto"></param>
  16952. /// <returns></returns>
  16953. [HttpPost]
  16954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16955. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16956. {
  16957. #region 参数验证
  16958. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16959. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16960. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16961. #region 团组操作权限验证 76 酒店预定模块
  16962. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16963. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16964. #endregion
  16965. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16966. #region 页面操作权限验证
  16967. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16968. if (_dto.Id == 0) // Add
  16969. {
  16970. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16971. }
  16972. else if (_dto.Id > 1) // Edit
  16973. {
  16974. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16975. }
  16976. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16977. #endregion
  16978. #endregion
  16979. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16980. if (_view.Code != 200)
  16981. {
  16982. return Ok(_view);
  16983. }
  16984. #region 成本无酒店价格数据进入超支
  16985. _sqlSugar.BeginTran();
  16986. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16987. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16988. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16989. for (int i = 0; i < groupCost.Count; i++)
  16990. {
  16991. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16992. {
  16993. groupCost[i].Date = groupCost[i - 1].Date;
  16994. }
  16995. }
  16996. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16997. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16998. List<Fin_GroupExtraCostDto_OP>();
  16999. if (start_Bool && end_Bool)
  17000. {
  17001. while (start_Time < end_Time)
  17002. {
  17003. foreach (var item in groupCost_Grp)
  17004. {
  17005. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  17006. {
  17007. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  17008. {
  17009. extraCostList.Add(new
  17010. Fin_GroupExtraCostDto_OP
  17011. {
  17012. Area = _dto.AreaId,
  17013. coefficient = 1.5M,
  17014. createUser = _dto.UserId,
  17015. currency = _dto.CardPriceCurrency,
  17016. diId = _dto.DiId,
  17017. ManagerConfirm = 0,
  17018. SupervisorConfirm = 0,
  17019. SYsupervisorConfirm = 0,
  17020. editType = 1,
  17021. PortType = 1,
  17022. price = _dto.CardPrice,
  17023. PriceCount = 1,
  17024. priceType = 1027,
  17025. priceDetailType = 1044,
  17026. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  17027. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  17028. });
  17029. }
  17030. }
  17031. }
  17032. start_Time = start_Time.AddDays(1);
  17033. }
  17034. }
  17035. if (extraCostList.Any())
  17036. {
  17037. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  17038. }
  17039. _sqlSugar.CommitTran();
  17040. #endregion
  17041. #region 应用推送
  17042. try
  17043. {
  17044. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17045. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17046. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17047. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17048. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17049. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17050. var diId = _dto.DiId;
  17051. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17052. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17053. #region 操作记录
  17054. var opInfo = new Crm_TableOperationRecord()
  17055. {
  17056. TableName = "Grp_HotelReservations",
  17057. PortType = _dto.PortType,
  17058. DataId = hotelId,
  17059. CreateUserId = _dto.UserId
  17060. };
  17061. //var opStatus = OperationEnum.NoOperation;
  17062. if (_dto.Id < 1) //添加操作
  17063. {
  17064. opInfo.OperationItem = OperationEnum.Add;
  17065. }
  17066. else if (_dto.Id > 0)
  17067. {
  17068. opInfo.OperationItem = OperationEnum.Edit;
  17069. }
  17070. string opRemark = string.Empty;
  17071. if (ccpInfo != null)
  17072. {
  17073. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  17074. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  17075. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  17076. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  17077. }
  17078. opInfo.Remark = opRemark;
  17079. await _tableorRep.AddAsync(opInfo);
  17080. #endregion
  17081. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  17082. //2024-10-21 新增LZ UID
  17083. var userIds = new List<int>() { 21 };
  17084. string title = $"费用审核";
  17085. string content = "";
  17086. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17087. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17088. try
  17089. {
  17090. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17091. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17092. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17093. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17094. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17095. }
  17096. catch (Exception ex)
  17097. {
  17098. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17099. }
  17100. }
  17101. catch (Exception ex)
  17102. {
  17103. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17104. }
  17105. try
  17106. {
  17107. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17108. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17109. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17110. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17111. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17112. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17113. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17114. //自动审核
  17115. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17116. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17117. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17118. //2024-10-21 新增LZ UID
  17119. var userIds = new List<int>() { 21 };
  17120. string title = $"系统通知";
  17121. var diId = _dto.DiId;
  17122. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17123. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17124. string content = "";
  17125. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17126. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17127. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17128. }
  17129. catch (Exception ex)
  17130. {
  17131. }
  17132. #endregion
  17133. return Ok(_view);
  17134. }
  17135. /// <summary>
  17136. /// 酒店自动审核测试
  17137. /// Add Or Edit
  17138. /// </summary>
  17139. /// <param name="diid"></param>
  17140. /// <param name="dataId"></param>
  17141. /// <returns></returns>
  17142. [HttpPost]
  17143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17144. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17145. {
  17146. #region 应用推送
  17147. try
  17148. {
  17149. //自动审核
  17150. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17151. }
  17152. catch (Exception ex)
  17153. {
  17154. return Ok(JsonView(false, "操作失败"));
  17155. }
  17156. #endregion
  17157. return Ok(JsonView(false, "操作成功"));
  17158. }
  17159. /// <summary>
  17160. /// 酒店预订
  17161. /// Del
  17162. /// </summary>
  17163. /// <param name="_dto"></param>
  17164. /// <returns></returns>
  17165. [HttpPost]
  17166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17167. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17168. {
  17169. #region 参数验证
  17170. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17171. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17172. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17173. #region 团组操作权限验证 76 酒店预定模块
  17174. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17175. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17176. #endregion
  17177. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17178. #region 页面操作权限验证
  17179. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17180. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17181. #endregion
  17182. #endregion
  17183. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  17184. #region 操作记录
  17185. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17186. {
  17187. TableName = "Grp_HotelReservations",
  17188. PortType = _dto.PortType,
  17189. OperationItem = OperationEnum.Del,
  17190. DataId = _dto.Id,
  17191. CreateUserId = _dto.UserId
  17192. });
  17193. #endregion
  17194. return Ok(data);
  17195. }
  17196. /// <summary>
  17197. /// 酒店预订
  17198. /// 生成VOUCHER
  17199. /// 2024.05.06 之前版本
  17200. /// </summary>
  17201. /// <param name="_dto"></param>
  17202. /// <returns></returns>
  17203. [HttpPost]
  17204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17205. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17206. {
  17207. try
  17208. {
  17209. #region 参数验证
  17210. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17211. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17212. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17213. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17214. #region 团组操作权限验证 76 酒店预定模块
  17215. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17216. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17217. #endregion
  17218. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17219. #region 页面操作权限验证
  17220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17221. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17222. #endregion
  17223. #endregion
  17224. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17225. //判断数据是否完整
  17226. if (hr != null)
  17227. {
  17228. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17229. {
  17230. string strFileName = "HotelStatement/";
  17231. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17232. if (dele != null)
  17233. strFileName += dele.TourCode;
  17234. //载入模板
  17235. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17236. Document doc = new Document(sss);
  17237. DocumentBuilder builder = new DocumentBuilder(doc);
  17238. #region 替换Word模板书签内容
  17239. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17240. //入住卷预定号码
  17241. if (doc.Range.Bookmarks["VNO"] != null)
  17242. {
  17243. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17244. mark.Text = hr.CheckNumber;
  17245. }
  17246. //酒店时间
  17247. if (doc.Range.Bookmarks["Date"] != null)
  17248. {
  17249. Bookmark mark = doc.Range.Bookmarks["Date"];
  17250. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17251. }
  17252. //团号
  17253. if (doc.Range.Bookmarks["TNo"] != null)
  17254. {
  17255. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17256. mark.Text = dele.TourCode;
  17257. }
  17258. //预定号码
  17259. if (doc.Range.Bookmarks["BookingId"] != null)
  17260. {
  17261. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17262. mark.Text = hr.ReservationsNo;
  17263. }
  17264. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17265. {
  17266. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17267. mark.Text = hr.DetermineNo;
  17268. }
  17269. //酒店城市
  17270. if (doc.Range.Bookmarks["City"] != null)
  17271. {
  17272. Bookmark mark = doc.Range.Bookmarks["City"];
  17273. mark.Text = hr.City;
  17274. }
  17275. //酒店名称
  17276. if (doc.Range.Bookmarks["HName"] != null)
  17277. {
  17278. Bookmark mark = doc.Range.Bookmarks["HName"];
  17279. mark.Text = hr.HotelName;
  17280. }
  17281. //酒店地址
  17282. if (doc.Range.Bookmarks["Address"] != null)
  17283. {
  17284. Bookmark mark = doc.Range.Bookmarks["Address"];
  17285. mark.Text = hr.HotelAddress;
  17286. }
  17287. //酒店电话
  17288. if (doc.Range.Bookmarks["Tel"] != null)
  17289. {
  17290. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17291. mark.Text = hr.HotelTel;
  17292. }
  17293. //酒店传真
  17294. if (doc.Range.Bookmarks["Fax"] != null)
  17295. {
  17296. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17297. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17298. {
  17299. mark.Text = hr.HotelFax;
  17300. }
  17301. }
  17302. //入住时间
  17303. if (doc.Range.Bookmarks["CIn"] != null)
  17304. {
  17305. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17306. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17307. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17308. }
  17309. //退房时间
  17310. if (doc.Range.Bookmarks["COut"] != null)
  17311. {
  17312. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17313. Bookmark mark = doc.Range.Bookmarks["COut"];
  17314. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17315. }
  17316. //客户名称
  17317. if (doc.Range.Bookmarks["GName"] != null)
  17318. {
  17319. string guestName = "";
  17320. string[] clients = new string[] { };
  17321. if (hr.GuestName.Contains(","))
  17322. {
  17323. clients = hr.GuestName.Split(",");
  17324. }
  17325. else
  17326. {
  17327. clients = new string[] { hr.GuestName };
  17328. }
  17329. List<int> clientIds_int = new List<int>();
  17330. if (clients.Length > 0)
  17331. {
  17332. foreach (var item in clients)
  17333. {
  17334. if (item.IsNumeric())
  17335. {
  17336. clientIds_int.Add(int.Parse(item));
  17337. }
  17338. }
  17339. }
  17340. if (clientIds_int.Count > 0)
  17341. {
  17342. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17343. foreach (var client in _clientDatas)
  17344. {
  17345. //男
  17346. if (client.Sex == 0) guestName += $"Mr.";
  17347. //女
  17348. else if (client.Sex == 1) guestName += $"Ms.";
  17349. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17350. {
  17351. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17352. }
  17353. //guestName += $"{client.Pinyin},";
  17354. }
  17355. if (guestName.Length > 0)
  17356. {
  17357. guestName = guestName.Substring(0, guestName.Length - 1);
  17358. }
  17359. }
  17360. else
  17361. {
  17362. guestName = hr.GuestName;
  17363. }
  17364. Bookmark mark = doc.Range.Bookmarks["GName"];
  17365. mark.Text = guestName;
  17366. }
  17367. //房间介绍
  17368. if (doc.Range.Bookmarks["ROOM"] != null)
  17369. {
  17370. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17371. mark.Text = hr.RoomExplanation;
  17372. }
  17373. //报价描述
  17374. if (doc.Range.Bookmarks["NOTE"] != null)
  17375. {
  17376. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17377. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17378. if (ss != null)
  17379. mark.Text = ss.Name;
  17380. }
  17381. //入住时间
  17382. if (doc.Range.Bookmarks["CheckIn"] != null)
  17383. {
  17384. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17385. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17386. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17387. }
  17388. //退房时间
  17389. if (doc.Range.Bookmarks["CheckOut"] != null)
  17390. {
  17391. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17392. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17393. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17394. }
  17395. //日期
  17396. if (doc.Range.Bookmarks["DT"] != null)
  17397. {
  17398. Bookmark mark = doc.Range.Bookmarks["DT"];
  17399. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17400. }
  17401. //名称
  17402. if (doc.Range.Bookmarks["VName"] != null)
  17403. {
  17404. Bookmark mark = doc.Range.Bookmarks["VName"];
  17405. mark.Text = hr.HotelName;
  17406. }
  17407. //号码
  17408. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17409. {
  17410. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17411. mark.Text = hr.CheckNumber;
  17412. }
  17413. #endregion
  17414. strFileName += "VOUCHER.doc";
  17415. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17416. doc.Save(fileDir);
  17417. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17418. return Ok(JsonView(true, "操作成功!", Url));
  17419. }
  17420. else
  17421. {
  17422. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17423. }
  17424. }
  17425. else
  17426. {
  17427. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17428. }
  17429. }
  17430. catch (Exception ex)
  17431. {
  17432. return Ok(JsonView(false, ex.Message));
  17433. }
  17434. }
  17435. /// <summary>
  17436. /// 酒店预订
  17437. /// 生成VOUCHER
  17438. /// 2024.05.06 之后版本
  17439. /// </summary>
  17440. /// <param name="_dto"></param>
  17441. /// <returns></returns>
  17442. [HttpPost]
  17443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17444. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17445. {
  17446. #region 参数验证
  17447. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17448. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17449. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17450. #region 团组操作权限验证 76 酒店预定模块
  17451. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17452. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17453. #endregion
  17454. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17455. #region 页面操作权限验证
  17456. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17457. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17458. #endregion
  17459. #endregion
  17460. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17461. //判断数据是否完整
  17462. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17463. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17464. string strFileName = "HotelStatement/";
  17465. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17466. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17467. #region 数据处理
  17468. List<int> guestIds = new List<int>();
  17469. //int index = 0;
  17470. foreach (var item in hrDtas)
  17471. {
  17472. if (item.GuestName.Contains(","))
  17473. {
  17474. string[] guestIdArr = item.GuestName.Split(',');
  17475. foreach (var guestIdStr in guestIdArr)
  17476. {
  17477. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17478. if (guestBool)
  17479. {
  17480. guestIds.Add(guestId);
  17481. }
  17482. }
  17483. }
  17484. else guestNames += item.GuestName;
  17485. var voucherInfo = new HotelVoucherInfoView()
  17486. {
  17487. HotelName = item.HotelName,
  17488. CheckInDate = item.CheckInDate,
  17489. CheckOutDate = item.CheckOutDate,
  17490. ConfirmationNumber = item.DetermineNo.Trim(),
  17491. RoomType = item.RoomExplanation
  17492. };
  17493. vouchers.Add(voucherInfo);
  17494. }
  17495. if (guestIds.Count > 0)
  17496. {
  17497. guestIds = guestIds.Distinct().ToList();
  17498. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17499. if (guestDatas.Count > 0)
  17500. {
  17501. guestNames = "";
  17502. foreach (var guest in guestDatas)
  17503. {
  17504. string guestName = "";
  17505. if (guest.Sex == 0) guestName += @"MR.";
  17506. else if (guest.Sex == 1) guestName += @"MS.";
  17507. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17508. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17509. guestNames += @$"{guestName.Trim()}、";
  17510. }
  17511. if (guestNames.Length > 0)
  17512. {
  17513. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17514. }
  17515. }
  17516. }
  17517. #endregion
  17518. //载入模板
  17519. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17520. Document doc = new Document(sss);
  17521. DocumentBuilder builder = new DocumentBuilder(doc);
  17522. if (doc.Range.Bookmarks["GuestName"] != null)
  17523. {
  17524. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17525. mark.Text = guestNames;
  17526. }
  17527. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17528. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17529. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17530. for (int i = 1; i <= vouchers.Count; i++)
  17531. {
  17532. HotelVoucherInfoView hviv = vouchers[i - 1];
  17533. builder.MoveToCell(0, i, 0, 0);
  17534. builder.Write(hviv.HotelName);
  17535. builder.MoveToCell(0, i, 1, 0);
  17536. builder.Write(hviv.CheckInDate);
  17537. builder.MoveToCell(0, i, 2, 0);
  17538. builder.Write(hviv.CheckOutDate);
  17539. builder.MoveToCell(0, i, 3, 0);
  17540. builder.Write(hviv.RoomType);
  17541. builder.MoveToCell(0, i, 4, 0);
  17542. builder.Write(hviv.ConfirmationNumber);
  17543. }
  17544. //删除多余行
  17545. int currRowIndex = vouchers.Count + 1;
  17546. int delRows = 21 - currRowIndex;
  17547. if (delRows > 0)
  17548. {
  17549. for (int i = 0; i < delRows; i++)
  17550. {
  17551. table.Rows.RemoveAt(currRowIndex);
  17552. //cultivateRowIndex++;
  17553. }
  17554. }
  17555. strFileName += "VOUCHER.docx";
  17556. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17557. doc.Save(fileDir);
  17558. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17559. return Ok(JsonView(true, "操作成功!", Url));
  17560. }
  17561. /// <summary>
  17562. /// 酒店预订
  17563. /// 生成VOUCHER 批量生成
  17564. /// New
  17565. /// </summary>
  17566. /// <param name="_dto"></param>
  17567. /// <returns></returns>
  17568. [HttpPost]
  17569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17570. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17571. {
  17572. #region 参数验证
  17573. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17574. if (_dto.PageId < 1) _dto.PageId = 28;
  17575. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17576. #region 团组操作权限验证 76 酒店预定模块
  17577. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17578. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17579. #endregion
  17580. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17581. #region 页面操作权限验证
  17582. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17583. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17584. #endregion
  17585. #endregion
  17586. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17587. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17588. .OrderBy(x => x.CheckInDate)
  17589. .ToListAsync();
  17590. //判断数据是否完整
  17591. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17592. string strFileName = "HotelStatement/";
  17593. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17594. if (dele != null)
  17595. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17596. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17597. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17598. .Where(it => it.IsDel == 0)
  17599. .ToListAsync();
  17600. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17601. for (int i = 0; i < hrDtas.Count; i++)
  17602. {
  17603. string guestNames = string.Empty;
  17604. List<int> guestIds = new List<int>();
  17605. var item = hrDtas[i];
  17606. //处理客户姓名
  17607. if (item.GuestName.Contains(","))
  17608. {
  17609. string[] guestIdArr = item.GuestName.Split(',');
  17610. foreach (var guestIdStr in guestIdArr)
  17611. if (int.TryParse(guestIdStr, out int guestId))
  17612. guestIds.Add(guestId);
  17613. }
  17614. else
  17615. {
  17616. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17617. if (guestIdBool)
  17618. {
  17619. guestIds.Add(guestId);
  17620. }
  17621. //NaN
  17622. if (item.GuestName.Contains("NaN"))
  17623. {
  17624. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17625. }
  17626. }
  17627. if (guestIds.Count > 0)
  17628. {
  17629. guestIds = guestIds.Distinct().ToList();
  17630. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17631. if (guestDatas1.Count > 0)
  17632. {
  17633. guestNames = "";
  17634. foreach (var guest in guestDatas1)
  17635. {
  17636. string guestName = "";
  17637. if (guest.Sex == 0) guestName += @"MR.";
  17638. else if (guest.Sex == 1) guestName += @"MS.";
  17639. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17640. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17641. guestNames += @$"{guestName.Trim()}、";
  17642. }
  17643. if (guestNames.Length > 0)
  17644. {
  17645. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17646. }
  17647. }
  17648. }
  17649. //if (!string.IsNullOrEmpty(guestNames))
  17650. //{
  17651. hrDtas[i].GuestName = guestNames;
  17652. //}
  17653. }
  17654. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17655. Document doc = new Document();
  17656. DocumentBuilder builder = new DocumentBuilder(doc);
  17657. try
  17658. {
  17659. builder.MoveToDocumentStart();
  17660. foreach (var item in hrDtas)
  17661. {
  17662. //标题
  17663. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17664. builder.ParagraphFormat.LineSpacing = 1;
  17665. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17666. builder.ParagraphFormat.Style.Font.Size = 9;
  17667. builder.ParagraphFormat.Style.Font.Bold = true;
  17668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17669. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17670. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17672. builder.ParagraphFormat.LineSpacing = 1;
  17673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17674. builder.ParagraphFormat.Style.Font.Size = 9;
  17675. builder.ParagraphFormat.Style.Font.Bold = true;
  17676. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17677. builder.StartTable();
  17678. // 设置边框颜色
  17679. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17680. //设置边框样式
  17681. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17682. //表格
  17683. #region 第一行
  17684. builder.InsertCell();
  17685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17686. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17687. //builder.CellFormat.AllowAutoFit = false;
  17688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17690. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17691. builder.CellFormat.WrapText = true; //自动换行
  17692. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17693. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17698. builder.Write("TOUR NO:");
  17699. builder.InsertCell();
  17700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17701. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17702. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17703. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17704. builder.ParagraphFormat.Style.Font.Bold = false;
  17705. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17707. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17708. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17709. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17710. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17711. builder.Write($"{dele?.TourCode ?? "-"}");
  17712. builder.InsertCell();
  17713. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17714. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17715. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17716. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17717. builder.ParagraphFormat.Style.Font.Bold = false;
  17718. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17719. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17720. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17721. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17722. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17723. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17724. builder.Write($"CITY:");
  17725. builder.InsertCell();
  17726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17727. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17728. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17729. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17730. builder.ParagraphFormat.Style.Font.Bold = false;
  17731. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17732. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17733. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17734. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17735. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17736. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17737. builder.Write($"{item.City}");
  17738. builder.EndRow();
  17739. #endregion
  17740. #region 第二行
  17741. builder.InsertCell();
  17742. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17743. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17744. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17745. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17746. builder.ParagraphFormat.Style.Font.Bold = false;
  17747. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17748. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17749. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17750. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17751. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17752. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17753. builder.Write("CONFIRMATION NO:");
  17754. builder.InsertCell();
  17755. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17756. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17757. builder.ParagraphFormat.Style.Font.Size = 8;
  17758. builder.ParagraphFormat.Style.Font.Bold = false;
  17759. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17760. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17761. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17762. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17763. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17764. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17765. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17766. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17767. builder.Write($"{item.DetermineNo}");
  17768. builder.InsertCell();
  17769. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17770. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17771. builder.InsertCell();
  17772. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17773. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17774. builder.EndRow();
  17775. #endregion
  17776. #region 第三行
  17777. builder.InsertCell();
  17778. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17779. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17780. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17781. builder.ParagraphFormat.Style.Font.Bold = false;
  17782. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17783. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17784. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17785. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17786. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17787. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17788. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17789. builder.Write($"HOTEL NAME:");
  17790. builder.InsertCell();
  17791. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17792. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17793. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17794. builder.ParagraphFormat.Style.Font.Bold = false;
  17795. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17796. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17797. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17798. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17799. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17800. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17801. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17802. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17803. builder.Write($"{item.HotelName}");
  17804. builder.InsertCell();
  17805. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17806. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17807. builder.InsertCell();
  17808. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17809. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17810. builder.EndRow();
  17811. #endregion
  17812. #region 第四行
  17813. builder.InsertCell();
  17814. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17815. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17816. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17817. builder.ParagraphFormat.Style.Font.Bold = false;
  17818. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17819. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17820. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17821. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17822. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17823. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17824. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17825. builder.Write($"HOTEL ADDRESS:");
  17826. builder.InsertCell();
  17827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17828. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17829. builder.ParagraphFormat.Style.Font.Size = 8;
  17830. builder.ParagraphFormat.Style.Font.Bold = false;
  17831. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17838. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17839. builder.Write($"{item.HotelAddress}");
  17840. builder.InsertCell();
  17841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17842. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17843. builder.InsertCell();
  17844. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17845. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17846. builder.EndRow();
  17847. #endregion
  17848. #region 第五行
  17849. builder.InsertCell();
  17850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17852. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17853. builder.ParagraphFormat.Style.Font.Bold = false;
  17854. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17857. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17858. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17859. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17860. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17861. builder.Write("TEL:");
  17862. builder.InsertCell();
  17863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17864. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17865. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17866. builder.ParagraphFormat.Style.Font.Bold = false;
  17867. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17868. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17869. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17870. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17871. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17872. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17873. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17874. builder.Write($"{item.HotelTel}");
  17875. builder.InsertCell();
  17876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17877. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17878. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17879. builder.ParagraphFormat.Style.Font.Bold = false;
  17880. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17881. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17882. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17883. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17884. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17885. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17886. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17887. builder.Write($"FAX:");
  17888. builder.InsertCell();
  17889. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17890. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17891. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17892. builder.ParagraphFormat.Style.Font.Bold = false;
  17893. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17894. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17895. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17896. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17897. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17898. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17899. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17900. builder.Write($"{item.HotelFax}");
  17901. builder.EndRow();
  17902. #endregion
  17903. #region 第六行
  17904. builder.InsertCell();
  17905. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17906. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17907. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17908. builder.ParagraphFormat.Style.Font.Bold = false;
  17909. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17910. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17911. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17912. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17913. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17914. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17915. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17916. builder.Write("CHECK IN:");
  17917. builder.InsertCell();
  17918. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17919. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17920. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17921. builder.ParagraphFormat.Style.Font.Bold = false;
  17922. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17923. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17924. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17925. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17926. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17927. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17928. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17929. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17930. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17931. builder.Write($"{checkInStr}");
  17932. builder.InsertCell();
  17933. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17934. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17935. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17936. builder.ParagraphFormat.Style.Font.Bold = false;
  17937. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17938. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17939. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17940. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17941. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17942. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17943. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17944. builder.Write($"CHECK OUT:");
  17945. builder.InsertCell();
  17946. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17947. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17948. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17949. builder.ParagraphFormat.Style.Font.Bold = false;
  17950. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17951. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17952. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17953. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17954. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17955. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17956. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17957. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17958. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17959. builder.Write($"{checkOutStr}");
  17960. builder.EndRow();
  17961. #endregion
  17962. #region 第七行
  17963. builder.InsertCell();
  17964. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17965. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17966. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17967. builder.ParagraphFormat.Style.Font.Bold = false;
  17968. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17969. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17970. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17971. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17972. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17973. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17974. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17975. builder.Write($"GUEST NAME:");
  17976. builder.InsertCell();
  17977. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17978. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17979. builder.ParagraphFormat.Style.Font.Size = 8;
  17980. builder.ParagraphFormat.Style.Font.Bold = false;
  17981. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17982. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17983. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17984. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17985. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17986. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17987. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17988. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17989. builder.Write($"{item.GuestName.Trim()}");
  17990. builder.InsertCell();
  17991. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17992. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17993. builder.InsertCell();
  17994. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17995. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17996. builder.EndRow();
  17997. #endregion
  17998. #region 第八行
  17999. builder.InsertCell();
  18000. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18001. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18002. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18003. builder.ParagraphFormat.Style.Font.Bold = false;
  18004. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18005. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18006. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18007. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18008. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18009. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18010. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18011. builder.Write($"ROOM TYPE:");
  18012. builder.InsertCell();
  18013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18014. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18015. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18016. builder.ParagraphFormat.Style.Font.Bold = false;
  18017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18018. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18019. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18020. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18021. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18022. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18023. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18024. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18025. builder.Write($"{item.RoomExplanation}");
  18026. builder.InsertCell();
  18027. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18028. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18029. builder.InsertCell();
  18030. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18031. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18032. builder.EndRow();
  18033. #endregion
  18034. #region 第九行
  18035. builder.InsertCell();
  18036. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18037. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18038. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18039. builder.ParagraphFormat.Style.Font.Bold = false;
  18040. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18041. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18042. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  18043. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  18044. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  18045. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  18046. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  18047. builder.Write($"NOTE:");
  18048. builder.InsertCell();
  18049. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18050. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  18051. builder.ParagraphFormat.Style.Font.Size = 7.5;
  18052. builder.ParagraphFormat.Style.Font.Bold = false;
  18053. builder.CellFormat.HorizontalMerge = CellMerge.None;
  18054. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  18055. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  18056. builder.CellFormat.HorizontalMerge = CellMerge.First;
  18057. 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.");
  18058. builder.InsertCell();
  18059. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  18060. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18061. builder.InsertCell();
  18062. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  18063. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  18064. builder.EndRow();
  18065. #endregion
  18066. builder.EndTable();
  18067. //换行
  18068. builder.Writeln("");
  18069. builder.Writeln("");
  18070. }
  18071. #region 获取文档中的所有表格 设置文字自适应
  18072. // 获取文档中的所有表格。
  18073. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  18074. {
  18075. // 遍历表格中的所有行。
  18076. foreach (Aspose.Words.Tables.Row row in table.Rows)
  18077. {
  18078. foreach (Cell cell in row.Cells)
  18079. {
  18080. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  18081. cellFormat.Width = 0;
  18082. }
  18083. }
  18084. }
  18085. #endregion
  18086. #region 设置页眉
  18087. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18088. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18089. if (System.IO.File.Exists(voucherHeaderPath))
  18090. {
  18091. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18092. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18093. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18094. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18095. // 调整图片位置
  18096. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18097. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18098. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18099. shape.Left = 0; // 将图片距离页面左边缘的距离
  18100. shape.Width = 81; // 设置图片宽度
  18101. shape.Height = 36; // 设置图片高度
  18102. }
  18103. //靠右
  18104. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18105. //// 设置页脚上下边距
  18106. //builder.PageSetup.HeaderDistance = 42;
  18107. // 添加页眉线
  18108. Aspose.Words.Border borderHeader = null;
  18109. try
  18110. {
  18111. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18112. }
  18113. catch (Exception e)
  18114. {
  18115. // TODO Auto-generated catch block
  18116. //e.printStackTrace();
  18117. }
  18118. borderHeader.Shadow = true;
  18119. borderHeader.DistanceFromText = 2;
  18120. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18121. #endregion
  18122. }
  18123. catch (Exception ex)
  18124. {
  18125. }
  18126. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18127. doc.Save(fileDir);
  18128. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18129. return Ok(JsonView(true, "操作成功!", Url));
  18130. }
  18131. /// <summary>
  18132. /// 酒店预订
  18133. /// 生成 预定成本 Excel
  18134. /// </summary>
  18135. /// <param name="_dto"></param>
  18136. /// <returns></returns>
  18137. [HttpPost]
  18138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18139. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18140. {
  18141. #region 参数验证
  18142. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18143. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18144. if (!vadalitorRes.IsValid)
  18145. {
  18146. var errors = new StringBuilder();
  18147. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18148. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18149. }
  18150. #region 团组操作权限验证 76 酒店预定模块
  18151. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18152. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18153. #endregion
  18154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18155. #region 页面操作权限验证
  18156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18157. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18158. #endregion
  18159. #endregion
  18160. decimal _rate = 1.00M;
  18161. string _currency = string.Empty;
  18162. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18163. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18164. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18165. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18166. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18167. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18168. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18169. if (_GroupCostParameter == null)
  18170. {
  18171. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18172. bool isIntType = int.TryParse(_currency, out int currId);
  18173. if (isIntType)
  18174. {
  18175. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18176. }
  18177. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18178. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18179. if (currInfo == null)
  18180. {
  18181. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18182. }
  18183. else _rate = currInfo.Rate;
  18184. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18185. {
  18186. _rate = _GroupCostParameter.Rate;
  18187. }
  18188. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18189. //string strFileName = "HotelStatement/";
  18190. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18191. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18192. var rateDatas = new List<dynamic>();
  18193. #region 数据处理
  18194. foreach (var item in hrDtas)
  18195. {
  18196. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18197. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18198. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18199. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18200. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18201. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18202. {
  18203. continue;
  18204. }
  18205. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18206. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18207. string singleRoomFeeStr = string.Empty,
  18208. doubleRoomFeeStr = string.Empty,
  18209. suiteRoomFeeStr = string.Empty,
  18210. otherRoomFeeStr = string.Empty,
  18211. payMoneyStr = string.Empty,
  18212. cardPriceStr = string.Empty;
  18213. if (roomCurr.Equals("CNY"))
  18214. {
  18215. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18216. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18217. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18218. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18219. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18220. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18221. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18222. }
  18223. else
  18224. {
  18225. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18226. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18227. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18228. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18229. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18230. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18231. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18232. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18233. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18234. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18235. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18236. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18237. if (ccpPaymentCurrency.Equals("CNY"))
  18238. {
  18239. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18240. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18241. }
  18242. else
  18243. {
  18244. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18245. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18246. }
  18247. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18248. if (hotelcardPriceCurrency.Equals("CNY"))
  18249. {
  18250. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18251. }
  18252. else
  18253. {
  18254. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18255. }
  18256. }
  18257. string breakfastPriceStr = string.Empty,
  18258. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18259. governmentRentStr = string.Empty,
  18260. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18261. cityTaxStr = string.Empty,
  18262. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18263. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18264. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18265. {
  18266. if (breakfastCurrency1.Equals("CNY"))
  18267. {
  18268. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18269. }
  18270. else
  18271. {
  18272. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18273. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18274. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18275. }
  18276. }
  18277. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18278. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18279. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18280. {
  18281. if (governmentRentCurrency.Equals("CNY"))
  18282. {
  18283. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18284. }
  18285. else
  18286. {
  18287. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18288. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18289. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18290. }
  18291. }
  18292. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18293. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18294. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18295. {
  18296. if (cityTaxStrCurrency1.Equals("CNY"))
  18297. {
  18298. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18299. }
  18300. else
  18301. {
  18302. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18303. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18304. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18305. }
  18306. }
  18307. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18308. int payDId = roomInfo?.PayDId ?? 0;
  18309. pcfds.Add(new HotelReservations_PCFD_View()
  18310. {
  18311. City = item.City,
  18312. HotelName = item.HotelName,
  18313. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18314. // SingleRoomCount = item.SingleRoomCount,
  18315. SingleRoomPrice = singleRoomFeeStr,
  18316. // DoubleRoomCount = item.DoubleRoomCount,
  18317. DoubleRoomPrice = doubleRoomFeeStr,
  18318. //SuiteRoomCount = item.SuiteRoomCount,
  18319. SuiteRoomPrice = suiteRoomFeeStr,
  18320. OtherRoomPrice = otherRoomFeeStr,
  18321. //OtherRoomCount = item.OtherRoomCount,
  18322. BreakfastPrice = breakfastPriceStr,
  18323. GovernmentRent = governmentRentStr,
  18324. CityTax = cityTaxStr,
  18325. RoomExplanation = item.RoomExplanation,
  18326. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18327. PayTime = roomInfo?.ConsumptionDate,
  18328. BankNo = roomInfo?.BankNo,
  18329. PayMoney = payMoneyStr,
  18330. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18331. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18332. CardPrice = cardPriceStr,
  18333. Remark = ccpInfo.Remark
  18334. });
  18335. }
  18336. #endregion
  18337. //载入模板
  18338. WorkbookDesigner designer = new WorkbookDesigner();
  18339. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18340. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18341. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18342. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18343. var rateDatas1 = rateDatas.Distinct();
  18344. var rateStr = string.Empty;
  18345. foreach (var item in rateDatas1)
  18346. {
  18347. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18348. }
  18349. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18350. designer.SetDataSource("Opertor", userInfo.CnName);
  18351. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18352. dt.TableName = "ViewMyHotelReservations";
  18353. designer.SetDataSource(dt);
  18354. designer.Process();
  18355. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18356. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18357. designer.Workbook.Save(serverPath);
  18358. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18359. #region 删除指定行
  18360. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18361. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18362. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18363. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18364. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18365. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18366. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18367. cssIndex = dt.Columns["CityTax"].Ordinal,
  18368. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18369. remarkIndex = dt.Columns["Remark"].Ordinal;
  18370. //删除指定列
  18371. foreach (DataRow item in dt.Rows)
  18372. {
  18373. string singleStr = item["SingleRoomPrice"].ToString();
  18374. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18375. if (containsDigitButNotZero1) singleDel = false;
  18376. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18377. string doubleStr = item["DoubleRoomPrice"].ToString();
  18378. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18379. if (containsDigitButNotZero2) doubleDel = false;
  18380. string suiteStr = item["SuiteRoomPrice"].ToString();
  18381. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18382. if (containsDigitButNotZero3) suiteDel = false;
  18383. string otherStr = item["OtherRoomPrice"].ToString();
  18384. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18385. if (containsDigitButNotZero4) otherDel = false;
  18386. string zcStr = item["BreakfastPrice"].ToString();
  18387. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18388. if (containsDigitButNotZero5) zcDel = false;
  18389. string dsStr = item["GovernmentRent"].ToString();
  18390. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18391. if (containsDigitButNotZero6) dsDel = false;
  18392. string cssStr = item["CityTax"].ToString();
  18393. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18394. if (containsDigitButNotZero7) cssDel = false;
  18395. string cpStr = item["ConsumptionPatterns"].ToString();
  18396. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18397. string remarkStr = item["Remark"].ToString();
  18398. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18399. }
  18400. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18401. DeleteColumn(serverPath, cpIndex, cpDel);
  18402. DeleteColumn(serverPath, dsIndex, dsDel);
  18403. DeleteColumn(serverPath, cssIndex, cssDel);
  18404. DeleteColumn(serverPath, zcIndex, zcDel);
  18405. DeleteColumn(serverPath, otherIndex, otherDel);
  18406. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18407. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18408. DeleteColumn(serverPath, singleIndex, singleDel);
  18409. #endregion
  18410. //只保留第一个表格
  18411. DeleteSheet(serverPath);
  18412. return Ok(JsonView(true, "操作成功", url = rst));
  18413. }
  18414. else
  18415. {
  18416. _currency = _GroupCostParameter.Currency;
  18417. bool isIntType = int.TryParse(_currency, out int currId);
  18418. if (isIntType)
  18419. {
  18420. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18421. }
  18422. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18423. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18424. if (currInfo == null)
  18425. {
  18426. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18427. }
  18428. if (!_currency.ToUpper().Equals("CNY"))
  18429. {
  18430. _rate = _GroupCostParameter.Rate;
  18431. }
  18432. _rate = currInfo.Rate;
  18433. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18434. //string strFileName = "HotelStatement/";
  18435. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18436. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18437. #region 数据处理
  18438. foreach (var item in hrDtas)
  18439. {
  18440. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18441. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18442. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18443. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18444. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18445. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18446. string singleRoomFeeStr = string.Empty,
  18447. doubleRoomFeeStr = string.Empty,
  18448. suiteRoomFeeStr = string.Empty,
  18449. otherRoomFeeStr = string.Empty,
  18450. payMoneyStr = string.Empty,
  18451. cardPriceStr = string.Empty;
  18452. if (roomCurr.Equals(_currency))
  18453. {
  18454. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18455. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18456. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18457. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18458. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18459. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18460. }
  18461. else
  18462. {
  18463. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18464. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18465. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18466. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18467. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18468. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18469. }
  18470. string breakfastPriceStr = string.Empty,
  18471. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18472. governmentRentStr = string.Empty,
  18473. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18474. cityTaxStrStr = string.Empty,
  18475. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18476. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18477. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18478. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18479. int payDId = roomInfo?.PayDId ?? 0;
  18480. pcfds.Add(new HotelReservations_PCFD_View()
  18481. {
  18482. City = item.City,
  18483. HotelName = item.HotelName,
  18484. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18485. // SingleRoomCount = item.SingleRoomCount,
  18486. SingleRoomPrice = singleRoomFeeStr,
  18487. // DoubleRoomCount = item.DoubleRoomCount,
  18488. DoubleRoomPrice = doubleRoomFeeStr,
  18489. //SuiteRoomCount = item.SuiteRoomCount,
  18490. SuiteRoomPrice = suiteRoomFeeStr,
  18491. OtherRoomPrice = otherRoomFeeStr,
  18492. //OtherRoomCount = item.OtherRoomCount,
  18493. BreakfastPrice = breakfastPriceStr,
  18494. GovernmentRent = governmentRentStr,
  18495. CityTax = cityTaxStrStr,
  18496. RoomExplanation = item.RoomExplanation,
  18497. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18498. PayTime = roomInfo?.ConsumptionDate,
  18499. BankNo = roomInfo?.BankNo,
  18500. PayMoney = payMoneyStr,
  18501. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18502. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18503. CardPrice = cardPriceStr,
  18504. Remark = ccpInfo.Remark
  18505. });
  18506. }
  18507. #endregion
  18508. //载入模板
  18509. WorkbookDesigner designer = new WorkbookDesigner();
  18510. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18511. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18512. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18513. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18514. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18515. designer.SetDataSource("Opertor", userInfo.CnName);
  18516. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18517. dt.TableName = "ViewMyHotelReservations";
  18518. designer.SetDataSource(dt);
  18519. designer.Process();
  18520. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18521. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18522. designer.Workbook.Save(serverPath);
  18523. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18524. #region 删除指定行
  18525. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18526. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18527. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18528. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18529. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18530. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18531. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18532. cssIndex = dt.Columns["CityTax"].Ordinal,
  18533. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18534. remarkIndex = dt.Columns["Remark"].Ordinal;
  18535. //删除指定列
  18536. foreach (DataRow item in dt.Rows)
  18537. {
  18538. string singleStr = item["SingleRoomPrice"].ToString();
  18539. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18540. if (containsDigitButNotZero1) singleDel = false;
  18541. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18542. string doubleStr = item["DoubleRoomPrice"].ToString();
  18543. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18544. if (containsDigitButNotZero2) doubleDel = false;
  18545. string suiteStr = item["SuiteRoomPrice"].ToString();
  18546. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18547. if (containsDigitButNotZero3) suiteDel = false;
  18548. string otherStr = item["OtherRoomPrice"].ToString();
  18549. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18550. if (containsDigitButNotZero4) otherDel = false;
  18551. string zcStr = item["BreakfastPrice"].ToString();
  18552. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18553. if (containsDigitButNotZero5) zcDel = false;
  18554. string dsStr = item["GovernmentRent"].ToString();
  18555. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18556. if (containsDigitButNotZero6) dsDel = false;
  18557. string cssStr = item["CityTax"].ToString();
  18558. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18559. if (containsDigitButNotZero7) cssDel = false;
  18560. string cpStr = item["ConsumptionPatterns"].ToString();
  18561. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18562. string remarkStr = item["Remark"].ToString();
  18563. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18564. }
  18565. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18566. DeleteColumn(serverPath, cpIndex, cpDel);
  18567. DeleteColumn(serverPath, dsIndex, dsDel);
  18568. DeleteColumn(serverPath, cssIndex, cssDel);
  18569. DeleteColumn(serverPath, zcIndex, zcDel);
  18570. DeleteColumn(serverPath, otherIndex, otherDel);
  18571. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18572. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18573. DeleteColumn(serverPath, singleIndex, singleDel);
  18574. #endregion
  18575. //只保留第一个表格
  18576. DeleteSheet(serverPath);
  18577. return Ok(JsonView(true, "操作成功", url = rst));
  18578. }
  18579. //return Ok(JsonView(false));
  18580. }
  18581. /// <summary>
  18582. /// 删除指定列
  18583. /// </summary>
  18584. /// <param name="file"></param>
  18585. /// <param name="columnIndex"></param>
  18586. /// <param name="isDel"></param>
  18587. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18588. {
  18589. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18590. //wb.Save(file);
  18591. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18592. if (sheet1 != null)
  18593. {
  18594. if (isDel)
  18595. {
  18596. Cells cells = sheet1.Cells;
  18597. cells.DeleteColumn(columnIndex);
  18598. }
  18599. }
  18600. wb.Save(file);
  18601. }
  18602. /// <summary>
  18603. /// 删除sheet
  18604. /// </summary>
  18605. /// <param name="file"></param>
  18606. /// <param name="sheetName"></param>
  18607. private void DeleteSheet(string file, string sheetName = "")
  18608. {
  18609. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18610. //wb.Save(file);
  18611. List<string> sheets = new List<string>();
  18612. foreach (var item in wb.Worksheets)
  18613. {
  18614. sheets.Add(item.Name);
  18615. }
  18616. if (sheets.Count > 0)
  18617. {
  18618. sheets.RemoveAt(0);//不删除第一个sheet
  18619. foreach (var item in sheets)
  18620. {
  18621. wb.Worksheets.RemoveAt(item);
  18622. }
  18623. }
  18624. wb.Save(file);
  18625. }
  18626. /// <summary>
  18627. /// 酒店预订
  18628. /// 确认单
  18629. /// </summary>
  18630. /// <param name="_dto"></param>
  18631. /// <returns></returns>
  18632. [HttpPost]
  18633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18634. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18635. {
  18636. try
  18637. {
  18638. #region 参数验证
  18639. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18640. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18641. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18642. #region 团组操作权限验证 76 酒店预定模块
  18643. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18644. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18645. #endregion
  18646. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18647. #region 页面操作权限验证
  18648. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18649. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18650. #endregion
  18651. #endregion
  18652. //团组信息
  18653. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18654. //酒店数据
  18655. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18656. if (listhoteldata.Count < 0)
  18657. {
  18658. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18659. }
  18660. //利datatable存储
  18661. DataTable dt = new DataTable();
  18662. dt.Columns.Add("CheckInDate", typeof(string));
  18663. dt.Columns.Add("City", typeof(string));
  18664. dt.Columns.Add("Hotel", typeof(string));
  18665. dt.Columns.Add("Room", typeof(string));
  18666. for (int i = 0; i < listhoteldata.Count; i++)
  18667. {
  18668. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18669. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18670. while (dayStart < dayEnd)
  18671. {
  18672. string temp = "";
  18673. DataRow row = dt.NewRow();
  18674. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18675. row["City"] = listhoteldata[i].City;
  18676. row["Hotel"] = listhoteldata[i].HotelName;
  18677. if (listhoteldata[i].SingleRoomCount > 0)
  18678. {
  18679. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18680. }
  18681. if (listhoteldata[i].DoubleRoomCount > 0)
  18682. {
  18683. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18684. }
  18685. if (listhoteldata[i].SuiteRoomCount > 0)
  18686. {
  18687. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18688. }
  18689. if (listhoteldata[i].OtherRoomCount > 0)
  18690. {
  18691. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18692. }
  18693. row["Room"] = temp;
  18694. dt.Rows.Add(row);
  18695. dayStart = dayStart.AddDays(1);
  18696. }
  18697. }
  18698. Dictionary<string, string> dic = new Dictionary<string, string>();
  18699. dic.Add("Dele", di.TeamName);
  18700. dic.Add("City", di.VisitCountry);
  18701. //模板路径
  18702. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18703. //载入模板
  18704. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18705. DocumentBuilder builder = new DocumentBuilder(doc);
  18706. foreach (var key in dic.Keys)
  18707. {
  18708. builder.MoveToBookmark(key);
  18709. builder.Write(dic[key]);
  18710. }
  18711. //获取word里所有表格
  18712. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18713. //获取所填表格的序数
  18714. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18715. var rowStart = tableOne.Rows[0]; //获取第1行
  18716. //循环赋值
  18717. for (int i = 0; i < dt.Rows.Count; i++)
  18718. {
  18719. builder.MoveToCell(0, i + 1, 0, 0);
  18720. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18721. builder.MoveToCell(0, i + 1, 1, 0);
  18722. builder.Write(dt.Rows[i]["City"].ToString());
  18723. builder.MoveToCell(0, i + 1, 2, 0);
  18724. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18725. builder.MoveToCell(0, i + 1, 3, 0);
  18726. builder.Write(dt.Rows[i]["Room"].ToString());
  18727. }
  18728. //删除多余行
  18729. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18730. {
  18731. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18732. }
  18733. string strFileName = di.TeamName + "酒店确认单.doc";
  18734. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18735. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18736. return Ok(JsonView(true, "成功", url));
  18737. }
  18738. catch (Exception ex)
  18739. {
  18740. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18741. }
  18742. }
  18743. #endregion
  18744. #region 团组状态
  18745. /// <summary>
  18746. /// 团组状态列表 Page
  18747. /// </summary>
  18748. /// <param name="dto">团组列表请求dto</param>
  18749. /// <returns></returns>
  18750. [HttpPost]
  18751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18752. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18753. {
  18754. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18755. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18756. {
  18757. string sqlWhere = string.Empty;
  18758. if (dto.IsSure == 0) //未完成
  18759. {
  18760. sqlWhere += string.Format(@" And IsSure = 0");
  18761. }
  18762. else if (dto.IsSure == 1) //已完成
  18763. {
  18764. sqlWhere += string.Format(@" And IsSure = 1");
  18765. }
  18766. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18767. {
  18768. string tj = dto.SearchCriteria;
  18769. 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}%')",
  18770. tj, tj, tj, tj, tj);
  18771. }
  18772. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18773. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18774. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18775. From (
  18776. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18777. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18778. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18779. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18780. From Grp_DelegationInfo gdi
  18781. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18782. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18783. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18784. Where gdi.IsDel = 0 {0}
  18785. ) temp ", sqlWhere);
  18786. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18787. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18788. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18789. }
  18790. else
  18791. {
  18792. return Ok(JsonView(false, "查询失败"));
  18793. }
  18794. }
  18795. /// <summary>
  18796. /// 团组状态
  18797. /// 设置操作完成
  18798. /// </summary>
  18799. /// <param name="dto">团组列表请求dto</param>
  18800. /// <returns></returns>
  18801. [HttpPost]
  18802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18803. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18804. {
  18805. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18806. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18807. {
  18808. Id = dto.Id,
  18809. IsSure = 1
  18810. };
  18811. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18812. .UpdateColumns(it => new { it.IsSure })
  18813. .WhereColumns(it => new { it.Id })
  18814. .ExecuteCommandAsync();
  18815. if (result > 0)
  18816. {
  18817. return Ok(JsonView(true, "操作完成!"));
  18818. }
  18819. return Ok(JsonView(false, "操作失败!"));
  18820. }
  18821. #endregion
  18822. #region 保险费用录入
  18823. /// <summary>
  18824. /// 根据团组Id查询保险费用列表
  18825. /// </summary>
  18826. /// <param name="dto"></param>
  18827. /// <returns></returns>
  18828. [HttpPost]
  18829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18830. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18831. {
  18832. Result groupData = await _customersRep.CustomersByDiId(dto);
  18833. if (groupData.Code != 0)
  18834. {
  18835. return Ok(JsonView(false, groupData.Msg));
  18836. }
  18837. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18838. }
  18839. /// <summary>
  18840. /// 根据保险费用Id查询保险费用详细
  18841. /// </summary>
  18842. /// <param name="dto"></param>
  18843. /// <returns></returns>
  18844. [HttpPost]
  18845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18846. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18847. {
  18848. try
  18849. {
  18850. Result groupData = await _customersRep.CustomersById(dto);
  18851. if (groupData.Code != 0)
  18852. {
  18853. return Ok(JsonView(false, groupData.Msg));
  18854. }
  18855. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18856. }
  18857. catch (Exception ex)
  18858. {
  18859. return Ok(JsonView(false, ex.Message));
  18860. }
  18861. }
  18862. /// <summary>
  18863. /// 保险费用录入页面初始化绑定
  18864. /// </summary>
  18865. /// <param name="dto"></param>
  18866. /// <returns></returns>
  18867. [HttpPost]
  18868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18869. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18870. {
  18871. try
  18872. {
  18873. Result groupData = await _customersRep.CustomersInitialize(dto);
  18874. if (groupData.Code != 0)
  18875. {
  18876. return Ok(JsonView(false, groupData.Msg));
  18877. }
  18878. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18879. }
  18880. catch (Exception ex)
  18881. {
  18882. return Ok(JsonView(false, ex.Message));
  18883. }
  18884. }
  18885. /// <summary>
  18886. /// 保险费用操作(Status:1.新增,2.修改)
  18887. /// </summary>
  18888. /// <param name="dto"></param>
  18889. /// <returns></returns>
  18890. [HttpPost]
  18891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18892. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18893. {
  18894. Result groupData = await _customersRep.OpCustomers(dto);
  18895. if (groupData.Code != 0)
  18896. {
  18897. return Ok(JsonView(false, groupData.Msg));
  18898. }
  18899. #region 应用推送
  18900. try
  18901. {
  18902. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18903. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18904. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18905. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18906. //自动审核
  18907. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18908. //2024-10-21 新增LZ UID
  18909. var userIds = new List<int>() { 21 };
  18910. string title = $"系统通知";
  18911. var diId = dto.DiId;
  18912. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18913. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18914. string content = "";
  18915. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18916. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18917. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18918. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18919. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18920. }
  18921. catch (Exception ex)
  18922. {
  18923. }
  18924. #endregion
  18925. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18926. }
  18927. /// <summary>
  18928. /// 保险文件上传
  18929. /// </summary>
  18930. /// <param name="file"></param>
  18931. /// <returns></returns>
  18932. [HttpPost]
  18933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18934. public async Task<IActionResult> UploadCus(IFormFile file)
  18935. {
  18936. try
  18937. {
  18938. if (file != null)
  18939. {
  18940. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18941. //文件名称
  18942. string projectFileName = file.FileName;
  18943. //上传的文件的路径
  18944. string filePath = "";
  18945. if (!Directory.Exists(fileDir))
  18946. {
  18947. Directory.CreateDirectory(fileDir);
  18948. }
  18949. //上传的文件的路径
  18950. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18951. using (FileStream fs = System.IO.File.Create(filePath))
  18952. {
  18953. file.CopyTo(fs);
  18954. fs.Flush();
  18955. }
  18956. return Ok(JsonView(true, "上传成功!", projectFileName));
  18957. }
  18958. else
  18959. {
  18960. return Ok(JsonView(false, "上传失败!"));
  18961. }
  18962. }
  18963. catch (Exception ex)
  18964. {
  18965. return Ok(JsonView(false, "程序错误!"));
  18966. throw;
  18967. }
  18968. }
  18969. /// <summary>
  18970. /// 保险删除指定文件
  18971. /// </summary>
  18972. /// <param name="dto"></param>
  18973. /// <returns></returns>
  18974. [HttpPost]
  18975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18976. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18977. {
  18978. try
  18979. {
  18980. string filePath = "";
  18981. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18982. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18983. //int id = 0;
  18984. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18985. // 删除该文件
  18986. try
  18987. {
  18988. System.IO.File.Delete(filePath);
  18989. 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()
  18990. {
  18991. Attachment = "",
  18992. }).ExecuteCommandAsync();
  18993. if (result != 0)
  18994. {
  18995. return Ok(JsonView(true, "成功!"));
  18996. }
  18997. else
  18998. {
  18999. return Ok(JsonView(false, "失败!"));
  19000. }
  19001. }
  19002. catch (Exception)
  19003. {
  19004. 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()
  19005. {
  19006. Attachment = "",
  19007. }).ExecuteCommandAsync();
  19008. if (result != 0)
  19009. {
  19010. return Ok(JsonView(true, "成功!"));
  19011. }
  19012. else
  19013. {
  19014. return Ok(JsonView(false, "失败!"));
  19015. }
  19016. }
  19017. }
  19018. catch (Exception ex)
  19019. {
  19020. return Ok(JsonView(false, "程序错误!"));
  19021. throw;
  19022. }
  19023. }
  19024. /// <summary>
  19025. /// 保险费用操作(删除)
  19026. /// </summary>
  19027. /// <param name="dto"></param>
  19028. /// <returns></returns>
  19029. [HttpPost]
  19030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19031. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  19032. {
  19033. try
  19034. {
  19035. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  19036. if (!res)
  19037. {
  19038. return Ok(JsonView(false, "删除失败"));
  19039. }
  19040. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  19041. {
  19042. IsDel = 1,
  19043. DeleteUserId = dto.DeleteUserId,
  19044. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  19045. }).ExecuteCommandAsync();
  19046. return Ok(JsonView(true, "删除成功!"));
  19047. }
  19048. catch (Exception ex)
  19049. {
  19050. return Ok(JsonView(false, "程序错误!"));
  19051. throw;
  19052. }
  19053. }
  19054. #endregion
  19055. #region 接团客户名单 PageId 104
  19056. /// <summary>
  19057. /// 接团客户名单
  19058. /// 迁移数据(慎用!)
  19059. /// </summary>
  19060. /// <returns></returns>
  19061. [HttpPost]
  19062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19063. public async Task<IActionResult> PostTourClientListChange()
  19064. {
  19065. try
  19066. {
  19067. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  19068. //var groupClinetData1
  19069. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  19070. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  19071. int updateCount = 0;
  19072. if (oldOAClientList.Count > 0)
  19073. {
  19074. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  19075. _sqlSugar.BeginTran();
  19076. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  19077. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  19078. foreach (var item in oldOAClientList)
  19079. {
  19080. int comId = 0;
  19081. string format = "yyyy-MM-dd HH:mm:ss";
  19082. string data11 = "1990-01-01 00:00";
  19083. var data1 = IsValidDate(item.OPdate, format);
  19084. if (data1) data11 = item.OPdate;
  19085. //客户公司验证
  19086. if (!string.IsNullOrEmpty(item.Company))
  19087. {
  19088. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19089. if (clientComInfo == null) // add
  19090. {
  19091. var addInfo = new Crm_CustomerCompany()
  19092. {
  19093. CompanyAbbreviation = "",
  19094. CompanyFullName = item.Company,
  19095. Address = "",
  19096. PostCodes = "",
  19097. LastedOpUserId = item.OPer,
  19098. LastedOpDt = Convert.ToDateTime(data11),
  19099. CreateUserId = item.OPer,
  19100. CreateTime = Convert.ToDateTime(data11),
  19101. IsDel = 0
  19102. };
  19103. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19104. if (comId1 > 0) comId = comId1;
  19105. }
  19106. else comId = clientComInfo.Id;
  19107. }
  19108. //客户人员验证
  19109. int clientId = 0;
  19110. string name = item.LastName + item.Name;
  19111. if (!string.IsNullOrEmpty(name))
  19112. {
  19113. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19114. if (clientInfo == null)
  19115. {
  19116. DateTime? dateTime = null;
  19117. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19118. if (isDt) dateTime = birthDayDt;
  19119. var addInfo1 = new Crm_DeleClient()
  19120. {
  19121. CrmCompanyId = comId,
  19122. DiId = -1,
  19123. LastName = item.LastName,
  19124. FirstName = item.Name,
  19125. OldName = "",
  19126. Pinyin = item.Pinyin,
  19127. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19128. Marriage = 0,
  19129. Phone = item.Phone,
  19130. Job = item.Job,
  19131. BirthDay = dateTime
  19132. };
  19133. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19134. if (clientId1 > 0) clientId = clientId1;
  19135. }
  19136. else clientId = clientInfo.Id;
  19137. }
  19138. if (clientId < 1)
  19139. {
  19140. continue;
  19141. }
  19142. int airType = 0;
  19143. if (item.AirType == "超经舱") airType = 459;
  19144. else if (item.AirType == "公务舱") airType = 458;
  19145. else if (item.AirType == "经济舱") airType = 460;
  19146. else if (item.AirType == "其他") airType = 565;
  19147. else if (item.AirType == "头等舱") airType = 457;
  19148. var _TourClientListEntity = new Grp_TourClientList()
  19149. {
  19150. DiId = item.Diid,
  19151. ClientId = clientId,
  19152. CreateUserId = item.OPer,
  19153. CreateTime = Convert.ToDateTime(data11),
  19154. Remark = item.Remark,
  19155. IsDel = item.Isdel,
  19156. ShippingSpaceTypeId = airType,
  19157. ShippingSpaceSpecialNeeds = item.AirRemark,
  19158. HotelSpecialNeeds = item.RoomType
  19159. };
  19160. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19161. if (_TourClientList > 0)
  19162. {
  19163. updateCount++;
  19164. }
  19165. }
  19166. _sqlSugar.CommitTran();
  19167. }
  19168. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19169. }
  19170. catch (Exception ex)
  19171. {
  19172. _sqlSugar.RollbackTran();
  19173. return Ok(JsonView(false, ex.Message));
  19174. }
  19175. //return Ok(JsonView(true));
  19176. }
  19177. private bool IsValidDate(string dateString, string format)
  19178. {
  19179. DateTime dateValue;
  19180. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  19181. return valid;
  19182. }
  19183. /// <summary>
  19184. /// 接团客户名单
  19185. /// 根据团组Id查询List
  19186. /// </summary>
  19187. /// <param name="_dto"></param>
  19188. /// <returns></returns>
  19189. [HttpPost]
  19190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19191. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19192. {
  19193. #region 参数验证
  19194. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19195. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19196. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19197. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19198. #region 页面操作权限验证
  19199. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19200. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19201. #endregion
  19202. #endregion
  19203. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19204. if (viewData.Code != 0)
  19205. {
  19206. return Ok(JsonView(false, viewData.Msg));
  19207. }
  19208. return Ok(JsonView(viewData.Data));
  19209. }
  19210. /// <summary>
  19211. /// 接团客户名单
  19212. /// 基础数据 Init
  19213. /// </summary>
  19214. /// <param name="_dto"></param>
  19215. /// <returns></returns>
  19216. [HttpPost]
  19217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19218. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19219. {
  19220. #region 参数验证
  19221. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19222. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19223. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19224. #region 页面操作权限验证
  19225. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19226. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19227. #endregion
  19228. #endregion
  19229. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19230. }
  19231. /// <summary>
  19232. /// 接团客户名单
  19233. /// 根据 Id查询 Details
  19234. /// </summary>
  19235. /// <param name="_dto"></param>
  19236. /// <returns></returns>
  19237. [HttpPost]
  19238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19239. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19240. {
  19241. #region 参数验证
  19242. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19243. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19244. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19245. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19246. #region 页面操作权限验证
  19247. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19248. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19249. #endregion
  19250. #endregion
  19251. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19252. if (viewData.Code != 0)
  19253. {
  19254. return Ok(JsonView(false, viewData.Msg));
  19255. }
  19256. return Ok(JsonView(viewData.Data));
  19257. }
  19258. /// <summary>
  19259. /// 接团客户名单
  19260. /// Add Or Edit
  19261. /// </summary>
  19262. /// <param name="_dto"></param>
  19263. /// <returns></returns>
  19264. [HttpPost]
  19265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19266. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19267. {
  19268. #region 参数验证
  19269. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19270. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19271. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19272. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19273. #region 页面操作权限验证
  19274. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19275. if (_dto.Id == 0) //添加
  19276. {
  19277. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19278. }
  19279. else if (_dto.Id >= 0) //修改
  19280. {
  19281. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19282. }
  19283. #endregion
  19284. #endregion
  19285. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19286. if (viewData.Code != 0)
  19287. {
  19288. return Ok(JsonView(false, viewData.Msg));
  19289. }
  19290. return Ok(JsonView(true));
  19291. }
  19292. /// <summary>
  19293. /// 接团客户名单
  19294. /// json字符串 AddMultiple(添加多个)
  19295. /// </summary>
  19296. /// <param name="_dto"></param>
  19297. /// <returns></returns>
  19298. [HttpPost]
  19299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19300. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19301. {
  19302. #region 参数验证
  19303. string jsonLabel = _dto.JsonLabel;
  19304. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19305. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19306. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19307. #region 页面操作权限验证
  19308. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19309. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19310. #endregion
  19311. #endregion
  19312. var request = new TourClientListAddMultipleDto();
  19313. request.DiId = _dto.DiId;
  19314. request.UserId = _dto.UserId;
  19315. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19316. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19317. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19318. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19319. var infos = new List<TourClientListInfo>();
  19320. foreach (var data in datas)
  19321. {
  19322. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19323. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19324. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19325. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19326. {
  19327. continue;
  19328. }
  19329. infos.Add(new TourClientListInfo()
  19330. {
  19331. IsAccompany = 1,
  19332. LastName = lastName,
  19333. FirstName = firstName,
  19334. Pinyin = lastNameEn + @"/" + firstNameEn,
  19335. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19336. CompanyFullName = data.CompanyFullName,
  19337. Job = data.Job
  19338. });
  19339. }
  19340. if (infos.Any())
  19341. {
  19342. var viewData = await _tourClientListRep._AddMultiple(request);
  19343. if (viewData.Code != 0)
  19344. {
  19345. return Ok(JsonView(false, viewData.Msg));
  19346. }
  19347. return Ok(JsonView(true));
  19348. }
  19349. return Ok(JsonView(false));
  19350. }
  19351. /// <summary>
  19352. /// 接团客户名单
  19353. /// AddMultiple(添加多个)
  19354. /// </summary>
  19355. /// <param name="_dto"></param>
  19356. /// <returns></returns>
  19357. [HttpPost]
  19358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19359. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19360. {
  19361. #region 参数验证
  19362. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19363. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19364. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19365. #region 页面操作权限验证
  19366. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19367. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19368. #endregion
  19369. #endregion
  19370. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19371. if (viewData.Code != 0)
  19372. {
  19373. return Ok(JsonView(false, viewData.Msg));
  19374. }
  19375. return Ok(JsonView(true));
  19376. }
  19377. /// <summary>
  19378. /// 接团客户名单
  19379. /// Del
  19380. /// </summary>
  19381. /// <param name="_dto"></param>
  19382. /// <returns></returns>
  19383. [HttpPost]
  19384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19385. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19386. {
  19387. #region 参数验证
  19388. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19389. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19390. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19391. #region 页面操作权限验证
  19392. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19393. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19394. #endregion
  19395. #endregion
  19396. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19397. if (viewData.Code != 0)
  19398. {
  19399. return Ok(JsonView(false, viewData.Msg));
  19400. }
  19401. return Ok(JsonView(true));
  19402. }
  19403. /// <summary>
  19404. /// 接团客户名单
  19405. /// 文件下载 客户名单
  19406. /// </summary>
  19407. /// <param name="_dto"></param>
  19408. /// <returns></returns>
  19409. [HttpPost]
  19410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19411. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19412. {
  19413. #region 参数验证
  19414. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19415. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19416. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19417. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19418. #region 页面操作权限验证
  19419. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19420. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19421. #endregion
  19422. #endregion
  19423. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19424. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19425. From Grp_TourClientList tcl
  19426. Left Join
  19427. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19428. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19429. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19430. From Crm_DeleClient dc
  19431. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19432. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19433. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19434. Where dc.IsDel = 0) temp
  19435. On temp.DcId =tcl.ClientId
  19436. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19437. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19438. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19439. //载入模板
  19440. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19441. if (_dto.Language == 1)
  19442. {
  19443. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19444. }
  19445. //载入模板
  19446. var doc = new Document(tempPath);
  19447. DocumentBuilder builder = new DocumentBuilder(doc);
  19448. //获取word里所有表格
  19449. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19450. //获取所填表格的序数
  19451. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19452. var rowStart = tableOne.Rows[0]; //获取第1行
  19453. if (_dto.Language == 0)
  19454. {
  19455. //循环赋值
  19456. for (int i = 0; i < DcList.Count; i++)
  19457. {
  19458. EncryptionProcessor.DecryptProperties(DcList[i]);
  19459. builder.MoveToCell(0, i + 1, 0, 0);
  19460. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19461. builder.MoveToCell(0, i + 1, 1, 0);
  19462. int sex = DcList[i].Sex;
  19463. string sexStr = string.Empty;
  19464. if (sex == 0) sexStr = "男";
  19465. else if (sex == 1) sexStr = "女";
  19466. else sexStr = "未设置";
  19467. builder.Write(sexStr);
  19468. builder.MoveToCell(0, i + 1, 2, 0);
  19469. string birthDay = DcList[i].BirthDay;
  19470. string birthDayStr = string.Empty;
  19471. if (!string.IsNullOrEmpty(birthDay))
  19472. {
  19473. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19474. }
  19475. builder.Write(birthDayStr);
  19476. builder.MoveToCell(0, i + 1, 3, 0);
  19477. string company = "";
  19478. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19479. {
  19480. company = DcList[i].CompanyFullName.ToString();
  19481. }
  19482. builder.Write(company);
  19483. builder.MoveToCell(0, i + 1, 4, 0);
  19484. builder.Write(DcList[i].Job);
  19485. }
  19486. }
  19487. else if (_dto.Language == 1)
  19488. {
  19489. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19490. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19491. List<string> transArrayStr = new List<string>();
  19492. string transStrRes1 = "";
  19493. for (int i = 0; i < DcList.Count; i++)
  19494. {
  19495. var dc = DcList[i];
  19496. EncryptionProcessor.DecryptProperties(dc);
  19497. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19498. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19499. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19500. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19501. else transStrRes1 += $"{str1}|";
  19502. }
  19503. #region AI转英文
  19504. string jsonValue = JsonConvert.SerializeObject(DcList);
  19505. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19506. List<SeedMessages> messages = new List<SeedMessages>()
  19507. {
  19508. new SeedMessages
  19509. {
  19510. Role = KimiRole.user,
  19511. Content = jsonValue + text
  19512. }
  19513. };
  19514. KiMiApiClient client = new KiMiApiClient();
  19515. var kimiApiResult = await client.SeedMessage(messages);
  19516. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19517. string clients = kimiApiResult_JObject["content"].ToString();
  19518. string startStr = "```json", endStr = "```";
  19519. // 判断并清除开头部分
  19520. if (clients.StartsWith(startStr))
  19521. {
  19522. clients = clients.Remove(0, startStr.Length);
  19523. }
  19524. // 判断并清除结尾部分
  19525. if (clients.EndsWith(endStr))
  19526. {
  19527. clients = clients.Remove(clients.Length - endStr.Length);
  19528. }
  19529. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19530. //循环赋值
  19531. for (int i = 0; i < en_Json.Count; i++)
  19532. {
  19533. var dc = en_Json[i];
  19534. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19535. string PYName = dc.FirstName + " " + dc.LastName;
  19536. builder.MoveToCell(0, i + 1, 0, 0);
  19537. builder.Write(PYName);
  19538. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19539. builder.MoveToCell(0, i + 1, 1, 0);
  19540. builder.Write(sex);
  19541. DateTime birthDt;
  19542. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19543. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19544. builder.MoveToCell(0, i + 1, 2, 0);
  19545. builder.Write(birthday);
  19546. string company = string.Empty, job = string.Empty;
  19547. company = dc.CompanyFullName;
  19548. job = dc.Job;
  19549. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19550. {
  19551. //查询对照表
  19552. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19553. if (tempCec != null)
  19554. {
  19555. company = tempCec.enName;
  19556. }
  19557. }
  19558. builder.MoveToCell(0, i + 1, 3, 0);
  19559. builder.Write(company);
  19560. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19561. {
  19562. //查询对照表
  19563. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19564. if (tempPec != null)
  19565. {
  19566. job = tempPec.enName;
  19567. }
  19568. }
  19569. builder.MoveToCell(0, i + 1, 4, 0);
  19570. builder.Write(job);
  19571. }
  19572. #endregion
  19573. #region 旧翻译英文处理
  19574. ////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";
  19575. //string transStrRes = "";
  19576. //if (transStrRes1.Length > 0)
  19577. //{
  19578. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19579. //}
  19580. ////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
  19581. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19582. ////List<string> transArray = new List<string> { };
  19583. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19584. //if (transStrRes.Contains("|"))
  19585. //{
  19586. // string[] transArray1 = transStrRes.Split('|');
  19587. // if (transArray1.Length > 0)
  19588. // {
  19589. // foreach (var item in transArray1)
  19590. // {
  19591. // if (item.Contains("&"))
  19592. // {
  19593. // string[] transArray2 = item.Split('&');
  19594. // int index = 0;
  19595. // string companyName = "", job = "";
  19596. // if (transArray2.Length > 0)
  19597. // {
  19598. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19599. // if (1 < transArray2.Length) companyName = transArray2[1];
  19600. // if (2 < transArray2.Length) job = transArray2[2];
  19601. // }
  19602. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19603. // }
  19604. // }
  19605. // }
  19606. //}
  19607. ////循环赋值
  19608. //for (int i = 0; i < DcList.Count; i++)
  19609. //{
  19610. // string PYName = "";
  19611. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19612. // {
  19613. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19614. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19615. // PYName = PY_First + " " + PY_Last;
  19616. // }
  19617. // else
  19618. // {
  19619. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19620. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19621. // PYName = PY_First + " " + PY_Last;
  19622. // }
  19623. // builder.MoveToCell(0, i + 1, 0, 0);
  19624. // builder.Write(PYName);
  19625. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19626. // builder.MoveToCell(0, i + 1, 1, 0);
  19627. // builder.Write(sex);
  19628. // DateTime birthDt;
  19629. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19630. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19631. // builder.MoveToCell(0, i + 1, 2, 0);
  19632. // builder.Write(birthday);
  19633. // string company = string.Empty, job = string.Empty;
  19634. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19635. // if (dcTransInfo != null)
  19636. // {
  19637. // company = dcTransInfo.CompanyName;
  19638. // job = dcTransInfo.Job;
  19639. // }
  19640. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19641. // {
  19642. // //查询对照表
  19643. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19644. // if (tempCec != null)
  19645. // {
  19646. // company = tempCec.enName;
  19647. // }
  19648. // //翻译
  19649. // else
  19650. // {
  19651. // }
  19652. // }
  19653. // builder.MoveToCell(0, i + 1, 3, 0);
  19654. // builder.Write(company);
  19655. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19656. // {
  19657. // //查询对照表
  19658. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19659. // if (tempPec != null)
  19660. // {
  19661. // job = tempPec.enName;
  19662. // }
  19663. // //翻译
  19664. // else
  19665. // {
  19666. // }
  19667. // }
  19668. // builder.MoveToCell(0, i + 1, 4, 0);
  19669. // builder.Write(job);
  19670. //}
  19671. #endregion
  19672. }
  19673. //删除多余行
  19674. while (tableOne.Rows.Count > DcList.Count + 1)
  19675. {
  19676. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19677. }
  19678. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19679. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19680. doc.Save(fileDir);
  19681. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19682. return Ok(JsonView(true, "操作成功!", Url));
  19683. }
  19684. private class TranslateInfo
  19685. {
  19686. public int Index { get; set; }
  19687. public string CompanyName { get; set; }
  19688. public string Job { get; set; }
  19689. }
  19690. [HttpPost]
  19691. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19692. {
  19693. if (files.Count == 0)
  19694. {
  19695. return Ok(JsonView(false, "文件为空"));
  19696. }
  19697. KiMiApiClient KiMiApi = new KiMiApiClient();
  19698. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19699. if (seedConter.Count == 0)
  19700. {
  19701. return Ok(JsonView(false, "上传结果为空!"));
  19702. }
  19703. var messages = new List<SeedMessages>
  19704. {
  19705. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19706. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19707. };
  19708. messages.InsertRange(1, seedConter);
  19709. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19710. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19711. string clients = kimiApiResult_JObject["content"].ToString();
  19712. string startStr = "```json", endStr = "```";
  19713. // 判断并清除开头部分
  19714. if (clients.StartsWith(startStr))
  19715. {
  19716. clients = clients.Remove(0, startStr.Length);
  19717. }
  19718. // 判断并清除结尾部分
  19719. if (clients.EndsWith(endStr))
  19720. {
  19721. clients = clients.Remove(clients.Length - endStr.Length);
  19722. }
  19723. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19724. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19725. {
  19726. {"姓", "LastName" },
  19727. {"名", "FirstName" },
  19728. {"姓名拼音", "Pinyin" },
  19729. {"性别", "Sex" },
  19730. {"单位", "CompanyFullName" },
  19731. {"职务", "Job" },
  19732. {"出生日期", "Birthday" },
  19733. };
  19734. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19735. foreach (var item in clients_JObject)
  19736. {
  19737. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19738. foreach (var field in clientFieldMap.Keys)
  19739. {
  19740. if (item.TryGetValue(field, out JToken value))
  19741. {
  19742. var getValue = value.ToString();
  19743. System.Type type = cdc.GetType();
  19744. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19745. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19746. propertyInfo.SetValue(cdc, propertyValue);
  19747. }
  19748. }
  19749. crmClients.Add(cdc);
  19750. }
  19751. return Ok(JsonView(new
  19752. {
  19753. fileCount = files.Count,
  19754. UploadCount = seedConter.Count,
  19755. ApiResult = clients,
  19756. CrmClients = crmClients
  19757. }));
  19758. }
  19759. #endregion
  19760. #region 团组倒推表
  19761. /// <summary>
  19762. /// 倒推表基础数据
  19763. /// Init
  19764. /// </summary>
  19765. /// <returns></returns>
  19766. [HttpPost]
  19767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19768. public async Task<IActionResult> PostInvertedListInit()
  19769. {
  19770. var viewData = await _invertedListRep._Init();
  19771. if (viewData.Code != 0)
  19772. {
  19773. return Ok(JsonView(false, viewData.Msg));
  19774. }
  19775. return Ok(JsonView(viewData.Data));
  19776. }
  19777. /// <summary>
  19778. /// 倒推表
  19779. /// Info
  19780. /// </summary>
  19781. /// <param name="dto"></param>
  19782. /// <returns></returns>
  19783. [HttpPost]
  19784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19785. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19786. {
  19787. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19788. if (viewData.Code != 0)
  19789. {
  19790. return Ok(JsonView(false, viewData.Msg));
  19791. }
  19792. return Ok(JsonView(viewData.Data));
  19793. }
  19794. /// <summary>
  19795. /// 倒推表
  19796. /// Create
  19797. /// </summary>
  19798. /// <param name="dto"></param>
  19799. /// <returns></returns>
  19800. [HttpPost]
  19801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19802. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19803. {
  19804. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19805. if (viewData.Code != 0)
  19806. {
  19807. return Ok(JsonView(false, viewData.Msg));
  19808. }
  19809. return Ok(JsonView(viewData.Data));
  19810. }
  19811. /// <summary>
  19812. /// 倒推表
  19813. /// Update
  19814. /// </summary>
  19815. /// <param name="dto"></param>
  19816. /// <returns></returns>
  19817. [HttpPost]
  19818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19819. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19820. {
  19821. var viewData = await _invertedListRep._Update(dto);
  19822. if (viewData.Code != 0)
  19823. {
  19824. return Ok(JsonView(false, viewData.Msg));
  19825. }
  19826. return Ok(JsonView(viewData.Data));
  19827. }
  19828. /// <summary>
  19829. /// 倒推表
  19830. /// File Download
  19831. /// </summary>
  19832. /// <param name="dto"></param>
  19833. /// <returns></returns>
  19834. [HttpPost]
  19835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19836. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19837. {
  19838. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19839. if (info2.Code != 0)
  19840. {
  19841. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19842. }
  19843. var info1 = info2.Data as InvertedListInfoView;
  19844. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19845. string teamName = "";
  19846. if (info != null) teamName = info.TeamName;
  19847. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19848. var doc = new Document();
  19849. var builder = new DocumentBuilder(doc);
  19850. #region old insert
  19851. ////载入模板
  19852. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19853. //Document doc = new Document(tempPath);
  19854. //DocumentBuilder builder = new DocumentBuilder(doc);
  19855. //利用键值对存放数据
  19856. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19857. //dic.Add("TeamName", teamName);
  19858. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19859. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19860. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19861. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19862. //dic.Add("SQRemark", info1.ApprovalRemark);
  19863. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19864. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19865. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19866. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19867. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19868. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19869. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19870. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19871. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19872. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19873. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19874. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19875. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19876. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19877. //#region 填充word模板书签内容
  19878. //foreach (var key in dic.Keys)
  19879. //{
  19880. // builder.MoveToBookmark(key);
  19881. // builder.Write(dic[key]);
  19882. //}
  19883. //#endregion
  19884. #endregion
  19885. #region New Insert
  19886. string titleFont = $"仿宋",
  19887. contentFont = $"仿宋";
  19888. var fontColor = Color.FromArgb(64, 64, 64);
  19889. //设置标题 团组名称
  19890. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19891. builder.Font.Name = titleFont;
  19892. builder.Font.Color = fontColor;
  19893. builder.Font.Size = 12;
  19894. builder.Font.Bold = true;
  19895. builder.Writeln(teamName);
  19896. //设置副标题 团组出访时间
  19897. builder.Font.Size = 12;
  19898. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19899. builder.Writeln();
  19900. var backgroundColor = Color.FromArgb(199, 199, 199);
  19901. var table = builder.StartTable();
  19902. builder.InsertCell();
  19903. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19904. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19905. builder.CellFormat.Borders.LineWidth = 1;
  19906. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19907. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19908. builder.RowFormat.Height = 40;
  19909. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19910. builder.Font.Name = contentFont;
  19911. builder.Font.Size = 12;
  19912. builder.Font.Bold = true;
  19913. builder.Font.Color = fontColor;
  19914. builder.Write("时间");
  19915. builder.InsertCell();
  19916. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19917. builder.Write("流程");
  19918. builder.InsertCell();
  19919. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19920. builder.Write("说明");
  19921. builder.EndRow();
  19922. //报批资料准备
  19923. if (info1.IsSelectedAirportd)
  19924. {
  19925. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19926. }
  19927. //报批/提供送签资料
  19928. if (info1.IsSelectedApprovalData)
  19929. {
  19930. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19931. }
  19932. //出批件护照办理
  19933. if (info1.IsSelectedIssueApproval)
  19934. {
  19935. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19936. }
  19937. //签证资料准备
  19938. if (info1.IsSelectedVisaInfo)
  19939. {
  19940. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19941. }
  19942. //送签
  19943. if (info1.IsSelectedSendVisa)
  19944. {
  19945. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19946. }
  19947. //出签
  19948. if (info1.IsSelectedIssueVisa)
  19949. {
  19950. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19951. }
  19952. //机票
  19953. if (info1.IsSelectedAirTicket)
  19954. {
  19955. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19956. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19957. }
  19958. //酒店
  19959. if (info1.IsSelectedHotel)
  19960. {
  19961. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19962. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19963. }
  19964. //开行前会
  19965. if (info1.IsSelectedPreTripMeeting)
  19966. {
  19967. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19968. }
  19969. //送机
  19970. if (info1.IsSelectedAirportdDropOff)
  19971. {
  19972. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19973. }
  19974. builder.EndTable();
  19975. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19976. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19977. for (int i = 0; i < table.Rows.Count; i++)
  19978. {
  19979. var row = table.Rows[i];
  19980. //设置宽度
  19981. row.Cells[0].CellFormat.Width = 20.00;
  19982. row.Cells[1].CellFormat.Width = 30.00;
  19983. row.Cells[2].CellFormat.Width = 50.00;
  19984. if (i != 0)
  19985. {
  19986. //边框设置
  19987. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19988. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19989. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19990. }
  19991. }
  19992. #region 页脚插入图片
  19993. // 创建页脚
  19994. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19995. doc.FirstSection.HeadersFooters.Add(footer);
  19996. Paragraph para = new Paragraph(doc);
  19997. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19998. footer.AppendChild(para);
  19999. builder.MoveTo(para);
  20000. string imagePath = "./Images/FMGJ_Log.png";
  20001. builder.InsertImage(imagePath);
  20002. #endregion
  20003. #endregion
  20004. var fileDir = AppSettingsHelper.Get("WordBasePath");
  20005. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  20006. string filePath = fileDir + $@"InvertedList/{fileName}";
  20007. doc.Save(filePath);
  20008. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  20009. return Ok(JsonView(true, "操作成功!", Url));
  20010. }
  20011. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  20012. {
  20013. var fontColor = Color.FromArgb(64, 64, 64);
  20014. builder.InsertCell();
  20015. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  20016. builder.RowFormat.Height = 40;
  20017. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20018. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  20019. builder.Font.Name = fontName;
  20020. builder.Font.Size = 8;
  20021. builder.Font.Bold = true;
  20022. builder.Font.Color = fontColor;
  20023. builder.Write(dateTime);
  20024. builder.InsertCell();
  20025. builder.Font.Size = 9;
  20026. builder.Font.Bold = true;
  20027. builder.Font.Color = fontColor;
  20028. builder.Write(content);
  20029. builder.InsertCell();
  20030. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  20031. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  20032. builder.Font.Size = 9;
  20033. builder.Font.Bold = false;
  20034. builder.Font.Color = fontColor;
  20035. builder.Write(reamrk);
  20036. builder.EndRow();
  20037. }
  20038. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  20039. {
  20040. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  20041. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  20042. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  20043. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  20044. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  20045. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  20046. }
  20047. #endregion
  20048. #region 会务倒推表
  20049. /// <summary>
  20050. /// 会务倒推表
  20051. /// Init
  20052. /// </summary>
  20053. /// <returns></returns>
  20054. [HttpPost]
  20055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20056. public async Task<IActionResult> InforRetrogressTableInit()
  20057. {
  20058. var groupData = await _groupRepository.PostShareGroupInfos(1);
  20059. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  20060. return Ok(JsonView(false, groupData.Msg));
  20061. }
  20062. /// <summary>
  20063. /// 会务倒推表
  20064. /// ExcelDownload
  20065. /// </summary>
  20066. /// <param name="dto"></param>
  20067. /// <returns></returns>
  20068. [HttpPost]
  20069. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  20070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20071. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  20072. {
  20073. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  20074. var validatorRes = await validator.ValidateAsync(dto);
  20075. if (!validatorRes.IsValid)
  20076. {
  20077. StringBuilder sb = new StringBuilder();
  20078. foreach (var item in validatorRes.Errors)
  20079. {
  20080. sb.AppendLine(item.ErrorMessage);
  20081. }
  20082. return Ok(JsonView(false, sb.ToString()));
  20083. }
  20084. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20085. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20086. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20087. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20088. #region Excel
  20089. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20090. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20091. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20092. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20093. var fileNamePrefix = string.Empty;
  20094. if (days >= 30)
  20095. {
  20096. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20097. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20098. }
  20099. else if (days < 30 && days > 7)
  20100. {
  20101. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20102. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20103. }
  20104. else if (days <= 7)
  20105. {
  20106. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20107. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20108. }
  20109. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20110. fileName = CommonFun.ValidFileName(fileName);
  20111. //载入模板
  20112. WorkbookDesigner designer = new WorkbookDesigner();
  20113. designer.Workbook = new Workbook(tempPath);
  20114. designer.Process();
  20115. if (!Directory.Exists(savePath))
  20116. {
  20117. Directory.CreateDirectory(savePath);
  20118. }
  20119. string serverPath = $"{savePath}{fileName}";
  20120. designer.Workbook.Save(serverPath);
  20121. string rst = $"{servicePath}{ftpPath}{fileName}";
  20122. #endregion
  20123. return Ok(JsonView(new { url = rst }));
  20124. }
  20125. #endregion
  20126. #region 三公签证费用(签证费、代办费)
  20127. /// <summary>
  20128. /// 三公签证费用(签证费、代办费)
  20129. /// List
  20130. /// </summary>
  20131. /// <returns></returns>
  20132. [HttpPost]
  20133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20134. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20135. {
  20136. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20137. if (_view.Code != 0)
  20138. {
  20139. return Ok(JsonView(false, _view.Msg));
  20140. }
  20141. return Ok(JsonView(true, "操作成功!", _view.Data));
  20142. }
  20143. /// <summary>
  20144. /// 三公签证费用(签证费、代办费)
  20145. /// Add Or Update
  20146. /// </summary>
  20147. /// <returns></returns>
  20148. [HttpPost]
  20149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20150. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20151. {
  20152. var _view = await _visaFeeInfoRep._Update(_dto);
  20153. if (_view.Code != 0)
  20154. {
  20155. return Ok(JsonView(false, _view.Msg));
  20156. }
  20157. return Ok(JsonView(true, _view.Msg));
  20158. }
  20159. #endregion
  20160. #region 酒店询价
  20161. /// <summary>
  20162. /// 酒店询价
  20163. /// Init
  20164. /// </summary>
  20165. /// <returns></returns>
  20166. [HttpPost]
  20167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20168. public async Task<IActionResult> PostHotelInquiryInit()
  20169. {
  20170. var res = await _hotelInquiryRep._Init();
  20171. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20172. return Ok(JsonView(true, res.Msg, res.Data));
  20173. }
  20174. /// <summary>
  20175. /// 酒店询价
  20176. /// page Item
  20177. /// </summary>
  20178. /// <param name="_dto"></param>
  20179. /// <returns></returns>
  20180. [HttpPost]
  20181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20182. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20183. {
  20184. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20185. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20186. var view = res.Data as PageDataViewBase;
  20187. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20188. }
  20189. /// <summary>
  20190. /// 酒店询价
  20191. /// info
  20192. /// </summary>
  20193. /// <param name="_dto"></param>
  20194. /// <returns></returns>
  20195. [HttpPost]
  20196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20197. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20198. {
  20199. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20200. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20201. return Ok(JsonView(true, res.Msg, res.Data));
  20202. }
  20203. /// <summary>
  20204. /// 酒店询价
  20205. /// Add Or Edit
  20206. /// </summary>
  20207. /// <param name="_dto"></param>
  20208. /// <returns></returns>
  20209. [HttpPost]
  20210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20211. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20212. {
  20213. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20214. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20215. return Ok(JsonView(true, res.Msg, res.Data));
  20216. }
  20217. /// <summary>
  20218. /// 酒店询价
  20219. /// Del
  20220. /// </summary>
  20221. /// <param name="_dto"></param>
  20222. /// <returns></returns>
  20223. [HttpPost]
  20224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20225. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20226. {
  20227. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20228. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20229. return Ok(JsonView(true, res.Msg, res.Data));
  20230. }
  20231. #endregion
  20232. #region 下载匹配op行程单
  20233. /// <summary>
  20234. /// 匹配op行程单
  20235. /// Init
  20236. /// </summary>
  20237. /// <param name="dto">团组列表请求dto</param>
  20238. /// <returns></returns>
  20239. [HttpPost]
  20240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20241. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20242. {
  20243. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20244. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20245. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20246. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20247. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20248. .Where(it => it.IsDel == 0)
  20249. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20250. .OrderByDescending(it => it.VisitStartDate)
  20251. .ToList();
  20252. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20253. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20254. var diids = groupInfos.Select(it => it.Id).ToList();
  20255. List<string> countrys = new List<string>();
  20256. foreach (var item in country)
  20257. {
  20258. var data = _groupRepository.FormartTeamName(item);
  20259. var dataArray = _groupRepository.GroupSplitCountry(data);
  20260. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20261. }
  20262. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20263. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20264. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20265. foreach (var item in areaItem)
  20266. {
  20267. string areaStr = item.Value;
  20268. if (!string.IsNullOrEmpty(areaStr))
  20269. {
  20270. string[] str1 = areaStr.Split("-");
  20271. if (str1.Length > 0)
  20272. {
  20273. areaArray.AddRange(str1);
  20274. }
  20275. }
  20276. }
  20277. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20278. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20279. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20280. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20281. .ToList();
  20282. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20283. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20284. .Where(it => countriesIds.Contains(it.Id))
  20285. .Select(it => new { it.Id, Name = it.Name_CN })
  20286. .ToList();
  20287. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20288. .Select(it => it.TeamName).ToList();
  20289. stopwatch.Stop();
  20290. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20291. }
  20292. ///// <summary>
  20293. ///// 匹配op行程单
  20294. ///// Init 查询区域数据
  20295. ///// </summary>
  20296. ///// <param name="dto">团组列表请求dto</param>
  20297. ///// <returns></returns>
  20298. //[HttpPost]
  20299. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20300. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20301. //{
  20302. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20303. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20304. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20305. // if (string.IsNullOrEmpty(countriesDataStr))
  20306. // {
  20307. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20308. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20309. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20310. // }
  20311. // else
  20312. // {
  20313. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20314. // }
  20315. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20316. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20317. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20318. // List<dynamic> childList = new List<dynamic>();
  20319. // int parentId = dto.CountriesId;
  20320. // if (provinceData.Count > 1)
  20321. // {
  20322. // foreach (var item1 in provinceData)
  20323. // {
  20324. // List<dynamic> childList1 = new List<dynamic>();
  20325. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20326. // foreach (var item2 in citiesData1)
  20327. // {
  20328. // List<dynamic> childList2 = new List<dynamic>();
  20329. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20330. // foreach (var item3 in countiesData1)
  20331. // {
  20332. // childList2.Add(new
  20333. // {
  20334. // id = item3.Id,
  20335. // parentId = item2.Id,
  20336. // level = "district",
  20337. // name = item3.Name_CN,
  20338. // });
  20339. // }
  20340. // childList1.Add(new
  20341. // {
  20342. // id = item2.Id,
  20343. // parentId = item1.Id,
  20344. // level = "city",
  20345. // name = item2.Name_CN,
  20346. // childList = childList2
  20347. // });
  20348. // }
  20349. // childList.Add(new
  20350. // {
  20351. // id = item1.Id,
  20352. // parentId = parentId,
  20353. // level = "province",
  20354. // name = item1.Name_CN,
  20355. // childList = childList1
  20356. // });
  20357. // }
  20358. // //城市
  20359. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20360. // foreach (var item2 in citiesData2)
  20361. // {
  20362. // List<dynamic> childList22 = new List<dynamic>();
  20363. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20364. // foreach (var item3 in countiesData1)
  20365. // {
  20366. // childList22.Add(new
  20367. // {
  20368. // id = item3.Id,
  20369. // parentId = item2.Id,
  20370. // level = "district",
  20371. // name = item3.Name_CN,
  20372. // });
  20373. // }
  20374. // childList.Add(new
  20375. // {
  20376. // id = item2.Id,
  20377. // parentId = parentId,
  20378. // level = "city",
  20379. // name = item2.Name_CN,
  20380. // childList = childList22
  20381. // });
  20382. // }
  20383. // }
  20384. // else
  20385. // {
  20386. // foreach (var item2 in citiesData)
  20387. // {
  20388. // string cname = item2.Name_CN;
  20389. // List<dynamic> childList1 = new List<dynamic>();
  20390. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20391. // foreach (var item3 in countiesData1)
  20392. // {
  20393. // childList1.Add(new
  20394. // {
  20395. // Id = item3.Id,
  20396. // parentId = item2.Id,
  20397. // level = "district",
  20398. // name = item3.Name_CN
  20399. // });
  20400. // }
  20401. // childList.Add(new
  20402. // {
  20403. // id = item2.Id,
  20404. // parentId = parentId,
  20405. // level = "city",
  20406. // name = item2.Name_CN,
  20407. // childList = childList1
  20408. // });
  20409. // }
  20410. // }
  20411. // stopwatch.Stop();
  20412. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20413. //}
  20414. /// <summary>
  20415. /// 匹配op行程单
  20416. /// 接团信息列表 Page
  20417. /// </summary>
  20418. /// <param name="dto">团组列表请求dto</param>
  20419. /// <returns></returns>
  20420. [HttpPost]
  20421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20422. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20423. {
  20424. var swatch = new Stopwatch();
  20425. swatch.Start();
  20426. #region 参数验证
  20427. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20428. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20429. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20430. #region 页面操作权限验证
  20431. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20432. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20433. #endregion
  20434. #endregion
  20435. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20436. {
  20437. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20438. //string sqlWhere = "";
  20439. if (!string.IsNullOrEmpty(dto.Country))
  20440. {
  20441. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20442. }
  20443. if (!string.IsNullOrEmpty(dto.Area))
  20444. {
  20445. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20446. }
  20447. if (!string.IsNullOrEmpty(dto.TeamName))
  20448. {
  20449. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20450. }
  20451. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20452. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20453. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20454. swatch.Stop();
  20455. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20456. }
  20457. else
  20458. {
  20459. return Ok(JsonView(false, "查询失败"));
  20460. }
  20461. }
  20462. /// <summary>
  20463. /// 匹配op行程单
  20464. /// 行程单下载
  20465. /// </summary>
  20466. /// <param name="dto">团组列表请求dto</param>
  20467. /// <returns></returns>
  20468. [HttpPost]
  20469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20470. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20471. {
  20472. #region 参数验证
  20473. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20474. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20475. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20476. #region 页面操作权限验证
  20477. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20478. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20479. #endregion
  20480. #endregion
  20481. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20482. {
  20483. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20484. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20485. }
  20486. else
  20487. {
  20488. return Ok(JsonView(false, "下载失败!"));
  20489. }
  20490. }
  20491. #endregion
  20492. #region 国家信息 数据 注释
  20493. //[HttpPost]
  20494. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20495. //{
  20496. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20497. // foreach (var item in dto)
  20498. // {
  20499. // infos.Add(new Grp_GroupsTaskAssignment()
  20500. // {
  20501. // DIId = item,
  20502. // CTId = 82,
  20503. // UId = 248,
  20504. // IsEnable = 1,
  20505. // CreateUserId = 233,
  20506. // CreateTime = DateTime.Now,
  20507. // IsDel = 0
  20508. // });
  20509. // infos.Add(new Grp_GroupsTaskAssignment()
  20510. // {
  20511. // DIId = item,
  20512. // CTId = 82,
  20513. // UId = 286,
  20514. // IsEnable = 1,
  20515. // CreateUserId = 233,
  20516. // CreateTime = DateTime.Now,
  20517. // IsDel = 0
  20518. // });
  20519. // }
  20520. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20521. // return Ok("操作成功");
  20522. //}
  20523. //public class paramJsonDto
  20524. //{
  20525. // public List<CountriesInfo> str { get; set; }
  20526. //}
  20527. //[HttpPost]
  20528. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20529. //{
  20530. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20531. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20532. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20533. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20534. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20535. // _sqlSugar.BeginTran();
  20536. // int countitiesIndex = 0;
  20537. // foreach (var item in dto.str)
  20538. // {
  20539. // dynamic data = item.c;
  20540. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20541. // if (data != null)
  20542. // {
  20543. // countitiesIndex++;
  20544. // foreach (var item1 in data)
  20545. // {
  20546. // string cnname = item1.cn;
  20547. // string enname = item1.en;
  20548. // Sys_Cities provinceInfo = new Sys_Cities()
  20549. // {
  20550. // CountriesId = countriesId,
  20551. // Name_CN = cnname,
  20552. // Name_EN = enname,
  20553. // ParentId = 0,
  20554. // IsCapital = 1,
  20555. // CreateUserId = 208,
  20556. // CreateTime = DateTime.Now,
  20557. // IsDel = 0
  20558. // };
  20559. // if (item1.lv == "province") //省份
  20560. // {
  20561. // provinceInfo.Level = 1;
  20562. // int provinceId = 0;
  20563. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20564. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20565. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20566. // var data1 = item1.c;
  20567. // foreach (var item2 in data1)
  20568. // {
  20569. // if (item2.lv == "city")
  20570. // {
  20571. // string citycnname = item2.cn;
  20572. // string cityenname = item2.en;
  20573. // Sys_Cities cityInfo = new Sys_Cities()
  20574. // {
  20575. // CountriesId = countriesId,
  20576. // ParentId = provinceId,
  20577. // Level = 2,
  20578. // Name_CN = citycnname,
  20579. // Name_EN = cityenname,
  20580. // IsCapital = 1,
  20581. // CreateUserId = 208,
  20582. // CreateTime = DateTime.Now,
  20583. // IsDel = 0
  20584. // };
  20585. // if (item2.c != null)
  20586. // {
  20587. // int cityId = 0;
  20588. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20589. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20590. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20591. // foreach (var item3 in item2.c)
  20592. // {
  20593. // if (item3.lv == "district")
  20594. // {
  20595. // var districtInfo = new Sys_Cities()
  20596. // {
  20597. // CountriesId = countriesId,
  20598. // Name_CN = item3.cn,
  20599. // Name_EN = item3.en,
  20600. // Level = 3,
  20601. // ParentId = cityId,
  20602. // IsCapital = 1,
  20603. // CreateUserId = 208,
  20604. // CreateTime = DateTime.Now,
  20605. // IsDel = 0
  20606. // };
  20607. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20608. // //{
  20609. // districts.Add(districtInfo);
  20610. // //}
  20611. // }
  20612. // }
  20613. // }
  20614. // else
  20615. // {
  20616. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20617. // //{
  20618. // cities.Add(cityInfo);
  20619. // //}
  20620. // }
  20621. // }
  20622. // }
  20623. // }
  20624. // else if (item1.lv == "city")//城市
  20625. // {
  20626. // provinceInfo.Level = 2;
  20627. // if (item1.c != null)
  20628. // {
  20629. // int cityId = 0;
  20630. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20631. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20632. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20633. // foreach (var item3 in item1.c)
  20634. // {
  20635. // if (item3.lv == "district")
  20636. // {
  20637. // var districtInfo = new Sys_Cities()
  20638. // {
  20639. // CountriesId = countriesId,
  20640. // Name_CN = item3.cn,
  20641. // Name_EN = item3.en,
  20642. // Level = 3,
  20643. // ParentId = cityId,
  20644. // IsCapital = 1,
  20645. // CreateUserId = 208,
  20646. // CreateTime = DateTime.Now,
  20647. // IsDel = 0
  20648. // };
  20649. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20650. // //{
  20651. // districts.Add(districtInfo);
  20652. // //}
  20653. // }
  20654. // }
  20655. // }
  20656. // else
  20657. // {
  20658. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20659. // //{
  20660. // cities.Add(provinceInfo);
  20661. // //}
  20662. // }
  20663. // }
  20664. // }
  20665. // }
  20666. // }
  20667. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20668. // cities = cities.Distinct().ToList();
  20669. // districts = districts.Distinct().ToList();
  20670. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20671. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20672. // cities.AddRange(districts);
  20673. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20674. // //_sqlSugar.RollbackTran();
  20675. // _sqlSugar.CommitTran();
  20676. // return Ok(JsonView(false, "操作成功!"));
  20677. //}
  20678. //[HttpPost]
  20679. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20680. //{
  20681. // List<CountitiesInfo> infos = dto.MyProperty;
  20682. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20683. // _sqlSugar.BeginTran();
  20684. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20685. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20686. // foreach (var item in infos)
  20687. // {
  20688. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20689. // if (countryInfo != null)
  20690. // {
  20691. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20692. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20693. // if (cityInfo1 != null)
  20694. // {
  20695. // cityInfo1.IsCapital = 0;
  20696. // cityInfos.Add(cityInfo1);
  20697. // }
  20698. // }
  20699. // }
  20700. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20701. // .UpdateColumns(it => it.IsCapital)
  20702. // .WhereColumns(it => it.Id)
  20703. // .ExecuteCommand();
  20704. // //_sqlSugar.RollbackTran();
  20705. // _sqlSugar.CommitTran();
  20706. // return Ok(JsonView(false, "操作成功!"));
  20707. //}
  20708. //public class CounrtiesDto
  20709. //{
  20710. // public List<CountitiesInfo> MyProperty { get; set; }
  20711. //}
  20712. //public class CountitiesInfo
  20713. //{
  20714. // /// <summary>
  20715. // /// 圣约翰
  20716. // /// </summary>
  20717. // public string capital_name_chinese { get; set; }
  20718. // /// <summary>
  20719. // ///
  20720. // /// </summary>
  20721. // public string capital_name { get; set; }
  20722. // /// <summary>
  20723. // ///
  20724. // /// </summary>
  20725. // public string country_type { get; set; }
  20726. // /// <summary>
  20727. // /// 安提瓜和巴布达
  20728. // /// </summary>
  20729. // public string country_name_chinese { get; set; }
  20730. // /// <summary>
  20731. // /// 安提瓜和巴布达
  20732. // /// </summary>
  20733. // public string country_name_chinese_short { get; set; }
  20734. // /// <summary>
  20735. // /// 安提瓜和巴布达
  20736. // /// </summary>
  20737. // public string country_name_chinese_UN { get; set; }
  20738. // /// <summary>
  20739. // ///
  20740. // /// </summary>
  20741. // public string country_name_english_abbreviation { get; set; }
  20742. // /// <summary>
  20743. // ///
  20744. // /// </summary>
  20745. // public string country_name_english_formal { get; set; }
  20746. // /// <summary>
  20747. // ///
  20748. // /// </summary>
  20749. // public string country_name_english_UN { get; set; }
  20750. // /// <summary>
  20751. // ///
  20752. // /// </summary>
  20753. // public string continent_name { get; set; }
  20754. // /// <summary>
  20755. // ///
  20756. // /// </summary>
  20757. // public string subregion_name { get; set; }
  20758. // /// <summary>
  20759. // ///
  20760. // /// </summary>
  20761. // public string country_code2 { get; set; }
  20762. // /// <summary>
  20763. // ///
  20764. // /// </summary>
  20765. // public string country_code3 { get; set; }
  20766. // /// <summary>
  20767. // ///
  20768. // /// </summary>
  20769. // public string phone_code { get; set; }
  20770. //}
  20771. //public class CountriesInfo : BasicInfo
  20772. //{
  20773. // public List<CitiesInfo> c { get; set; }
  20774. //}
  20775. //public class CitiesInfo : BasicInfo
  20776. //{
  20777. // public List<AreaInfo> c { get; set; }
  20778. //}
  20779. //public class AreaInfo : BasicInfo
  20780. //{
  20781. // public List<AreaInfo> c { get; set; }
  20782. //}
  20783. //public class BasicInfo
  20784. //{
  20785. // public string code { get; set; }
  20786. // public string cn { get; set; }
  20787. // public string lv { get; set; }
  20788. // public string en { get; set; }
  20789. //}
  20790. #endregion
  20791. #region 查看邀请方
  20792. /// <summary>
  20793. /// 查看邀请方
  20794. /// 邀请方信息 Init
  20795. /// </summary>
  20796. /// <param name="dto"></param>
  20797. /// <returns></returns>
  20798. [HttpPost]
  20799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20800. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20801. {
  20802. string sqlWhere = string.Empty;
  20803. if (!string.IsNullOrEmpty(dto.Search))
  20804. {
  20805. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20806. }
  20807. string sql = string.Format($@"Select
  20808. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20809. Id,
  20810. UnitName
  20811. From Res_InvitationOfficialActivityData
  20812. Where IsDel = 0
  20813. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20814. RefAsync<int> total = 0;
  20815. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20816. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20817. }
  20818. /// <summary>
  20819. /// 查看邀请方
  20820. /// 国家信息 Init
  20821. /// </summary>
  20822. /// <param name="dto"></param>
  20823. /// <returns></returns>
  20824. [HttpPost]
  20825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20826. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20827. {
  20828. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20829. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20830. var diids = groupInfos.Select(it => it.Id).ToList();
  20831. List<string> countrys = new List<string>();
  20832. foreach (var item in country)
  20833. {
  20834. var data = _groupRepository.FormartTeamName(item);
  20835. var dataArray = _groupRepository.GroupSplitCountry(data);
  20836. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20837. }
  20838. countrys = countrys.Distinct().ToList();
  20839. for (int i = 0; i < countrys.Count; i++)
  20840. {
  20841. string item = countrys[i];
  20842. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20843. {
  20844. countrys.Remove(item);
  20845. i--;
  20846. }
  20847. }
  20848. RefAsync<int> total = 0;
  20849. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20850. .Where(it => countrys.Contains(it.Name_CN))
  20851. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20852. .Select(it => new { id = it.Id, name = it.Name_CN })
  20853. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20854. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20855. }
  20856. /// <summary>
  20857. /// 查看邀请方
  20858. /// 城市信息 Init
  20859. /// </summary>
  20860. /// <param name="dto"></param>
  20861. /// <returns></returns>
  20862. [HttpPost]
  20863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20864. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20865. {
  20866. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20867. RefAsync<int> total = 0;
  20868. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20869. .Where(it => it.CountriesId == dto.CountiesId)
  20870. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20871. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20872. .Select(it => new { id = it.Id, name = it.Name_CN })
  20873. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20874. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20875. }
  20876. /// <summary>
  20877. /// 查看邀请方
  20878. /// 团组名称 Init
  20879. /// </summary>
  20880. /// <param name="dto"></param>
  20881. /// <returns></returns>
  20882. [HttpPost]
  20883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20884. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20885. {
  20886. var watch = new Stopwatch();
  20887. watch.Start();
  20888. RefAsync<int> total = 0;
  20889. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20890. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20891. .Where((oa, di) => oa.IsDel == 0)
  20892. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20893. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20894. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20895. .Distinct()
  20896. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20897. watch.Stop();
  20898. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20899. }
  20900. /// <summary>
  20901. /// 查看邀请方
  20902. /// 团组 & 邀请方信息
  20903. /// </summary>
  20904. /// <param name="dto"></param>
  20905. /// <returns></returns>
  20906. [HttpPost]
  20907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20908. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20909. {
  20910. var watch = new Stopwatch();
  20911. watch.Start();
  20912. RefAsync<int> total = 0;
  20913. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20914. .AS("Grp_DelegationInfo")
  20915. .Includes(x => x.InvitingInfos)
  20916. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20917. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20918. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20919. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20920. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20921. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20922. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20923. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20924. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20925. infos.ForEach(x =>
  20926. {
  20927. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20928. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20929. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20930. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20931. });
  20932. watch.Stop();
  20933. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20934. }
  20935. #endregion
  20936. #region 报批行程
  20937. /// <summary>
  20938. /// 报批行程初始化
  20939. /// </summary>
  20940. /// <param name="dto"></param>
  20941. /// <returns></returns>
  20942. [HttpPost]
  20943. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20944. {
  20945. const int chiNumber = 5;
  20946. var jw = JsonView(false);
  20947. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20948. var group = groupList.First();
  20949. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20950. group = groupList.First(x => x.Id == diid);
  20951. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20952. .Where(x => x.DiId == diid && x.IsDel == 0)
  20953. .ToArray();
  20954. var count = 1;
  20955. foreach (var item in blackCodeList)
  20956. {
  20957. if (string.IsNullOrWhiteSpace(item.Title))
  20958. {
  20959. item.Title = "未设置名称数据" + count;
  20960. }
  20961. count++;
  20962. }
  20963. ;
  20964. if (group == null)
  20965. {
  20966. jw.Msg = "暂无团组!";
  20967. return Ok(jw);
  20968. }
  20969. var data = new
  20970. {
  20971. groupList = groupList.Select(x => new
  20972. {
  20973. x.TeamName,
  20974. x.Id
  20975. }),
  20976. content = new ArrayList(),
  20977. groupInfo = new
  20978. {
  20979. group.VisitDays,
  20980. group.TourCode,
  20981. group.VisitPNumber,
  20982. group.TeamName,
  20983. group.Id,
  20984. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20985. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  20986. group.ClientUnit
  20987. },
  20988. blackCodeList = blackCodeList.Select(x => new
  20989. {
  20990. x.Title,
  20991. x.Id
  20992. }),
  20993. FileTempList = new ArrayList()
  20994. {
  20995. new { Index = 1,FileName = "旧模板" },
  20996. new { Index = 2,FileName = "省外办" },
  20997. new { Index = 3,FileName = "市外办" },
  20998. }
  20999. };
  21000. var resultArr = new ArrayList();
  21001. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  21002. #region 默认不生成行程
  21003. //if (content.Count == 0)
  21004. //{
  21005. // var stay = "-";
  21006. // var cityPath = "-";
  21007. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  21008. // .Where(x => x.DiId == diid && x.IsDel == 0)
  21009. // .ToList();
  21010. // //添加城市路径以及住宿地
  21011. // //黑屏代码数据
  21012. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  21013. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21014. // {
  21015. // jw = JsonView(true, "黑屏代码有误!", data);
  21016. // return Ok(jw);
  21017. // }
  21018. // data = data with
  21019. // {
  21020. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  21021. // {
  21022. // x.Title,
  21023. // x.Id,
  21024. // }).ToArray())
  21025. // };
  21026. // foreach (DataRow row in dtBlack.Rows)
  21027. // {
  21028. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21029. // {
  21030. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  21031. // return Ok(jw);
  21032. // }
  21033. // }
  21034. // //黑屏代码获取时间区间
  21035. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21036. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21037. // _sqlSugar.BeginTran();
  21038. // for (int i = 0; i < timeArr.Count; i++)
  21039. // {
  21040. // stay = "-";
  21041. // cityPath = "-";
  21042. // DateTime NewData = DateTime.Parse(timeArr[i]);
  21043. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21044. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21045. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21046. // if (tbSelect.Length > 0)
  21047. // {
  21048. // List<string> threeCodeStr = new List<string>();
  21049. // foreach (var item in tbSelect)
  21050. // {
  21051. // var threeCode = item["Three"].ToString() ?? "";
  21052. // if (threeCode.Length == 6)
  21053. // {
  21054. // var start = threeCode.Substring(0, 3);
  21055. // var end = threeCode.Substring(3, 3);
  21056. // if (threeCodeStr.Count == 0)
  21057. // {
  21058. // threeCodeStr.Add(start);
  21059. // threeCodeStr.Add(end);
  21060. // }
  21061. // else
  21062. // {
  21063. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21064. // {
  21065. // threeCodeStr.Add(end);
  21066. // }
  21067. // else
  21068. // {
  21069. // threeCodeStr.Add(start);
  21070. // threeCodeStr.Add(end);
  21071. // }
  21072. // }
  21073. // }
  21074. // }
  21075. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21076. // var last = threeCodeStr.Last();
  21077. // foreach (var item in threeCodeStr)
  21078. // {
  21079. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21080. // if (item.Equals(last))
  21081. // {
  21082. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21083. // }
  21084. // }
  21085. // cityPath = cityPath.Trim('-');
  21086. // }
  21087. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21088. // appro.Diid = diid ?? -1;
  21089. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21090. // appro.Id = thisId;
  21091. // appro.CreateUserId = dto.UserId;
  21092. // appro.CreateTime = DateTime.Now;
  21093. // content.Add(appro);
  21094. // }
  21095. // _sqlSugar.CommitTran();
  21096. //}
  21097. #endregion
  21098. foreach (var x in content)
  21099. {
  21100. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21101. if (chiList.Count < chiNumber)
  21102. {
  21103. for (int i = chiList.Count; i < chiNumber; i++)
  21104. {
  21105. chiList.Add(new Grp_ApprovalTravelDetails());
  21106. }
  21107. }
  21108. resultArr.Add(new
  21109. {
  21110. x.Id,
  21111. x.Date,
  21112. x.Diid,
  21113. chiList = chiList.Select(x1 => new
  21114. {
  21115. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21116. x1.Details,
  21117. x1.ParentId,
  21118. x1.Id
  21119. })
  21120. });
  21121. }
  21122. data = data with
  21123. {
  21124. content = resultArr,
  21125. };
  21126. jw = JsonView(true, "获取成功!", data);
  21127. return Ok(jw);
  21128. }
  21129. /// <summary>
  21130. /// 报批行程删除
  21131. /// </summary>
  21132. /// <param name="dto"></param>
  21133. /// <returns></returns>
  21134. [HttpPost]
  21135. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21136. {
  21137. var jw = JsonView(false);
  21138. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21139. if (group == null)
  21140. {
  21141. jw.Msg = "团组参数有误!";
  21142. return Ok(jw);
  21143. }
  21144. try
  21145. {
  21146. _sqlSugar.BeginTran();
  21147. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21148. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21149. {
  21150. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21151. DeleteUserId = dto.uesrId,
  21152. IsDel = 1
  21153. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21154. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21155. {
  21156. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21157. DeleteUserId = dto.uesrId,
  21158. IsDel = 1
  21159. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21160. _sqlSugar.CommitTran();
  21161. jw = JsonView(true, "删除成功");
  21162. }
  21163. catch (Exception ex)
  21164. {
  21165. jw = JsonView(false, ex.Message);
  21166. }
  21167. return Ok(jw);
  21168. }
  21169. /// <summary>
  21170. /// 报批行程保存
  21171. /// </summary>
  21172. /// <param name="dto"></param>
  21173. /// <returns></returns>
  21174. [HttpPost]
  21175. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21176. {
  21177. var jw = JsonView(false);
  21178. var Find = dto.Arr.Find(x => x.id == 0);
  21179. if (Find != null)
  21180. {
  21181. jw.Msg = "生成的ID为0!";
  21182. return Ok(jw);
  21183. }
  21184. foreach (var item in dto.Arr)
  21185. {
  21186. foreach (var chi in item.chiList)
  21187. {
  21188. if (chi.parentId == 0)
  21189. {
  21190. chi.parentId = item.id;
  21191. }
  21192. }
  21193. }
  21194. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21195. _sqlSugar.BeginTran();
  21196. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21197. {
  21198. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21199. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21200. {
  21201. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21202. DeleteUserId = dto.UserId,
  21203. IsDel = 1
  21204. }).ExecuteCommand();
  21205. }
  21206. try
  21207. {
  21208. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21209. {
  21210. CreateTime = DateTime.Now,
  21211. CreateUserId = dto.UserId,
  21212. Details = x.details,
  21213. ParentId = x.parentId,
  21214. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21215. Remark = "",
  21216. IsDel = 0
  21217. }).ToList()).ExecuteCommand();
  21218. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21219. {
  21220. Id = x.id,
  21221. Details = x.details,
  21222. ParentId = x.parentId,
  21223. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21224. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21225. {
  21226. Details = x.Details,
  21227. ParentId = x.ParentId,
  21228. Time = x.Time
  21229. }).ExecuteCommand();
  21230. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21231. {
  21232. Id = x.id,
  21233. Date = x.date,
  21234. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21235. {
  21236. Date = x.Date
  21237. }).ExecuteCommand();
  21238. _sqlSugar.CommitTran();
  21239. jw = JsonView(true, "保存成功!");
  21240. }
  21241. catch (Exception ex)
  21242. {
  21243. _sqlSugar.RollbackTran();
  21244. jw = JsonView(false, "保存失败!" + ex.Message);
  21245. }
  21246. return Ok(jw);
  21247. }
  21248. /// <summary>
  21249. /// 报批行程生成
  21250. /// </summary>
  21251. /// <param name="dto"></param>
  21252. /// <returns></returns>
  21253. [HttpPost]
  21254. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21255. {
  21256. var jw = JsonView(false);
  21257. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21258. if (group == null)
  21259. {
  21260. jw.Msg = "暂无该团组!";
  21261. return Ok(jw);
  21262. }
  21263. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21264. //黑屏代码数据
  21265. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21266. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21267. {
  21268. jw.Msg = "黑屏代码有误!";
  21269. return Ok(jw);
  21270. }
  21271. foreach (DataRow row in dtBlack.Rows)
  21272. {
  21273. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21274. {
  21275. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21276. return Ok(jw);
  21277. }
  21278. }
  21279. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21280. var resultArr = new ArrayList();
  21281. //if (officialActivitiesArr.Count == 0)
  21282. //{
  21283. // jw.Msg = "暂无公务出访信息!";
  21284. // return Ok(jw);
  21285. //}
  21286. try
  21287. {
  21288. _sqlSugar.BeginTran();
  21289. DeleteApprovalJourney(new
  21290. Domain.Dtos.Groups.DeleteApprovalJourney
  21291. {
  21292. Diid = dto.Diid,
  21293. uesrId = dto.Userid
  21294. });
  21295. var stay = "-";
  21296. var cityPath = "-";
  21297. var arriveCountry = string.Empty;
  21298. //添加城市路径以及住宿地
  21299. //黑屏代码获取时间区间
  21300. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21301. var empty = "【未收入该三字码!请机票同事录入】";
  21302. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21303. #region 配置公务活动时间
  21304. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21305. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21306. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21307. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21308. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21309. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21310. {
  21311. 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" }),
  21312. 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"}),
  21313. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21314. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21315. };
  21316. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21317. {
  21318. 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" }),
  21319. 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"}),
  21320. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21321. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21322. };
  21323. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21324. {
  21325. 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" }),
  21326. 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"}),
  21327. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21328. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21329. };
  21330. #endregion
  21331. var nextDayNum = 0;
  21332. for (int i = 0; i < timeArr.Count; i++)
  21333. {
  21334. stay = "-";
  21335. cityPath = "-";
  21336. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21337. DateTime NewData = DateTime.Parse(timeArr[i]);
  21338. //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();
  21339. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21340. if (nextDayNum > 0)
  21341. {
  21342. nextDayNum--;
  21343. }
  21344. if (tbSelect.Length > 0)
  21345. {
  21346. List<string> threeCodeStr = new List<string>();
  21347. bool isTrade = false;
  21348. string trip = string.Empty;
  21349. foreach (var item in tbSelect)
  21350. {
  21351. if (nextDayNum == 0)
  21352. {
  21353. nextDayNum = Convert.ToInt32(item["Sign"]);
  21354. }
  21355. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21356. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21357. var takeOffTime = DateTime.Parse(timeArr[i]);
  21358. var fallToTime = DateTime.Parse(timeArr[i]);
  21359. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21360. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21361. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21362. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21363. if (nextDayNum > 0)
  21364. {
  21365. fallToTime = fallToTime.AddDays(nextDayNum);
  21366. }
  21367. trip = string.Empty;
  21368. var start = string.Empty;
  21369. var end = string.Empty;
  21370. var threeCode = item["Three"].ToString() ?? "";
  21371. if (threeCode.Length == 6)
  21372. {
  21373. start = threeCode.Substring(0, 3);
  21374. end = threeCode.Substring(3, 3);
  21375. if (threeCodeStr.Count == 0)
  21376. {
  21377. threeCodeStr.Add(start);
  21378. threeCodeStr.Add(end);
  21379. }
  21380. else
  21381. {
  21382. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21383. {
  21384. threeCodeStr.Add(end);
  21385. }
  21386. else
  21387. {
  21388. threeCodeStr.Add(start);
  21389. threeCodeStr.Add(end);
  21390. }
  21391. }
  21392. }
  21393. //处理机票信息
  21394. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21395. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21396. if (start_Object == null)
  21397. {
  21398. start_Object = new Res_ThreeCode()
  21399. {
  21400. AirPort = empty,
  21401. AirPort_En = empty,
  21402. City = empty,
  21403. Country = empty,
  21404. Four = empty,
  21405. Three = empty,
  21406. };
  21407. }
  21408. if (end_Object == null)
  21409. {
  21410. end_Object = new Res_ThreeCode()
  21411. {
  21412. AirPort = empty,
  21413. AirPort_En = empty,
  21414. City = empty,
  21415. Country = empty,
  21416. Four = empty,
  21417. Three = empty,
  21418. };
  21419. }
  21420. //机型判断
  21421. string airModel = item["AirModel"].ToString();
  21422. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21423. string flightTime = item["FlightTime"].ToString();
  21424. flightTime = ParseBlackTime(flightTime);
  21425. //航班号
  21426. string flightcode = item["Fliagtcode"].ToString();
  21427. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21428. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21429. if (aircompany == null)
  21430. {
  21431. aircompany = new Res_AirCompany
  21432. {
  21433. CnName = hsEmpty,
  21434. EnName = hsEmpty,
  21435. ShortCode = hsEmpty,
  21436. };
  21437. }
  21438. //航班前公务安排
  21439. if (tbSelect.First().Equals(item) && i != 0)
  21440. {
  21441. foreach (var takeoff in takeoffTimes)
  21442. {
  21443. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21444. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21445. {
  21446. foreach (var addTime in takeoff.Item2)
  21447. {
  21448. chiarr.Add(new Grp_ApprovalTravelDetails
  21449. {
  21450. Time = addTime,
  21451. CreateTime = DateTime.Now,
  21452. CreateUserId = dto.Userid,
  21453. ParentId = 0,
  21454. Details = "公务活动"
  21455. });
  21456. }
  21457. break;
  21458. }
  21459. }
  21460. }
  21461. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21462. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21463. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21464. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21465. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21466. if (isTrade)
  21467. {
  21468. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21469. trip += "(转机不出机场)。";
  21470. }
  21471. //else
  21472. //{
  21473. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21474. //}
  21475. chiarr.Add(new Grp_ApprovalTravelDetails
  21476. {
  21477. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21478. CreateTime = DateTime.Now,
  21479. CreateUserId = dto.Userid,
  21480. ParentId = 0,
  21481. Details = trip
  21482. });
  21483. //最后一条到达的时间安排公务
  21484. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21485. {
  21486. bool isCheckCountry = false;
  21487. if (end_Object.Country != arriveCountry)
  21488. {
  21489. arriveCountry = end_Object.Country;
  21490. isCheckCountry = true;
  21491. }
  21492. if (nextDayNum == 0)
  21493. {
  21494. //需要入境的情况
  21495. if (isCheckCountry)
  21496. {
  21497. foreach (var fallTime in fallTimesCheckCountry)
  21498. {
  21499. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21500. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21501. {
  21502. foreach (var addTime in fallTime.Item2)
  21503. {
  21504. chiarr.Add(new Grp_ApprovalTravelDetails
  21505. {
  21506. Time = addTime,
  21507. CreateTime = DateTime.Now,
  21508. CreateUserId = dto.Userid,
  21509. ParentId = 0,
  21510. Details = "公务活动"
  21511. });
  21512. }
  21513. break;
  21514. }
  21515. }
  21516. }
  21517. else
  21518. {
  21519. foreach (var fallTime in fallTimesNotCheckCountry)
  21520. {
  21521. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21522. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21523. {
  21524. foreach (var addTime in fallTime.Item2)
  21525. {
  21526. chiarr.Add(new Grp_ApprovalTravelDetails
  21527. {
  21528. Time = addTime,
  21529. CreateTime = DateTime.Now,
  21530. CreateUserId = dto.Userid,
  21531. ParentId = 0,
  21532. Details = "公务活动"
  21533. });
  21534. }
  21535. break;
  21536. }
  21537. }
  21538. }
  21539. }
  21540. }
  21541. }
  21542. //添加乘车语句
  21543. //chiarr.Add(new Grp_ApprovalTravelDetails
  21544. //{
  21545. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21546. // CreateTime = DateTime.Now,
  21547. // CreateUserId = dto.Userid,
  21548. // ParentId = 0,
  21549. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21550. //});
  21551. //if (i != timeArr.Count - 1)
  21552. //{
  21553. // fallToTime = fallToTime.AddHours(2.5);
  21554. // foreach (var item in Times)
  21555. // {
  21556. // //排列公务时间
  21557. // if (fallToTime.Hour < item.Item1)
  21558. // {
  21559. // chiarr.Add(new Grp_ApprovalTravelDetails
  21560. // {
  21561. // Time = $"{item.Item2} - {item.Item3}",
  21562. // CreateTime = DateTime.Now,
  21563. // CreateUserId = dto.Userid,
  21564. // ParentId = 0,
  21565. // Details = "公务活动"
  21566. // });
  21567. // }
  21568. // }
  21569. //}
  21570. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21571. var last = threeCodeStr.Last();
  21572. foreach (var item in threeCodeStr)
  21573. {
  21574. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21575. if (item.Equals(last))
  21576. {
  21577. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21578. }
  21579. }
  21580. cityPath = cityPath.Trim('-');
  21581. }
  21582. else
  21583. {
  21584. foreach (var item in Times)
  21585. {
  21586. chiarr.Add(new Grp_ApprovalTravelDetails
  21587. {
  21588. Time = $"{item.Item2} - {item.Item3}",
  21589. CreateTime = DateTime.Now,
  21590. CreateUserId = dto.Userid,
  21591. ParentId = 0,
  21592. Details = "公务活动"
  21593. });
  21594. }
  21595. }
  21596. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21597. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21598. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21599. appro.Diid = dto.Diid;
  21600. appro.CreateUserId = dto.Userid;
  21601. appro.CreateTime = DateTime.Now;
  21602. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21603. appro.Id = thisId;
  21604. //foreach (var item in gwinfo)
  21605. //{
  21606. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21607. // chi.Details = "拜访" + item.Client;
  21608. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21609. // {
  21610. // chi.Details += "," + item.ReqSample;
  21611. // }
  21612. // chi.ParentId = thisId;
  21613. // chi.Time = item.Time;
  21614. // chiarr.Add(chi);
  21615. //}
  21616. if (chiarr.Count < 6)
  21617. {
  21618. for (int j = chiarr.Count; j < 6; j++)
  21619. {
  21620. chiarr.Add(new
  21621. Grp_ApprovalTravelDetails());
  21622. }
  21623. }
  21624. resultArr.Add(new
  21625. {
  21626. appro.Id,
  21627. appro.Date,
  21628. appro.Diid,
  21629. chiList = chiarr.Select(x1 => new
  21630. {
  21631. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21632. x1.Details,
  21633. x1.ParentId,
  21634. x1.Id
  21635. })
  21636. });
  21637. }
  21638. _sqlSugar.CommitTran();
  21639. jw = JsonView(true, "生成成功!", resultArr);
  21640. }
  21641. catch (Exception ex)
  21642. {
  21643. jw.Code = 400;
  21644. jw.Msg = "生成失败!" + ex.Message;
  21645. }
  21646. return Ok(jw);
  21647. }
  21648. /// <summary>
  21649. /// 报批行程word导出
  21650. /// </summary>
  21651. /// <param name="dto"></param>
  21652. /// <returns></returns>
  21653. [HttpPost]
  21654. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21655. {
  21656. var jw = JsonView(false);
  21657. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21658. if (group == null)
  21659. {
  21660. jw.Msg = "暂无该团组!";
  21661. return Ok(jw);
  21662. }
  21663. //模板路径
  21664. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21665. var fileName = string.Empty;
  21666. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21667. bool bold = false;
  21668. if (dto.FileIndex == 1)
  21669. {
  21670. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21671. }
  21672. else if (dto.FileIndex == 2)
  21673. {
  21674. fileName = "省外办-报批.docx";
  21675. bold = false;
  21676. titleFont = "方正黑体简体";
  21677. timeFont = "Times New Roman";
  21678. contentFont = "方正仿宋_GBK";
  21679. }
  21680. else if (dto.FileIndex == 3)
  21681. {
  21682. fileName = "市外办-报批.docx";
  21683. titleFont = "方正黑体简体";
  21684. timeFont = "Times New Roman";
  21685. contentFont = "方正仿宋简体";
  21686. }
  21687. tempPath = tempPath + fileName;
  21688. //载入模板
  21689. Document doc = new Document(tempPath);
  21690. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21691. //获取所填表格的序数
  21692. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21693. Aspose.Words.Tables.Row titleRowClone = null;
  21694. Aspose.Words.Tables.Row CenterRowClone = null;
  21695. int index = 0;
  21696. int indexChi = 0;
  21697. int SetIndex = 0;
  21698. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21699. //获取数据,放到datatable
  21700. foreach (var item in ApprovalTravelArr)
  21701. {
  21702. if (index > 0)
  21703. {
  21704. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21705. tableOne.AppendChild(titleRowClone);
  21706. }
  21707. var textTime = item.Date;
  21708. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21709. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21710. SetIndex++;
  21711. if (ChiRep.Count > 0)
  21712. {
  21713. foreach (var itemChi in ChiRep)
  21714. {
  21715. var txtTime = itemChi.Time;
  21716. var txtDetail = itemChi.Details;
  21717. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21718. {
  21719. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21720. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21721. //indexChi++;
  21722. //SetIndex++;
  21723. break;
  21724. }
  21725. if (indexChi > 0)
  21726. {
  21727. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21728. tableOne.AppendChild(CenterRowClone);
  21729. }
  21730. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21731. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21732. indexChi++;
  21733. SetIndex++;
  21734. }
  21735. }
  21736. //else
  21737. //{
  21738. // if (indexChi > 0)
  21739. // {
  21740. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21741. // tableOne.AppendChild(CenterRowClone);
  21742. // }
  21743. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21744. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21745. // indexChi++;
  21746. // SetIndex++;
  21747. //}
  21748. index++;
  21749. }
  21750. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21751. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21752. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21753. jw.Code = 200;
  21754. jw.Msg = "";
  21755. return Ok(jw);
  21756. }
  21757. private string ParseBlackTime(string time)
  21758. {
  21759. // 匹配可能只有分钟的情况
  21760. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21761. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21762. if (match.Success)
  21763. {
  21764. string hours = match.Groups[1].Value;
  21765. string minutes = match.Groups[2].Value;
  21766. // 如果小时部分为空,则只显示分钟
  21767. if (string.IsNullOrEmpty(hours))
  21768. {
  21769. return $"{minutes}分钟";
  21770. }
  21771. // 如果分钟部分为空,则只显示小时
  21772. else if (string.IsNullOrEmpty(minutes))
  21773. {
  21774. return $"{hours}小时";
  21775. }
  21776. // 否则显示完整格式
  21777. else
  21778. {
  21779. return $"{hours}小时{minutes}分钟";
  21780. }
  21781. }
  21782. else
  21783. {
  21784. return "未知时长";
  21785. }
  21786. }
  21787. private string intToString(int numberVal)
  21788. {
  21789. string numberval = numberVal.ToString();
  21790. Dictionary<char, string> Number = new Dictionary<char, string>();
  21791. Number.Add('1', "一");
  21792. Number.Add('2', "二");
  21793. Number.Add('3', "三");
  21794. Number.Add('4', "四");
  21795. Number.Add('5', "五");
  21796. Number.Add('6', "六");
  21797. Number.Add('7', "七");
  21798. Number.Add('8', "八");
  21799. Number.Add('9', "九");
  21800. string stringNumberVal = string.Empty;
  21801. for (int i = 0; i < numberval.Length; i++)
  21802. {
  21803. if (i == 0)
  21804. {
  21805. stringNumberVal += Number[numberval[i]];
  21806. }
  21807. else if (i >= 1)
  21808. {
  21809. if (numberval[i] == '0')
  21810. {
  21811. stringNumberVal = "十";
  21812. }
  21813. else
  21814. {
  21815. stringNumberVal += "十" + Number[numberval[i]];
  21816. }
  21817. }
  21818. }
  21819. return stringNumberVal;
  21820. }
  21821. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21822. {
  21823. //获取table中的某个单元格,从0开始
  21824. Cell lshCell = table.Rows[rows].Cells[cells];
  21825. //将单元格中段落移除
  21826. foreach (Paragraph item in lshCell.Paragraphs)
  21827. {
  21828. lshCell.Paragraphs.Remove(item);
  21829. }
  21830. if (val.Contains("\r\n"))
  21831. {
  21832. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21833. foreach (var item in spArr)
  21834. {
  21835. //新建一个段落
  21836. Paragraph p = new Paragraph(doc);
  21837. var r = new Run(doc, item);
  21838. //设置字体
  21839. if (!string.IsNullOrEmpty(font))
  21840. {
  21841. r.Font.Name = font;
  21842. }
  21843. r.Font.Bold = bold;
  21844. //把设置的值赋给之前新建的段落
  21845. p.AppendChild(r);
  21846. //将此段落加到单元格内
  21847. lshCell.AppendChild(p);
  21848. }
  21849. }
  21850. else
  21851. {
  21852. //新建一个段落
  21853. Paragraph p = new Paragraph(doc);
  21854. var r = new Run(doc, val);
  21855. //设置字体
  21856. if (!string.IsNullOrEmpty(font))
  21857. {
  21858. r.Font.Name = font;
  21859. }
  21860. r.Font.Bold = bold;
  21861. //把设置的值赋给之前新建的段落
  21862. p.AppendChild(r);
  21863. //将此段落加到单元格内
  21864. lshCell.AppendChild(p);
  21865. }
  21866. }
  21867. /// <summary>
  21868. /// 报批行程AI续写
  21869. /// </summary>
  21870. /// <returns></returns>
  21871. [HttpPost]
  21872. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21873. {
  21874. var jw = JsonView(false);
  21875. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21876. {
  21877. jw.Msg = "参数有误!";
  21878. return Ok(jw);
  21879. }
  21880. KiMiApiClient kiMi = new KiMiApiClient();
  21881. List<SeedMessages> messages = new List<SeedMessages>() {
  21882. new SeedMessages
  21883. {
  21884. Role = KimiRole.system,
  21885. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21886. },
  21887. new SeedMessages
  21888. {
  21889. Role = KimiRole.user,
  21890. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  21891. }
  21892. };
  21893. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  21894. string data = kimi_result.Choices[0]?.Message.Content;
  21895. if (string.IsNullOrWhiteSpace(data))
  21896. {
  21897. jw.Data = "Ai续写失败!";
  21898. }
  21899. else
  21900. {
  21901. jw = JsonView(true, "success!", data);
  21902. }
  21903. return Ok(jw);
  21904. }
  21905. #endregion
  21906. #region 团组接待意见调查
  21907. /// <summary>
  21908. /// 团组接待意见调查 - 信息管理
  21909. /// 基础数据(团组)
  21910. /// </summary>
  21911. /// <returns></returns>
  21912. [HttpGet]
  21913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21914. public async Task<IActionResult> OpinionaireInit()
  21915. {
  21916. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21917. .Select(x => new
  21918. {
  21919. x.Id,
  21920. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21921. })
  21922. .OrderByDescending(x => x.Id)
  21923. .ToListAsync();
  21924. return Ok(JsonView(groupData, groupData.Count));
  21925. }
  21926. /// <summary>
  21927. /// 团组接待意见调查 - 信息管理
  21928. /// 列表
  21929. /// </summary>
  21930. /// <param name="groupId"></param>
  21931. /// <returns></returns>
  21932. [HttpGet("{groupId}")]
  21933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21934. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21935. {
  21936. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21937. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21938. .Select(x => new
  21939. {
  21940. x.Id,
  21941. x.TourGuideName,
  21942. x.CityName,
  21943. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21944. x.CreateTime
  21945. })
  21946. .OrderBy(x => x.Id)
  21947. .ToListAsync();
  21948. return Ok(JsonView(data));
  21949. }
  21950. /// <summary>
  21951. /// 团组接待意见调查 - 信息管理
  21952. /// 保存
  21953. /// </summary>
  21954. /// <param name="dto"></param>
  21955. /// <returns></returns>
  21956. [HttpPost]
  21957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21958. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21959. {
  21960. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21961. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21962. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21963. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21964. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21965. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21966. _opinionaireRep.BeginTran();
  21967. if (addData != null && addData.Count > 0)
  21968. {
  21969. foreach (var item in addData)
  21970. {
  21971. item.CreateUserId = currUserInfo.UserId;
  21972. item.DiId = dto.DiId;
  21973. }
  21974. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21975. }
  21976. if (updData != null && updData.Count > 0)
  21977. {
  21978. var upd = await _opinionaireRep._sqlSugar
  21979. .Updateable(updData)
  21980. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21981. .WhereColumns(x => new { x.Id })
  21982. .ExecuteCommandAsync();
  21983. }
  21984. _opinionaireRep.CommitTran();
  21985. return Ok(JsonView("操作成功!"));
  21986. }
  21987. /// <summary>
  21988. /// 团组接待意见调查 - 信息管理
  21989. /// 删除
  21990. /// </summary>
  21991. /// <param name="id"></param>
  21992. /// <returns></returns>
  21993. [HttpDelete("{id}")]
  21994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21995. public async Task<IActionResult> OpinionaireManageDel(int id)
  21996. {
  21997. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21998. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21999. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  22000. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  22001. if (!del) return Ok(JsonView("操作失败!"));
  22002. return Ok(JsonView("操作成功!"));
  22003. }
  22004. /// <summary>
  22005. /// 团组接待意见调查 - 用户
  22006. /// 列表
  22007. /// </summary>
  22008. /// <param name="diId"></param>
  22009. /// <returns></returns>
  22010. [HttpGet("{diId}")]
  22011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22012. public async Task<IActionResult> OpinionaireUserList(int diId)
  22013. {
  22014. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  22015. var sql = string.Format(@"
  22016. SELECT
  22017. o.Id,
  22018. o.DiId,
  22019. di.TeamName AS 'GroupName',
  22020. di.VisitPNumber AS 'PeopleNumber',
  22021. di.ClientName AS 'LeadGroup',
  22022. di.VisitCountry AS 'Travel',
  22023. di.VisitDays AS 'Days',
  22024. o.CityName,
  22025. o.TourGuideName,
  22026. o.Catering,
  22027. o.CateringReason,
  22028. o.Stay,
  22029. o.StayReason,
  22030. o.[Route],
  22031. o.RouteReason,
  22032. o.OfficialActivity,
  22033. o.OfficialActivityReason,
  22034. o.TourGuide,
  22035. o.TourGuideReason,
  22036. o.[Translate],
  22037. o.TranslateReason,
  22038. o.Trip,
  22039. o.TripReason,
  22040. o.ESFileName,
  22041. o.SignatureDate,
  22042. o.Remark
  22043. FROM
  22044. Grp_Opinionaire o
  22045. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  22046. WHERE
  22047. o.IsDel = 0
  22048. AND o.DiId = {0}
  22049. ORDER BY
  22050. o.Id ASC", diId);
  22051. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  22052. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  22053. return Ok(JsonView(data));
  22054. }
  22055. /// <summary>
  22056. /// 团组接待意见调查 - 用户
  22057. /// 保存
  22058. /// </summary>
  22059. /// <param name="dto"></param>
  22060. /// <returns></returns>
  22061. [HttpPost]
  22062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22063. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  22064. {
  22065. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  22066. foreach (var item in dto)
  22067. {
  22068. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  22069. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  22070. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  22071. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  22072. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  22073. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  22074. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  22075. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  22076. }
  22077. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  22078. if (!Directory.Exists(filePathBase))
  22079. {
  22080. Directory.CreateDirectory(filePathBase);
  22081. }
  22082. #region 上传文件
  22083. var filePaths = new List<string>();
  22084. foreach (var item in dto)
  22085. {
  22086. var file = item.File;
  22087. // 将文件保存到指定位置
  22088. var filePath = Path.Combine(filePathBase, file.FileName);
  22089. using (var stream = new FileStream(filePath, FileMode.Create))
  22090. {
  22091. await file.CopyToAsync(stream);
  22092. }
  22093. //验证文件是否上传成功
  22094. if (!System.IO.File.Exists(filePath))
  22095. {
  22096. foreach (var filePathStr in filePaths)
  22097. {
  22098. System.IO.File.Delete(filePathStr);
  22099. }
  22100. return Ok(JsonView(false, "文件上传失败!"));
  22101. }
  22102. item.ESFileName = file.FileName;
  22103. }
  22104. #endregion
  22105. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22106. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22107. .UpdateColumns(x => new
  22108. {
  22109. x.Catering,
  22110. x.CateringReason,
  22111. x.Stay,
  22112. x.StayReason,
  22113. x.Route,
  22114. x.RouteReason,
  22115. x.OfficialActivity,
  22116. x.OfficialActivityReason,
  22117. x.TourGuide,
  22118. x.TourGuideReason,
  22119. x.Translate,
  22120. x.TranslateReason,
  22121. x.Trip,
  22122. x.TripReason,
  22123. x.ESFileName,
  22124. x.SignatureDate,
  22125. x.Remark
  22126. })
  22127. .WhereColumns(x => new { x.Id })
  22128. .ExecuteCommandAsync();
  22129. if (upd < 1)
  22130. {
  22131. foreach (var filePathStr in filePaths)
  22132. {
  22133. System.IO.File.Delete(filePathStr);
  22134. }
  22135. return Ok(JsonView(false));
  22136. }
  22137. return Ok(JsonView(true));
  22138. }
  22139. #endregion
  22140. #region 团组餐厅相关信息
  22141. /// <summary>
  22142. /// 团组相关餐厅信息
  22143. /// 基础数据(团组)
  22144. /// </summary>
  22145. /// <returns></returns>
  22146. [HttpGet]
  22147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22148. public async Task<IActionResult> RestaurantInit()
  22149. {
  22150. return Ok(await _restaurantRep.InitAsync());
  22151. }
  22152. /// <summary>
  22153. /// 团组相关餐厅信息
  22154. /// Item
  22155. /// </summary>
  22156. /// <param name="dto"></param>
  22157. /// <returns></returns>
  22158. [HttpPost]
  22159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22160. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22161. {
  22162. int portType = dto.PortType,
  22163. groupId = dto.GroupId;
  22164. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22165. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22166. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22167. }
  22168. /// <summary>
  22169. /// 团组相关餐厅信息
  22170. /// List
  22171. /// </summary>
  22172. /// <param name="dto"></param>
  22173. /// <returns></returns>
  22174. [HttpPost]
  22175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22176. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22177. {
  22178. int portType = dto.PortType,
  22179. groupId = dto.GroupId;
  22180. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22181. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22182. var sql = string.Format(@" SELECT
  22183. ri.Id,
  22184. ri.GroupId,
  22185. ri.Date,
  22186. ri.StartTime,
  22187. ri.EndTime,
  22188. CASE WHEN ri.Type = 1 THEN '早餐'
  22189. WHEN ri.Type = 2 THEN '午餐'
  22190. WHEN ri.Type = 3 THEN '晚餐'
  22191. ELSE '其他'
  22192. END AS 'Type',
  22193. ri.Name,
  22194. ri.Address,
  22195. ri.Tel,
  22196. ri.Remark,
  22197. ri.CreateTime,
  22198. u.CnName AS CreateUserName
  22199. FROM
  22200. Grp_RestaurantInfo ri
  22201. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22202. WHERE
  22203. ri.IsDel = 0
  22204. AND ri.GroupId = {0}
  22205. ORDER BY
  22206. ri.Date ASC
  22207. ", groupId);
  22208. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22209. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22210. return Ok(JsonView(infos));
  22211. }
  22212. /// <summary>
  22213. /// 团组相关餐厅信息
  22214. /// Info
  22215. /// </summary>
  22216. /// <param name="dto"></param>
  22217. /// <returns></returns>
  22218. [HttpPost]
  22219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22220. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22221. {
  22222. int portType = dto.PortType,
  22223. id = dto.Id;
  22224. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22225. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22226. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22227. }
  22228. /// <summary>
  22229. /// 团组相关餐厅信息
  22230. /// Op
  22231. /// </summary>
  22232. /// <param name="dto"></param>
  22233. /// <returns></returns>
  22234. [HttpPost]
  22235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22236. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22237. {
  22238. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22239. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22240. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22241. return Ok(await _restaurantRep.OpAsync(dto));
  22242. }
  22243. /// <summary>
  22244. /// 团组相关餐厅信息
  22245. /// Del
  22246. /// </summary>
  22247. /// <param name="dto"></param>
  22248. /// <returns></returns>
  22249. [HttpPost]
  22250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22251. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22252. {
  22253. int userId = dto.DeleteUserId;
  22254. var id = dto.Id;
  22255. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22256. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22257. return Ok(await _restaurantRep.DelAsync(dto));
  22258. }
  22259. #endregion
  22260. /// <summary>
  22261. /// 123132123
  22262. /// </summary>
  22263. /// <param name="_dto"></param>
  22264. /// <returns></returns>
  22265. [HttpPost]
  22266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22267. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22268. {
  22269. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22270. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22271. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22272. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22273. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22274. dicDetail.Add(789, 1034);
  22275. dicDetail.Add(790, 1035);
  22276. dicDetail.Add(791, 1036);
  22277. dicDetail.Add(792, 1037);
  22278. dicDetail.Add(793, 1038);
  22279. dicDetail.Add(794, 1039);
  22280. dicDetail.Add(795, 1040);
  22281. dicDetail.Add(796, 1041);
  22282. dicDetail.Add(797, 1042);
  22283. dicDetail.Add(798, 1043);
  22284. dicDetail.Add(801, 1044);
  22285. dicDetail.Add(802, 1045);
  22286. dicDetail.Add(803, 1046);
  22287. Dictionary<int, int> dic = new Dictionary<int, int>();
  22288. dic.Add(806, 1027);
  22289. dic.Add(807, 1028);
  22290. dic.Add(808, 1029);
  22291. dic.Add(809, 1030);
  22292. dic.Add(810, 1031);
  22293. dic.Add(811, 1032);
  22294. dic.Add(812, 1033);
  22295. foreach (var item in list_visa)
  22296. {
  22297. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22298. temp.Coefficient = item.coefficient;
  22299. DateTime dtCrt;
  22300. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22301. if (b1)
  22302. {
  22303. temp.CreateTime = dtCrt;
  22304. }
  22305. else
  22306. {
  22307. temp.CreateTime = DateTime.Now;
  22308. }
  22309. temp.CreateUserId = item.Operators;
  22310. temp.DeleteTime = "";
  22311. temp.DeleteUserId = 0;
  22312. temp.DiId = int.Parse(item.DIID);
  22313. temp.FilePath = item.FilePath;
  22314. temp.IsDel = item.IsDel;
  22315. temp.Price = item.Price;
  22316. temp.PriceCount = 1;
  22317. temp.PriceCurrency = item.Currency;
  22318. int detailId = 0;
  22319. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22320. {
  22321. detailId = dicDetail[item.PriceTypeDetail];
  22322. }
  22323. temp.PriceDetailType = detailId;
  22324. temp.PriceDt = DateTime.Now;
  22325. temp.PriceName = item.PriceName;
  22326. temp.PriceSum = item.Price;
  22327. int tid = 0;
  22328. if (dic.ContainsKey(item.PriceType))
  22329. {
  22330. tid = dic[item.PriceType];
  22331. }
  22332. temp.PriceType = tid;
  22333. temp.Remark = item.Remark;
  22334. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22335. }
  22336. return Ok(JsonView(true, "操作成功!"));
  22337. }
  22338. [HttpPost]
  22339. public IActionResult TimeTest()
  22340. {
  22341. var jw = JsonView(false, "error");
  22342. _sqlSugar.BeginTran();
  22343. try
  22344. {
  22345. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22346. .Select(x => new Crm_NewClientData
  22347. {
  22348. Id = x.Id,
  22349. Client = x.Client,
  22350. Contact = x.Contact,
  22351. Location = x.Location,
  22352. })
  22353. .ToList();
  22354. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22355. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22356. Stopwatch stopwatch = new Stopwatch();
  22357. // 开始计时
  22358. stopwatch.Start();
  22359. foreach (var item in clientList)
  22360. {
  22361. EncryptionProcessor.DecryptProperties(item);
  22362. }
  22363. stopwatch.Stop();
  22364. jw.Code = 200;
  22365. jw.Data = stopwatch.ElapsedMilliseconds;
  22366. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22367. }
  22368. catch (Exception ex)
  22369. {
  22370. jw.Code = 400;
  22371. jw.Msg = ex.Message;
  22372. }
  22373. return Ok(jw);
  22374. }
  22375. }
  22376. }