GroupsController.cs 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using Microsoft.AspNetCore.SignalR;
  11. using Microsoft.EntityFrameworkCore.Metadata.Internal;
  12. using Microsoft.IdentityModel.Tokens;
  13. using Microsoft.VisualBasic;
  14. using MySqlX.XDevAPI.Relational;
  15. using NetTaste;
  16. using NPOI.HSSF.UserModel;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.KiMiApi;
  29. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  30. using OASystem.Domain.AesEncryption;
  31. using OASystem.Domain.Attributes;
  32. using OASystem.Domain.Dtos.CRM;
  33. using OASystem.Domain.Dtos.FileDto;
  34. using OASystem.Domain.Dtos.Financial;
  35. using OASystem.Domain.Dtos.Groups;
  36. using OASystem.Domain.Entities.Customer;
  37. using OASystem.Domain.Entities.Financial;
  38. using OASystem.Domain.Entities.Groups;
  39. using OASystem.Domain.ViewModels.Financial;
  40. using OASystem.Domain.ViewModels.Groups;
  41. using OASystem.Domain.ViewModels.OCR;
  42. using OASystem.Domain.ViewModels.QiYeWeChat;
  43. using OASystem.Domain.ViewModels.Statistics;
  44. using OASystem.Infrastructure.Repositories.CRM;
  45. using OASystem.Infrastructure.Repositories.Financial;
  46. using OASystem.Infrastructure.Repositories.Groups;
  47. using OASystem.Infrastructure.Tools;
  48. using OASystem.RedisRepository;
  49. using Org.BouncyCastle.Crypto;
  50. using Org.BouncyCastle.Utilities;
  51. using Quartz.Util;
  52. using SqlSugar.Extensions;
  53. using System.Collections;
  54. using System.Data;
  55. using System.Diagnostics;
  56. using System.Drawing.Printing;
  57. using System.Globalization;
  58. using System.IO;
  59. using System.IO.Compression;
  60. using System.Reflection;
  61. using System.Text.Json;
  62. using System.Web;
  63. using System.Xml.Linq;
  64. using TencentCloud.Ocr.V20181119.Models;
  65. using static OASystem.API.OAMethodLib.JWTHelper;
  66. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  67. using Bookmark = Aspose.Words.Bookmark;
  68. using Cell = Aspose.Words.Tables.Cell;
  69. using Table = Aspose.Words.Tables.Table;
  70. namespace OASystem.API.Controllers
  71. {
  72. /// <summary>
  73. /// 团组相关
  74. /// </summary>
  75. //[Authorize]
  76. [Route("api/[controller]/[action]")]
  77. public class GroupsController : ControllerBase
  78. {
  79. private readonly ILogger<GroupsController> _logger;
  80. private readonly GrpScheduleRepository _grpScheduleRep;
  81. private readonly IMapper _mapper;
  82. private readonly DelegationInfoRepository _groupRepository;
  83. private readonly TaskAssignmentRepository _taskAssignmentRep;
  84. private readonly AirTicketResRepository _airTicketResRep;
  85. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  86. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  87. private readonly DelegationEnDataRepository _delegationEnDataRep;
  88. private readonly DelegationVisaRepository _delegationVisaRep;
  89. private readonly VisaPriceRepository _visaPriceRep;
  90. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  91. private readonly HotelPriceRepository _hotelPriceRep;
  92. private readonly CustomersRepository _customersRep;
  93. private readonly MessageRepository _message;
  94. private readonly SqlSugarClient _sqlSugar;
  95. private readonly TourClientListRepository _tourClientListRep;
  96. private readonly TeamRateRepository _teamRateRep;
  97. #region 成本相关
  98. private readonly CheckBoxsRepository _checkBoxs;
  99. private readonly GroupCostRepository _GroupCostRepository;
  100. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  101. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  102. #endregion
  103. private readonly SetDataRepository _setDataRep;
  104. private string url;
  105. private string path;
  106. private readonly EnterExitCostRepository _enterExitCostRep;
  107. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  108. private readonly UsersRepository _usersRep;
  109. private readonly IJuHeApiService _juHeApi;
  110. private readonly InvertedListRepository _invertedListRep;
  111. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  112. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  113. private readonly ThreeCodeRepository _threeCodeRepository;
  114. private readonly HotelInquiryRepository _hotelInquiryRep;
  115. private readonly FeeAuditRepository _feeAuditRep;
  116. private readonly VisaCommissionRepository _visaCommissionRep;
  117. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  118. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  119. private readonly List<CurrencyInfo> _currencyInit;
  120. private readonly List<int> _portTypeData;
  121. private readonly TableOperationRecordRepository _tableorRep;
  122. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  123. private readonly RestaurantRepository _restaurantRep;
  124. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  125. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  126. /// <summary>
  127. /// 构造函数
  128. /// </summary>
  129. /// <param name="logger"></param>
  130. /// <param name="mapper"></param>
  131. /// <param name="hubContext"></param>
  132. /// <param name="sqlSugar"></param>
  133. /// <param name="grpScheduleRep"></param>
  134. /// <param name="groupRepository"></param>
  135. /// <param name="taskAssignmentRep"></param>
  136. /// <param name="airTicketResRep"></param>
  137. /// <param name="decreasePaymentsRep"></param>
  138. /// <param name="InvitationOfficialActivitiesRep"></param>
  139. /// <param name="delegationEnDataRep"></param>
  140. /// <param name="enterExitCostRep"></param>
  141. /// <param name="delegationVisaRep"></param>
  142. /// <param name="message"></param>
  143. /// <param name="visaPriceRep"></param>
  144. /// <param name="carTouristGuideGroundRep"></param>
  145. /// <param name="checkBoxs"></param>
  146. /// <param name="GroupCostRepository"></param>
  147. /// <param name="CostTypeHotelNumberRepository"></param>
  148. /// <param name="GroupCostParameterRepository"></param>
  149. /// <param name="hotelPriceRep"></param>
  150. /// <param name="customersRep"></param>
  151. /// <param name="setDataRep"></param>
  152. /// <param name="tourClientListRep"></param>
  153. /// <param name="teamRateRep"></param>
  154. /// <param name="usersRep"></param>
  155. /// <param name="juHeApi"></param>
  156. /// <param name="invertedListRep"></param>
  157. /// <param name="visaFeeInfoRep"></param>
  158. /// <param name="ticketBlackCodeRep"></param>
  159. /// <param name="hotelInquiryRep"></param>
  160. /// <param name="threeCodeRepository"></param>
  161. /// <param name="feeAuditRep"></param>
  162. /// <param name="visaCommissionRep"></param>
  163. /// <param name="ffrRep"></param>
  164. /// <param name="opinionaireRep"></param>
  165. /// <param name="tableorRep"></param>
  166. /// <param name="enterExitCostDraftRep"></param>
  167. /// <param name="restaurantRep"></param>
  168. /// <param name="enterExitCostQuoteRep"></param>
  169. /// <param name="grpOrderPreInfoRep"></param>
  170. public GroupsController(
  171. ILogger<GroupsController> logger,
  172. IMapper mapper,
  173. IHubContext<ChatHub, IChatClient> hubContext,
  174. SqlSugarClient sqlSugar,
  175. GrpScheduleRepository grpScheduleRep,
  176. DelegationInfoRepository groupRepository,
  177. TaskAssignmentRepository taskAssignmentRep,
  178. AirTicketResRepository airTicketResRep,
  179. DecreasePaymentsRepository decreasePaymentsRep,
  180. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  181. DelegationEnDataRepository delegationEnDataRep,
  182. EnterExitCostRepository enterExitCostRep,
  183. DelegationVisaRepository delegationVisaRep,
  184. MessageRepository message,
  185. VisaPriceRepository visaPriceRep,
  186. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  187. CheckBoxsRepository checkBoxs,
  188. GroupCostRepository GroupCostRepository,
  189. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  190. GroupCostParameterRepository GroupCostParameterRepository,
  191. HotelPriceRepository hotelPriceRep,
  192. CustomersRepository customersRep,
  193. SetDataRepository setDataRep,
  194. TourClientListRepository tourClientListRep,
  195. TeamRateRepository teamRateRep,
  196. UsersRepository usersRep,
  197. IJuHeApiService juHeApi,
  198. InvertedListRepository invertedListRep,
  199. VisaFeeInfoRepository visaFeeInfoRep,
  200. TicketBlackCodeRepository ticketBlackCodeRep,
  201. HotelInquiryRepository hotelInquiryRep,
  202. ThreeCodeRepository threeCodeRepository,
  203. FeeAuditRepository feeAuditRep,
  204. VisaCommissionRepository visaCommissionRep,
  205. ForeignReceivablesRepository ffrRep,
  206. OpinionaireRepository opinionaireRep,
  207. TableOperationRecordRepository tableorRep,
  208. EnterExitCostDraftRepository enterExitCostDraftRep,
  209. RestaurantRepository restaurantRep,
  210. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  211. GroupOrderPreInfoRepository grpOrderPreInfoRep
  212. )
  213. {
  214. _logger = logger;
  215. _mapper = mapper;
  216. _grpScheduleRep = grpScheduleRep;
  217. _groupRepository = groupRepository;
  218. _taskAssignmentRep = taskAssignmentRep;
  219. _airTicketResRep = airTicketResRep;
  220. _sqlSugar = sqlSugar;
  221. url = AppSettingsHelper.Get("ExcelBaseUrl");
  222. path = AppSettingsHelper.Get("ExcelBasePath");
  223. if (!System.IO.Directory.Exists(path))
  224. {
  225. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  226. }
  227. _decreasePaymentsRep = decreasePaymentsRep;
  228. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  229. _delegationEnDataRep = delegationEnDataRep;
  230. _enterExitCostRep = enterExitCostRep;
  231. _delegationVisaRep = delegationVisaRep;
  232. _message = message;
  233. _visaPriceRep = visaPriceRep;
  234. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  235. _checkBoxs = checkBoxs;
  236. _GroupCostRepository = GroupCostRepository;
  237. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  238. _GroupCostParameterRepository = GroupCostParameterRepository;
  239. _hotelPriceRep = hotelPriceRep;
  240. _customersRep = customersRep;
  241. _setDataRep = setDataRep;
  242. _tourClientListRep = tourClientListRep;
  243. _teamRateRep = teamRateRep;
  244. _hubContext = hubContext;
  245. _usersRep = usersRep;
  246. _juHeApi = juHeApi;
  247. _invertedListRep = invertedListRep;
  248. _visaFeeInfoRep = visaFeeInfoRep;
  249. _ticketBlackCodeRep = ticketBlackCodeRep;
  250. _hotelInquiryRep = hotelInquiryRep;
  251. _threeCodeRepository = threeCodeRepository;
  252. _feeAuditRep = feeAuditRep;
  253. _visaCommissionRep = visaCommissionRep;
  254. _ffrRep = ffrRep;
  255. _opinionaireRep = opinionaireRep;
  256. _currencyInit = new List<CurrencyInfo>()
  257. {
  258. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  259. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  260. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  261. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  262. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  263. };
  264. _portTypeData = new List<int>() { 2, 3 };
  265. _tableorRep = tableorRep;
  266. _enterExitCostDraftRep = enterExitCostDraftRep;
  267. _restaurantRep = restaurantRep;
  268. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  269. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  270. }
  271. #region 流程管控
  272. /// <summary>
  273. /// 获取团组流程管控信息
  274. /// </summary>
  275. /// <param name="_jsonDto">查询参数</param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  279. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  280. {
  281. if (string.IsNullOrEmpty(_jsonDto.Paras))
  282. {
  283. return Ok(JsonView(false, "参数为空"));
  284. }
  285. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  286. if (_ScheduleDto != null)
  287. {
  288. if (_ScheduleDto.SearchType == 2)//获取列表
  289. {
  290. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  291. return Ok(JsonView(_grpScheduleViewList));
  292. }
  293. else//获取对象
  294. {
  295. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  296. if (_grpScheduleView != null)
  297. {
  298. return Ok(JsonView(_grpScheduleView));
  299. }
  300. }
  301. }
  302. else
  303. {
  304. return Ok(JsonView(false, "参数反序列化失败"));
  305. }
  306. return Ok(JsonView(false, "暂无数据!"));
  307. }
  308. /// <summary>
  309. /// 修改团组流程管控详细表数据
  310. /// </summary>
  311. /// <param name="dto"></param>
  312. /// <returns></returns>
  313. [HttpPost]
  314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  315. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  316. {
  317. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  318. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  319. .SetColumns(it => it.Duty == _detail.Duty)
  320. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  321. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  322. .SetColumns(it => it.JobContent == _detail.JobContent)
  323. .SetColumns(it => it.Remark == _detail.Remark)
  324. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  325. .Where(s => s.Id == dto.Id)
  326. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  327. .ExecuteCommandAsync();
  328. if (result > 0)
  329. {
  330. return Ok(JsonView(true, "保存成功!"));
  331. }
  332. return Ok(JsonView(false, "保存失败!"));
  333. }
  334. /// <summary>
  335. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  336. /// </summary>
  337. /// <param name="dto"></param>
  338. /// <returns></returns>
  339. [HttpPost]
  340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  341. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  342. {
  343. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  344. _detail.IsDel = 1;
  345. _detail.DeleteUserId = dto.Duty;
  346. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  347. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  348. .SetColumns(it => it.IsDel == _detail.IsDel)
  349. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  350. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  351. .Where(it => it.Id == dto.Id)
  352. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  353. //.WhereColumns(s => s.Id == dto.Id)
  354. .ExecuteCommandAsync();
  355. if (result > 0)
  356. {
  357. return Ok(JsonView(true, "删除成功!"));
  358. }
  359. return Ok(JsonView(false, "删除失败!"));
  360. }
  361. /// <summary>
  362. /// 增加团组流程管控详细表数据
  363. /// </summary>
  364. /// <param name="dto"></param>
  365. /// <returns></returns>
  366. [HttpPost]
  367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  368. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  369. {
  370. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  371. if (DateTime.Now < _detail.ExpectBeginDt)
  372. {
  373. _detail.StepStatus = 0;
  374. }
  375. else
  376. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  377. _detail.StepStatus = 1;
  378. }
  379. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  380. if (result > 0)
  381. {
  382. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  383. return Ok(JsonView(true, "添加成功!", _result));
  384. }
  385. return Ok(JsonView(false, "添加失败!"));
  386. }
  387. #endregion
  388. #region 团组前期信息
  389. /// <summary>
  390. /// 团组前期信息 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. /// <returns></returns>
  462. [HttpGet]
  463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  464. public async Task<IActionResult> CountryInit()
  465. {
  466. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  467. return Ok(JsonView(countrys));
  468. }
  469. /// <summary>
  470. /// 城市数据源
  471. /// </summary>
  472. /// <returns></returns>
  473. [HttpGet("{countryLabel}")]
  474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  475. public async Task<IActionResult> CityByCountry(string countryLabel)
  476. {
  477. countryLabel = HttpUtility.UrlDecode(countryLabel);
  478. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  479. var citys = Array.Empty<string?>();
  480. if (countryList.Any())
  481. {
  482. var cityDatas = await _sqlSugar
  483. .Queryable<Grp_NationalTravelFee>()
  484. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  485. .ToArrayAsync();
  486. foreach (var item in cityDatas)
  487. {
  488. if (item.City.Contains("城市"))
  489. {
  490. item.City = item.Country + "-所有城市";
  491. }
  492. }
  493. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  494. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  495. }
  496. return Ok(JsonView(citys));
  497. }
  498. /// <summary>
  499. /// 团组前期信息 Info
  500. /// </summary>
  501. /// <param name="dto">Id</param>
  502. /// <returns></returns>
  503. [HttpGet("{Id}/{TempId}")]
  504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  505. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  506. {
  507. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  508. }
  509. /// <summary>
  510. /// 团组前期信息 Save
  511. /// </summary>
  512. /// <param name="dto">Id</param>
  513. /// <returns></returns>
  514. [HttpPost]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  517. {
  518. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  519. }
  520. /// <summary>
  521. /// 团组前期信息 Del
  522. /// </summary>
  523. /// <param name="dto">Id</param>
  524. /// <returns></returns>
  525. [HttpPost]
  526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  527. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  528. {
  529. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  530. }
  531. /// <summary>
  532. /// 团组前期信息 文件下载
  533. /// </summary>
  534. /// <param name="dto">Id</param>
  535. /// <returns></returns>
  536. [HttpGet("{Id}/{TempId}")]
  537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  538. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  539. {
  540. int id = dto.Id, tempId = dto.TempId;
  541. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  542. var data = view.Data as GrpOrderPreInfoView;
  543. #region Excel
  544. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  545. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  546. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  547. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  548. var fileNamePrefix = string.Empty;
  549. if (tempId == 1405)
  550. {
  551. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  552. fileNamePrefix = $"{data.Name}_无商邀版";
  553. }
  554. else if (tempId == 1406)
  555. {
  556. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  557. fileNamePrefix = $"{data.Name}_有商邀版";
  558. }
  559. else
  560. {
  561. //tempId == 1404 默认下载
  562. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  563. fileNamePrefix = $"{data.Name}_单接送机";
  564. }
  565. foreach (var item in data.Items)
  566. {
  567. var obj = item.NewValue;
  568. if (obj == null) item.OriginVal = "";
  569. else if (obj.Equals("有") || obj.Equals("无"))
  570. {
  571. item.OriginVal = obj.ToString();
  572. }
  573. else if (obj is object[] objArray)
  574. {
  575. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  576. item.OriginVal = string.Join("、", stringArray);
  577. }
  578. else if (obj is string[] stringArray)
  579. {
  580. item.OriginVal = string.Join("、", stringArray);
  581. }
  582. else if (obj.Equals("-"))
  583. {
  584. item.OriginVal = "";
  585. }
  586. }
  587. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  588. fileName = CommonFun.ValidFileName(fileName);
  589. //载入模板
  590. WorkbookDesigner designer = new WorkbookDesigner();
  591. designer.Workbook = new Workbook(tempPath);
  592. if (tempId == 1406)
  593. {
  594. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  595. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  596. for (int i = 1; i <= view2.Length; i++)
  597. {
  598. view2[i - 1].Index = i;
  599. }
  600. designer.SetDataSource("View1", view1);
  601. designer.SetDataSource("View2", view2);
  602. }
  603. else
  604. {
  605. designer.SetDataSource("View", data.Items);
  606. }
  607. designer.Process();
  608. if (!Directory.Exists(savePath))
  609. {
  610. Directory.CreateDirectory(savePath);
  611. }
  612. string serverPath = $"{savePath}{fileName}";
  613. designer.Workbook.Save(serverPath);
  614. string rst = $"{servicePath}{ftpPath}{fileName}";
  615. #endregion
  616. return Ok(JsonView(new { url = rst }));
  617. }
  618. #endregion
  619. #region 团组基本信息
  620. /// <summary>
  621. /// 接团信息列表
  622. /// </summary>
  623. /// <param name="dto">团组列表请求dto</param>
  624. /// <returns></returns>
  625. [HttpPost]
  626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  627. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  628. {
  629. var groupData = await _groupRepository.GetGroupList(dto);
  630. if (groupData.Code != 0)
  631. {
  632. return Ok(JsonView(false, groupData.Msg));
  633. }
  634. return Ok(JsonView(groupData.Data));
  635. }
  636. /// <summary>
  637. /// 分页查询团组列表
  638. /// </summary>
  639. /// <param name="dto"></param>
  640. /// <returns></returns>
  641. [HttpPost]
  642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  643. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  644. {
  645. var watch = new Stopwatch();
  646. watch.Start();
  647. RefAsync<int> total = 0;
  648. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  649. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  650. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  651. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  652. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  653. .Distinct()
  654. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  655. watch.Stop();
  656. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  657. }
  658. /// <summary>
  659. /// 接团信息列表 Page Init
  660. /// </summary>
  661. /// <returns></returns>
  662. [HttpPost]
  663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  664. public async Task<IActionResult> PostGroupPageListInit()
  665. {
  666. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  667. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  668. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  669. var _view = new
  670. {
  671. depData = depDatas,
  672. rankData = rankDatas
  673. };
  674. return Ok(JsonView(true, "查询成功!", _view));
  675. }
  676. /// <summary>
  677. /// 接团信息列表 Page
  678. /// </summary>
  679. /// <param name="dto">团组列表请求dto</param>
  680. /// <returns></returns>
  681. [HttpPost]
  682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  683. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  684. {
  685. #region 参数验证
  686. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  687. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  688. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  689. #region 页面操作权限验证
  690. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  691. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  692. #endregion
  693. #endregion
  694. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  695. {
  696. string sqlWhere = string.Empty;
  697. if (dto.IsSure == 0) //未完成
  698. {
  699. sqlWhere += string.Format(@" And IsSure = 0");
  700. }
  701. else if (dto.IsSure == 1) //已完成
  702. {
  703. sqlWhere += string.Format(@" And IsSure = 1");
  704. }
  705. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  706. {
  707. string tj = dto.SearchCriteria;
  708. 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}%')",
  709. tj, tj, tj, tj, tj);
  710. }
  711. if (int.TryParse(dto.Rank, out int rankId))
  712. {
  713. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  714. }
  715. string sqlWhere1 = string.Empty;
  716. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  717. {
  718. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  719. }
  720. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  721. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  722. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  723. JietuanOperator,IsSure,CreateTime,IsBid
  724. From (
  725. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  726. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  727. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  728. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  729. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  730. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  731. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  732. From Grp_DelegationInfo gdi
  733. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  734. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  735. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  736. Where gdi.IsDel = 0 {0}
  737. ) temp {1}", sqlWhere, sqlWhere1);
  738. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  739. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  740. var _view = new
  741. {
  742. PageFuncAuth = pageFunAuthView,
  743. Data = _DelegationList
  744. };
  745. return Ok(JsonView(true, "查询成功!", _view, total));
  746. }
  747. else
  748. {
  749. return Ok(JsonView(false, "查询失败"));
  750. }
  751. }
  752. /// <summary>
  753. /// 团组列表
  754. /// </summary>
  755. /// <returns></returns>
  756. [HttpPost]
  757. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  758. {
  759. #region 参数验证
  760. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  761. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  762. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  763. #region 页面操作权限验证
  764. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  765. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  766. #endregion
  767. #endregion
  768. if (dto.PortType != 1 && dto.PortType != 2)
  769. {
  770. return Ok(JsonView(false, "查询失败!"));
  771. }
  772. string orderbyStr = "order by gdi.CreateTime Desc";
  773. string sqlWhere = string.Empty;
  774. if (dto.IsSure == 0) //未完成
  775. {
  776. sqlWhere += string.Format(@" And IsSure = 0");
  777. }
  778. else if (dto.IsSure == 1) //已完成
  779. {
  780. sqlWhere += string.Format(@" And IsSure = 1");
  781. }
  782. //团组类型
  783. if (dto.TeamDid > 0)
  784. {
  785. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  786. }
  787. //团组名称
  788. if (!string.IsNullOrEmpty(dto.TeamName))
  789. {
  790. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  791. }
  792. //客户名称
  793. if (!string.IsNullOrEmpty(dto.ClientName))
  794. {
  795. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  796. }
  797. //客户单位
  798. if (!string.IsNullOrEmpty(dto.ClientUnit))
  799. {
  800. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  801. }
  802. //出访时间
  803. if (!string.IsNullOrEmpty(dto.visitDataTime))
  804. {
  805. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  806. orderbyStr = "order by gdi.VisitDate";
  807. }
  808. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  809. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  810. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  811. JietuanOperator,IsSure,CreateTime
  812. From (
  813. Select row_number() over({0}) as Row_Number,
  814. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  815. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  816. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  817. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  818. From Grp_DelegationInfo gdi
  819. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  820. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  821. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  822. Where gdi.IsDel = 0 {1}
  823. ) temp ", orderbyStr, sqlWhere);
  824. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  825. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  826. #region 处理所属部门
  827. /*
  828. * 1.sq 和 gyy 等显示 市场部
  829. * 2.王鸽和主管及张总还有管理员号统一国交部
  830. * 2-1. 4 管理员 ,21 张海麟
  831. */
  832. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  833. List<int> userIds1 = new List<int>() { 4, 21 };
  834. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  835. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  836. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  837. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  838. .ToList();
  839. foreach (var item in _DelegationList)
  840. {
  841. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  842. }
  843. #endregion
  844. var _view = new
  845. {
  846. PageFuncAuth = pageFunAuthView,
  847. Data = _DelegationList
  848. };
  849. return Ok(JsonView(true, "查询成功!", _view, total));
  850. }
  851. /// <summary>
  852. /// 接团信息详情
  853. /// </summary>
  854. /// <param name="dto">团组info请求dto</param>
  855. /// <returns></returns>
  856. [HttpPost]
  857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  858. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  859. {
  860. var groupData = await _groupRepository.GetGroupInfo(dto);
  861. if (groupData.Code != 0)
  862. {
  863. return Ok(JsonView(false, groupData.Msg));
  864. }
  865. return Ok(JsonView(groupData.Data));
  866. }
  867. /// <summary>
  868. /// 接团信息 编辑添加
  869. /// 基础信息数据源
  870. /// </summary>
  871. /// <param name="dto"></param>
  872. /// <returns></returns>
  873. [HttpPost]
  874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  875. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  876. {
  877. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  878. if (groupData.Code != 0)
  879. {
  880. return Ok(JsonView(false, groupData.Msg));
  881. }
  882. return Ok(JsonView(groupData.Data));
  883. }
  884. /// <summary>
  885. /// 接团信息 编辑添加
  886. /// 省份-城市 基础信息数据源
  887. /// </summary>
  888. /// <param name="dto"></param>
  889. /// <returns></returns>
  890. [HttpPost]
  891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  892. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  893. {
  894. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  895. string search = dto.Search;
  896. var data = await _groupRepository.CityBasicSource();
  897. int total = data.Length;
  898. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  899. .Skip((pageIndex - 1) * pageSize)
  900. .Take(pageSize)
  901. .ToArray();
  902. return Ok(JsonView(data, total));
  903. }
  904. /// <summary>
  905. /// 接团信息 操作(增改)
  906. /// </summary>
  907. /// <param name="dto"></param>
  908. /// <returns></returns>
  909. [HttpPost]
  910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  911. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  912. {
  913. // 创建 Stopwatch 实例
  914. Stopwatch stopwatch = Stopwatch.StartNew();
  915. decimal ffrPrice = 0.00M;
  916. DateTime? visitDt = null;
  917. if (dto.Status == 2)
  918. {
  919. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  920. if (groupInfo != null)
  921. {
  922. ffrPrice = groupInfo.PaymentMoney;
  923. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  924. }
  925. }
  926. var groupData = await _groupRepository.GroupOperation(dto);
  927. if (groupData.Code != 0)
  928. {
  929. return Ok(JsonView(false, groupData.Msg));
  930. }
  931. int diId = 0;
  932. try
  933. {
  934. //添加时 默认加入团组汇率
  935. if (dto.Status == 1) //添加
  936. {
  937. diId = groupData.Data;
  938. //添加默认币种
  939. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  940. //默认分配权限
  941. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  942. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  943. var _managerIds = new List<int>() { 22, 32, 21 };
  944. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  945. if (userIds.Count > 0)
  946. {
  947. userIds.Add(208);
  948. //创建团组管控
  949. GroupStepForDelegation.CreateWorkStep(diId);
  950. //发送消息
  951. string groupName = dto.TeamName;
  952. string createGroupUser = string.Empty;
  953. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  954. if (userInfo != null) createGroupUser = userInfo.CnName;
  955. string title = $"系统通知";
  956. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  957. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  958. }
  959. //默认创建倒推表
  960. await _invertedListRep._Create(dto.UserId, diId);
  961. }
  962. else if (dto.Status == 2)
  963. {
  964. diId = dto.Id;
  965. }
  966. #region 签证人员团组时间通知
  967. #region 计算出访起止时间
  968. var startTime = new DateTime();
  969. var endTime = new DateTime();
  970. if (DateTime.TryParse(dto.VisitDate, out startTime))
  971. {
  972. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  973. }
  974. #endregion
  975. #endregion
  976. #region 团组操作默认添加/修改收款账单
  977. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  978. {
  979. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  980. .Where(x => x.IsDel == 0 &&
  981. x.Diid == diId &&
  982. x.Remark.Equals("预付款")
  983. )
  984. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  985. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  986. .FirstAsync();
  987. ffrInfo = new Fin_ForeignReceivables()
  988. {
  989. Diid = diId,
  990. PriceName = dto.ClientUnit,
  991. Price = dto.PaymentMoney,
  992. Count = 1,
  993. Unit = $"元",
  994. ItemSumPrice = dto.PaymentMoney,
  995. Rate = 1.0000M,
  996. Currency = 836,
  997. AddingWay = 0,
  998. CreateUserId = dto.UserId,
  999. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1000. Remark = $"预付款"
  1001. };
  1002. if (ffrInfo == null) //Add
  1003. {
  1004. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1005. }
  1006. else //修改
  1007. {
  1008. await _sqlSugar.Updateable(ffrInfo)
  1009. .UpdateColumns(x => new
  1010. {
  1011. x.PriceName,
  1012. x.Price,
  1013. x.ItemSumPrice,
  1014. x.CreateTime,
  1015. x.CreateUserId
  1016. })
  1017. .WhereColumns(x => x.Id)
  1018. .ExecuteCommandAsync();
  1019. }
  1020. }
  1021. #endregion
  1022. if (diId > 0)
  1023. {
  1024. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1025. }
  1026. // 停止计时
  1027. stopwatch.Stop();
  1028. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1029. }
  1030. catch (Exception ex)
  1031. {
  1032. // 停止计时
  1033. stopwatch.Stop();
  1034. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1035. Logs(ex.Message);
  1036. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1037. }
  1038. // 停止计时
  1039. stopwatch.Stop();
  1040. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1041. }
  1042. /// <summary>
  1043. /// 接团流程操作(增改)
  1044. /// 安卓端使用 建团时添加客户名单
  1045. /// </summary>
  1046. /// <param name="dto"></param>
  1047. /// <returns></returns>
  1048. [HttpPost]
  1049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1050. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1051. {
  1052. #region 参数验证
  1053. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1055. #region 页面操作权限验证
  1056. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1057. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1058. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1059. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1060. #endregion
  1061. #endregion
  1062. try
  1063. {
  1064. //_sqlSugar.BeginTran();
  1065. decimal ffrPrice = 0.00M;
  1066. DateTime? visitDt = null;
  1067. if (dto.Status == 2)
  1068. {
  1069. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1070. if (groupInfo != null)
  1071. {
  1072. ffrPrice = groupInfo.PaymentMoney;
  1073. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1074. }
  1075. }
  1076. var _dto = new GroupOperationDto();
  1077. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1078. var groupData = await _groupRepository.GroupOperation(_dto);
  1079. if (groupData.Code != 0)
  1080. {
  1081. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1082. }
  1083. int diId = 0;
  1084. //添加时 默认加入团组汇率
  1085. if (dto.Status == 1) //添加
  1086. {
  1087. diId = groupData.Data;
  1088. //添加默认币种
  1089. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1090. //默认分配权限
  1091. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1092. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1093. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1094. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1095. if (userIds.Count > 0)
  1096. {
  1097. userIds.Add(208);
  1098. //创建团组管控
  1099. GroupStepForDelegation.CreateWorkStep(diId);
  1100. //发送消息
  1101. string groupName = dto.TeamName;
  1102. string createGroupUser = string.Empty;
  1103. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1104. if (userInfo != null) createGroupUser = userInfo.CnName;
  1105. string title = $"系统通知";
  1106. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1107. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1108. }
  1109. #region 应用推送
  1110. try
  1111. {
  1112. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1113. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1114. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1115. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1116. {
  1117. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1118. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1119. }
  1120. }
  1121. catch (Exception ex)
  1122. {
  1123. }
  1124. #endregion
  1125. //默认创建倒推表
  1126. await _invertedListRep._Create(dto.UserId, diId);
  1127. }
  1128. if (dto.Status == 2)
  1129. {
  1130. diId = dto.Id;
  1131. if (diId == 0)
  1132. {
  1133. //_sqlSugar.RollbackTran();
  1134. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1135. }
  1136. }
  1137. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1138. if (viewData.Code != 0)
  1139. {
  1140. //_sqlSugar.RollbackTran();
  1141. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1142. }
  1143. #region 团组操作默认添加/修改收款账单
  1144. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1145. {
  1146. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1147. .Where(x => x.IsDel == 0 &&
  1148. x.Diid == diId &&
  1149. x.Remark.Equals("预付款")
  1150. )
  1151. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1152. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1153. .FirstAsync();
  1154. ffrInfo = new Fin_ForeignReceivables()
  1155. {
  1156. Diid = diId,
  1157. PriceName = dto.ClientUnit,
  1158. Price = dto.PaymentMoney,
  1159. Count = 1,
  1160. Unit = $"元",
  1161. ItemSumPrice = dto.PaymentMoney,
  1162. Rate = 1.0000M,
  1163. Currency = 836,
  1164. AddingWay = 0,
  1165. CreateUserId = dto.UserId,
  1166. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1167. Remark = $"预付款"
  1168. };
  1169. if (ffrInfo == null) //Add
  1170. {
  1171. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1172. }
  1173. else //修改
  1174. {
  1175. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1176. .UpdateColumns(x => new
  1177. {
  1178. x.PriceName,
  1179. x.Price,
  1180. x.ItemSumPrice,
  1181. x.CreateTime,
  1182. x.CreateUserId
  1183. })
  1184. .WhereColumns(x => x.Id)
  1185. .ExecuteCommandAsync();
  1186. }
  1187. }
  1188. #endregion
  1189. #region 签证人员团组时间通知
  1190. #region 计算出访起止时间
  1191. var startTime = new DateTime();
  1192. var endTime = new DateTime();
  1193. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1194. {
  1195. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1196. }
  1197. #endregion
  1198. if (diId > 0)
  1199. {
  1200. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1201. }
  1202. #endregion
  1203. //_sqlSugar.CommitTran();
  1204. return Ok(JsonView(true, "添加成功"));
  1205. }
  1206. catch (Exception ex)
  1207. {
  1208. _sqlSugar.RollbackTran();
  1209. return Ok(JsonView(false, ex.Message));
  1210. }
  1211. }
  1212. /// <summary>
  1213. /// 接团流程操作(增改)
  1214. /// 安卓端使用 建团时添加客户名单
  1215. /// </summary>
  1216. /// <param name="dto"></param>
  1217. /// <returns></returns>
  1218. [HttpPost]
  1219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1220. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1221. {
  1222. #region 参数验证
  1223. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1224. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1225. #region 页面操作权限验证
  1226. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1227. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1228. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1229. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1230. #endregion
  1231. #endregion
  1232. _sqlSugar.BeginTran();
  1233. decimal ffrPrice = 0.00M;
  1234. DateTime? visitDt = null;
  1235. if (dto.Status == 2)
  1236. {
  1237. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1238. if (groupInfo != null)
  1239. {
  1240. ffrPrice = groupInfo.PaymentMoney;
  1241. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1242. }
  1243. }
  1244. var _dto = new GroupOperationDto();
  1245. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1246. var groupData = await _groupRepository.GroupOperation(_dto);
  1247. if (groupData.Code != 0)
  1248. {
  1249. _sqlSugar.RollbackTran();
  1250. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1251. }
  1252. try
  1253. {
  1254. int diId = 0;
  1255. //添加时 默认加入团组汇率
  1256. if (dto.Status == 1) //添加
  1257. {
  1258. diId = groupData.Data;
  1259. //添加默认币种
  1260. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1261. //默认分配权限
  1262. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1263. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1264. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1265. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1266. if (userIds.Count > 0)
  1267. {
  1268. userIds.Add(208);
  1269. //创建团组管控
  1270. GroupStepForDelegation.CreateWorkStep(diId);
  1271. //发送消息
  1272. string groupName = dto.TeamName;
  1273. string createGroupUser = string.Empty;
  1274. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1275. if (userInfo != null) createGroupUser = userInfo.CnName;
  1276. string title = $"系统通知";
  1277. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1278. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1279. }
  1280. #region 应用推送
  1281. try
  1282. {
  1283. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1284. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1285. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1286. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1287. {
  1288. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1289. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1290. }
  1291. }
  1292. catch (Exception ex)
  1293. {
  1294. _sqlSugar.CommitTran();
  1295. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1296. }
  1297. #endregion
  1298. //默认创建倒推表
  1299. await _invertedListRep._Create(dto.UserId, diId);
  1300. }
  1301. else if (dto.Status == 2)
  1302. {
  1303. diId = dto.Id;
  1304. if (diId == 0)
  1305. {
  1306. _sqlSugar.RollbackTran();
  1307. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1308. }
  1309. }
  1310. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1311. if (viewData.Code != 0)
  1312. {
  1313. _sqlSugar.RollbackTran();
  1314. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1315. }
  1316. #region 团组操作默认添加/修改收款账单
  1317. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1318. {
  1319. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1320. .Where(x => x.IsDel == 0 &&
  1321. x.Diid == diId &&
  1322. x.Remark.Equals("预付款")
  1323. )
  1324. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1325. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1326. .FirstAsync();
  1327. ffrInfo = new Fin_ForeignReceivables()
  1328. {
  1329. Diid = diId,
  1330. PriceName = dto.ClientUnit,
  1331. Price = dto.PaymentMoney,
  1332. Count = 1,
  1333. Unit = $"元",
  1334. ItemSumPrice = dto.PaymentMoney,
  1335. Rate = 1.0000M,
  1336. Currency = 836,
  1337. AddingWay = 0,
  1338. CreateUserId = dto.UserId,
  1339. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1340. Remark = $"预付款"
  1341. };
  1342. if (ffrInfo == null) //Add
  1343. {
  1344. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1345. }
  1346. else //修改
  1347. {
  1348. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1349. .UpdateColumns(x => new
  1350. {
  1351. x.PriceName,
  1352. x.Price,
  1353. x.ItemSumPrice,
  1354. x.CreateTime,
  1355. x.CreateUserId
  1356. })
  1357. .WhereColumns(x => x.Id)
  1358. .ExecuteCommandAsync();
  1359. }
  1360. }
  1361. #endregion
  1362. #region 签证人员团组时间通知
  1363. #region 计算出访起止时间
  1364. var startTime = new DateTime();
  1365. var endTime = new DateTime();
  1366. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1367. {
  1368. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1369. }
  1370. #endregion
  1371. if (diId > 0)
  1372. {
  1373. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1374. }
  1375. #endregion
  1376. _sqlSugar.CommitTran();
  1377. return Ok(JsonView(true));
  1378. }
  1379. catch (Exception ex)
  1380. {
  1381. _sqlSugar.RollbackTran();
  1382. return Ok(JsonView(false, ex.Message));
  1383. }
  1384. }
  1385. /// <summary>
  1386. /// 接团信息 操作(删除)
  1387. /// </summary>
  1388. /// <param name="dto"></param>
  1389. /// <returns></returns>
  1390. [HttpPost]
  1391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1392. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1393. {
  1394. var diId = dto.Id;
  1395. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1396. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1397. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1398. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1399. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1400. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1401. #endregion
  1402. var groupData = await _groupRepository.GroupDel(dto);
  1403. if (groupData.Code != 0)
  1404. {
  1405. return Ok(JsonView(false, groupData.Msg));
  1406. }
  1407. return Ok(JsonView(true));
  1408. }
  1409. /// <summary>
  1410. /// 获取团组销售报价号
  1411. /// 团组添加时 使用
  1412. /// </summary>
  1413. /// <returns></returns>
  1414. [HttpPost]
  1415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1416. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1417. {
  1418. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1419. if (groupData.Code != 0)
  1420. {
  1421. return Ok(JsonView(false, groupData.Msg));
  1422. }
  1423. object salesQuoteNo = new
  1424. {
  1425. SalesQuoteNo = groupData.Data
  1426. };
  1427. return Ok(JsonView(salesQuoteNo));
  1428. }
  1429. /// <summary>
  1430. /// 设置确认出团
  1431. /// </summary>
  1432. /// <param name="dto"></param>
  1433. /// <returns></returns>
  1434. [HttpPost]
  1435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1436. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1437. {
  1438. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1439. if (groupData.Code != 0)
  1440. {
  1441. return Ok(JsonView(false, groupData.Msg));
  1442. }
  1443. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1444. #region OA消息推送
  1445. try
  1446. {
  1447. string groupName = groupInfo.TeamName;
  1448. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1449. string title = $"系统通知";
  1450. string content = $"团组[{groupName}]已确认出团!";
  1451. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1452. }
  1453. catch (Exception ex)
  1454. {
  1455. }
  1456. #endregion
  1457. #region 应用推送
  1458. try
  1459. {
  1460. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1461. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1462. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1463. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1464. {
  1465. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1466. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1467. }
  1468. }
  1469. catch (Exception ex)
  1470. {
  1471. }
  1472. #endregion
  1473. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1474. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1475. }
  1476. /// <summary>
  1477. /// 获取团组名称data And 签证国别Data
  1478. /// </summary>
  1479. /// <param name="dto"></param>
  1480. /// <returns></returns>
  1481. [HttpPost]
  1482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1483. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1484. {
  1485. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1486. if (groupData.Code != 0)
  1487. {
  1488. return Ok(JsonView(false, groupData.Msg));
  1489. }
  1490. return Ok(JsonView(groupData.Data));
  1491. }
  1492. /// <summary>
  1493. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1494. /// </summary>
  1495. /// <returns></returns>
  1496. [HttpPost]
  1497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1498. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1499. {
  1500. try
  1501. {
  1502. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1503. if (groupData.Code != 0)
  1504. {
  1505. return Ok(JsonView(false, groupData.Msg));
  1506. }
  1507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1508. }
  1509. catch (Exception ex)
  1510. {
  1511. return Ok(JsonView(false, "程序错误!"));
  1512. throw;
  1513. }
  1514. }
  1515. /// <summary>
  1516. /// 团组清单 Excel
  1517. /// </summary>
  1518. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1519. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1520. /// <returns></returns>
  1521. [HttpGet]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1524. {
  1525. DateTime _beginDt, _endDt;
  1526. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1527. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1528. if (!beginBool && !endBool)
  1529. {
  1530. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1531. }
  1532. string sql = string.Format(@"
  1533. SELECT
  1534. ROW_NUMBER,
  1535. Id,
  1536. SalesQuoteNo,
  1537. TourCode,
  1538. TeamTypeId,
  1539. TeamType,
  1540. TeamLevId,
  1541. TeamLev,
  1542. TeamName,
  1543. ClientName,
  1544. ClientUnit,
  1545. VisitDate,
  1546. VisitDays,
  1547. VisitPNumber,
  1548. JietuanOperatorId,
  1549. JietuanOperator,
  1550. IsSure,
  1551. CreateUserName,
  1552. IsBid
  1553. FROM
  1554. (
  1555. SELECT
  1556. ROW_NUMBER() OVER(
  1557. ORDER BY
  1558. gdi.CreateTime Desc
  1559. ) AS ROW_NUMBER,
  1560. gdi.Id,
  1561. SalesQuoteNo,
  1562. TourCode,
  1563. ssd.Id TeamTypeId,
  1564. ssd.Name TeamType,
  1565. ssd1.Id TeamLevId,
  1566. ssd1.Name TeamLev,
  1567. TeamName,
  1568. ClientName,
  1569. ClientUnit,
  1570. VisitDate,
  1571. VisitDays,
  1572. VisitPNumber,
  1573. JietuanOperator JietuanOperatorId,
  1574. su.CnName JietuanOperator,
  1575. IsSure,
  1576. gdi.CreateTime,
  1577. su1.CnName As CreateUserName,
  1578. gdi.IsBid
  1579. FROM
  1580. Grp_DelegationInfo gdi
  1581. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1582. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1583. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1584. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1585. WHERE
  1586. gdi.IsDel = 0
  1587. AND gdi.IsBid = 0
  1588. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1589. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1590. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1591. #region 处理所属部门
  1592. /*
  1593. * 1.sq 和 gyy 等显示 市场部
  1594. * 2.王鸽和主管及张总还有管理员号统一国交部
  1595. * 2-1. 4 管理员 ,21 张海麟
  1596. */
  1597. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1598. List<int> userIds1 = new List<int>() { 4, 21 };
  1599. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1600. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1601. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1602. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1603. .ToListAsync();
  1604. var droupIds = groupList.Select(it => it.Id).ToList();
  1605. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1606. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1607. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1608. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1609. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1610. {
  1611. DiId = tcl.DiId,
  1612. LastName = dc.LastName,
  1613. FirstName = dc.FirstName,
  1614. Sex = dc.Sex,
  1615. Birthday = dc.BirthDay,
  1616. Company = cc.CompanyFullName,
  1617. Job = dc.Job,
  1618. CreateTime = tcl.CreateTime,
  1619. })
  1620. .ToList();
  1621. foreach (var item in groupList)
  1622. {
  1623. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1624. string groupFirstName = "";
  1625. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1626. if (currDatas.Any())
  1627. {
  1628. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1629. }
  1630. item.GroupFirst = groupFirstName;
  1631. }
  1632. #endregion
  1633. #region Excel
  1634. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1635. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1636. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1637. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1638. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1639. //载入模板
  1640. WorkbookDesigner designer = new WorkbookDesigner();
  1641. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1642. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1643. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1644. dt.TableName = "GroupList";
  1645. designer.SetDataSource(dt);
  1646. designer.Process();
  1647. if (!Directory.Exists(savePath))
  1648. {
  1649. Directory.CreateDirectory(savePath);
  1650. }
  1651. string serverPath = $"{savePath}{fileName}";
  1652. designer.Workbook.Save(serverPath);
  1653. string rst = $"{servicePath}{ftpPath}{fileName}";
  1654. #endregion
  1655. return Ok(JsonView(true, "操作成功!", rst));
  1656. }
  1657. /// <summary>
  1658. /// 团组合同下载(1.付款80% 2.付全款)
  1659. /// </summary>
  1660. /// <param name="dto"></param>
  1661. /// <returns></returns>
  1662. /// <exception cref="Exception"></exception>
  1663. [HttpPost]
  1664. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1665. {
  1666. var jw = JsonView(false);
  1667. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1668. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1669. if (di == null)
  1670. {
  1671. jw.Msg = "团组Id有误!";
  1672. return Ok(jw);
  1673. }
  1674. #region 权限校验
  1675. var allDownFile = new List<int>() { 21 };
  1676. try
  1677. {
  1678. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1679. .First(x => x.Id == 1418 && x.IsDel == 0);
  1680. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1681. }
  1682. catch (Exception)
  1683. { }
  1684. var guojiaoDownFile = new List<int>() { 330 };
  1685. var shichangDownFile = new List<int>() { 95 };
  1686. if (allDownFile.Contains(dto.UserId))
  1687. {
  1688. }
  1689. else if (guojiaoDownFile.Contains(dto.UserId))
  1690. {
  1691. var guojiaobuDi = new List<int>() { 4, 21 };
  1692. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1693. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1694. .Where((d, u) => u.Id == di.JietuanOperator)
  1695. .Select((d, u) => d.DepName)
  1696. .First();
  1697. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1698. {
  1699. jw.Msg = "暂无下载权限!";
  1700. return Ok(jw);
  1701. }
  1702. }
  1703. else if (shichangDownFile.Contains(dto.UserId))
  1704. {
  1705. var dic = new Dictionary<int, int[]>()
  1706. {
  1707. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1708. };
  1709. try
  1710. {
  1711. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1712. if (sqSetting != null)
  1713. {
  1714. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1715. foreach (var item in result.Keys)
  1716. {
  1717. if (dic.Keys.Contains(item))
  1718. {
  1719. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1720. Array.Copy(dic[item], dilatation, dic[item].Length);
  1721. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1722. dic[item] = dilatation;
  1723. }
  1724. else
  1725. {
  1726. dic.Add(item, result[item]);
  1727. }
  1728. }
  1729. }
  1730. if (!dic[95].Contains(di.CreateUserId))
  1731. {
  1732. jw.Msg = "暂无下载权限!";
  1733. return Ok(jw);
  1734. }
  1735. }
  1736. catch (Exception)
  1737. { }
  1738. }
  1739. else if (dto.UserId == di.CreateUserId)
  1740. {
  1741. }
  1742. else
  1743. {
  1744. jw.Msg = "暂无下载权限!";
  1745. return Ok(jw);
  1746. }
  1747. #endregion
  1748. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1749. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1750. .ToListAsync();
  1751. if (!blackCodeList.Any())
  1752. {
  1753. jw.Msg = "该团无机票行程代码!";
  1754. return Ok(jw);
  1755. }
  1756. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1757. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1758. if (groupEnterExitCost == null)
  1759. {
  1760. jw.Msg = "暂无三公费用信息!";
  1761. return Ok(jw);
  1762. }
  1763. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1764. rateList ??= new List<CurrencyInfo>();
  1765. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1766. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1767. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1768. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1769. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1770. .Select((x, a, b) => new
  1771. {
  1772. x.Index,
  1773. itemName = a.Name,
  1774. CurrencyStr = b.Name,
  1775. x.Cost,
  1776. x.SubTotal,
  1777. x.Remark
  1778. })
  1779. .OrderBy((x) => x.Index)
  1780. .ToList();
  1781. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1782. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1783. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1784. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1785. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1786. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1787. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1788. decimal subJJC = 0.00M,
  1789. subGWC = 0.00M,
  1790. subTDC = 0.00M;
  1791. //经济舱
  1792. if (groupEnterExitCost.SumJJC == 1)
  1793. {
  1794. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1795. }
  1796. //公务舱
  1797. if (groupEnterExitCost.SumGWC == 1)
  1798. {
  1799. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1800. }
  1801. //头等舱
  1802. if (groupEnterExitCost.SumTDC == 1)
  1803. {
  1804. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1805. }
  1806. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1807. .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
  1808. .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
  1809. .Select((x, s) => new
  1810. {
  1811. x.Id,
  1812. s.Name,
  1813. })
  1814. .ToListAsync();
  1815. //获取舱位人数
  1816. var cabinCount = groupClints.GroupBy(x => x.Name)
  1817. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1818. .ToList();
  1819. string cityPath = string.Empty;
  1820. string startCity = string.Empty;
  1821. string endCity = string.Empty;
  1822. foreach (var item in blackCodeList)
  1823. {
  1824. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1825. cityPath += city + "\r\n";
  1826. if (item.Equals(blackCodeList.First()))
  1827. {
  1828. var sp = city.Split('-');
  1829. startCity = sp[0];
  1830. endCity = sp[sp.Length - 1];
  1831. }
  1832. }
  1833. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1834. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1835. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1836. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1837. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1838. bookMarkDic.Add("CityPath", cityPath);
  1839. bookMarkDic.Add("StartCity", startCity);
  1840. bookMarkDic.Add("EndCity", endCity);
  1841. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1842. Document doc = null;
  1843. var percentage = 0.8M;
  1844. var fileNameadd = "预付";
  1845. if (dto.FileType == 1)
  1846. {
  1847. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1848. }
  1849. else if (dto.FileType == 2)
  1850. {
  1851. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1852. percentage = 1;
  1853. fileNameadd = "全款";
  1854. }
  1855. else
  1856. {
  1857. throw new Exception("FileType有误!");
  1858. }
  1859. DocumentBuilder builder = new DocumentBuilder(doc);
  1860. decimal totalPrice = 0.00M;
  1861. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1862. if (firstTable != null)
  1863. {
  1864. // 遍历表格的行和单元格
  1865. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1866. {
  1867. for (int i = 0; i < row.Cells.Count; i++)
  1868. {
  1869. var cell = row.Cells[i];
  1870. // 读取单元格内容
  1871. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1872. if (cellTextFirst.Contains("舱位"))
  1873. {
  1874. break;
  1875. }
  1876. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1877. {
  1878. if (i == 2)
  1879. {
  1880. if (cellTextFirst == "经济舱")
  1881. {
  1882. // 设置单元格内容
  1883. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1884. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1885. }
  1886. else
  1887. {
  1888. // 设置单元格内容
  1889. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1890. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1891. }
  1892. }
  1893. if (i == 3)
  1894. {
  1895. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1896. if (count != null)
  1897. {
  1898. // 设置单元格内容
  1899. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1900. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  1901. }
  1902. }
  1903. if (i == 4)
  1904. {
  1905. var rowPrice = 0.00M;
  1906. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1907. count ??= 0;
  1908. if (cellTextFirst == "经济舱")
  1909. {
  1910. rowPrice = subJJC * (int)count;
  1911. }
  1912. else
  1913. {
  1914. rowPrice = subGWC * (int)count;
  1915. }
  1916. totalPrice += rowPrice;
  1917. // 设置单元格内容
  1918. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1919. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  1920. }
  1921. }
  1922. }
  1923. }
  1924. }
  1925. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  1926. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  1927. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  1928. //--合同表格部分
  1929. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  1930. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  1931. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  1932. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  1933. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  1934. bookMarkDic.Add("CityPath1", cityPath);
  1935. bookMarkDic.Add("CityPath2", cityPath);
  1936. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  1937. if (contractTable != null)
  1938. {
  1939. //数据源
  1940. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  1941. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  1942. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  1943. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  1944. .Select((it, y, s) => new
  1945. {
  1946. it.Cost,
  1947. it.SubTotal,
  1948. it.Type,
  1949. y.Id,
  1950. y.City,
  1951. s.Name,
  1952. CurrencyCodeCn = s.Remark
  1953. })
  1954. .ToList()
  1955. .Select(x => new
  1956. {
  1957. CurrencyCode = x.Name,
  1958. CityId = x.Id,
  1959. x.City,
  1960. VisitPNumber = di.VisitPNumber,
  1961. x.Type,
  1962. x.Cost,
  1963. x.SubTotal,
  1964. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  1965. x.CurrencyCodeCn,
  1966. });
  1967. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  1968. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  1969. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  1970. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  1971. List<tableSetting> tableSettings = new List<tableSetting>()
  1972. {
  1973. new tableSetting{ Index = 1 , Property = "City"},
  1974. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  1975. new tableSetting{ Index = 3 , Property = "Cost"},
  1976. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  1977. //new tableSetting{ Index = 5 , Property = ""},
  1978. //new tableSetting{ Index = 6 , Property = ""},
  1979. new tableSetting{ Index = 7 , Property = "Rate"},
  1980. //new tableSetting{ Index = 8 , Property = ""},
  1981. };
  1982. //1.住宿费
  1983. int cloneRow = 8;
  1984. int startDayPrice = 8; //写入index
  1985. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  1986. foreach (var dac in dac1)
  1987. {
  1988. var first = dac.First();
  1989. var dayCount = dac.Count();
  1990. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  1991. for (int i = 1; i < row.Cells.Count; i++)
  1992. {
  1993. var cell = row.Cells[i];
  1994. var findProperty = tableSettings.Find(x => x.Index == i);
  1995. if (findProperty != null)
  1996. {
  1997. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  1998. // 设置单元格内容
  1999. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2000. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2001. }
  2002. else
  2003. {
  2004. switch (i)
  2005. {
  2006. case 5:
  2007. cell.FirstParagraph.Runs.Clear();
  2008. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2009. break;
  2010. case 6:
  2011. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2012. cell.FirstParagraph.Runs.Clear();
  2013. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2014. break;
  2015. case 8:
  2016. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2017. cell.FirstParagraph.Runs.Clear();
  2018. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2019. ZSPriceSum += xiaojiRMB;
  2020. break;
  2021. default:
  2022. break;
  2023. }
  2024. }
  2025. }
  2026. startDayPrice++;
  2027. if (!dac1.Last().Equals(dac))
  2028. {
  2029. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2030. // 将克隆的行追加到原行后面
  2031. contractTable.Rows.Insert(startDayPrice, newRow);
  2032. }
  2033. else
  2034. {
  2035. cloneRow += dac1.Count() + 1;
  2036. startDayPrice = cloneRow;
  2037. }
  2038. }
  2039. //2.伙食费
  2040. foreach (var dac in dac2)
  2041. {
  2042. var first = dac.First();
  2043. var dayCount = dac.Count();
  2044. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2045. for (int i = 1; i < row.Cells.Count; i++)
  2046. {
  2047. var cell = row.Cells[i];
  2048. var findProperty = tableSettings.Find(x => x.Index == i);
  2049. if (findProperty != null)
  2050. {
  2051. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2052. // 设置单元格内容
  2053. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2054. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2055. }
  2056. else
  2057. {
  2058. switch (i)
  2059. {
  2060. case 5:
  2061. cell.FirstParagraph.Runs.Clear();
  2062. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2063. break;
  2064. case 6:
  2065. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2066. cell.FirstParagraph.Runs.Clear();
  2067. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2068. break;
  2069. case 8:
  2070. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2071. cell.FirstParagraph.Runs.Clear();
  2072. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2073. HSPriceSum += xiaojiRMB;
  2074. break;
  2075. default:
  2076. break;
  2077. }
  2078. }
  2079. }
  2080. startDayPrice++;
  2081. if (!dac2.Last().Equals(dac))
  2082. {
  2083. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2084. // 将克隆的行追加到原行后面
  2085. contractTable.Rows.Insert(startDayPrice, newRow);
  2086. }
  2087. else
  2088. {
  2089. cloneRow += dac2.Count() + 1;
  2090. startDayPrice = cloneRow;
  2091. }
  2092. }
  2093. //3.公杂费
  2094. foreach (var dac in dac3)
  2095. {
  2096. var first = dac.First();
  2097. var dayCount = dac.Count();
  2098. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2099. for (int i = 1; i < row.Cells.Count; i++)
  2100. {
  2101. var cell = row.Cells[i];
  2102. var findProperty = tableSettings.Find(x => x.Index == i);
  2103. if (findProperty != null)
  2104. {
  2105. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2106. // 设置单元格内容
  2107. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2108. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2109. }
  2110. else
  2111. {
  2112. switch (i)
  2113. {
  2114. case 5:
  2115. cell.FirstParagraph.Runs.Clear();
  2116. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2117. break;
  2118. case 6:
  2119. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2120. cell.FirstParagraph.Runs.Clear();
  2121. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2122. break;
  2123. case 8:
  2124. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2125. cell.FirstParagraph.Runs.Clear();
  2126. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2127. GZPriceSum += xiaojiRMB;
  2128. break;
  2129. default:
  2130. break;
  2131. }
  2132. }
  2133. }
  2134. startDayPrice++;
  2135. if (!dac3.Last().Equals(dac))
  2136. {
  2137. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2138. // 将克隆的行追加到原行后面
  2139. contractTable.Rows.Insert(startDayPrice, newRow);
  2140. }
  2141. else
  2142. {
  2143. cloneRow += dac3.Count() + 1;
  2144. startDayPrice = cloneRow;
  2145. }
  2146. }
  2147. //合并单元格
  2148. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2149. {
  2150. var currentRow = contractTable.Rows[i];
  2151. var nextRow = contractTable.Rows[i + 1];
  2152. // 获取当前行和下一行的第一个单元格
  2153. Cell currentCell = currentRow.Cells[0];
  2154. Cell nextCell = nextRow.Cells[0];
  2155. // 检查单元格内容是否一致(去除尾部的换行符)
  2156. string currentText = currentCell.GetText().Trim();
  2157. string nextText = nextCell.GetText().Trim();
  2158. if (currentText == nextText)
  2159. {
  2160. // 如果当前单元格已经被合并,找到合并的起始单元格
  2161. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2162. {
  2163. // 找到合并的起始单元格
  2164. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2165. // 将下一行的单元格设置为合并的后续单元格
  2166. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2167. }
  2168. else
  2169. {
  2170. // 如果当前单元格是合并的起始单元格
  2171. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2172. // 将下一行的单元格设置为合并的后续单元格
  2173. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2174. }
  2175. }
  2176. else
  2177. {
  2178. // 如果内容不一致,重置当前单元格的合并属性
  2179. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2180. {
  2181. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2182. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2183. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2184. }
  2185. else
  2186. {
  2187. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2188. }
  2189. }
  2190. }
  2191. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2192. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2193. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2194. }
  2195. foreach (var bookmarkName in bookMarkDic.Keys)
  2196. {
  2197. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2198. if (bookmark != null)
  2199. {
  2200. if (bookmarkName == "ClientUnit")
  2201. {
  2202. // 移动到书签位置
  2203. builder.MoveTo(bookmark.BookmarkStart);
  2204. // 设置字体样式为下划线
  2205. builder.Font.Underline = Aspose.Words.Underline.Single;
  2206. // 插入书签值
  2207. builder.Write(bookMarkDic[bookmarkName]);
  2208. // 清除字体格式,避免影响后续文本
  2209. builder.Font.ClearFormatting();
  2210. }
  2211. else
  2212. {
  2213. builder.MoveToBookmark(bookmarkName);
  2214. builder.Write(bookMarkDic[bookmarkName]);
  2215. }
  2216. }
  2217. }
  2218. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2219. doc.Save(savePaht);
  2220. jw.Msg = "生成成功!";
  2221. jw.Code = 200;
  2222. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2223. return Ok(jw);
  2224. }
  2225. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2226. {
  2227. int index = rowIndex;
  2228. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2229. {
  2230. index--;
  2231. }
  2232. return index;
  2233. }
  2234. #endregion
  2235. #region 团组&签证
  2236. /// <summary>
  2237. /// 根据团组Id获取签证客户信息List
  2238. /// </summary>
  2239. /// <param name="dto">请求dto</param>
  2240. /// <returns></returns>
  2241. [HttpPost]
  2242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2243. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2244. {
  2245. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2246. if (groupData.Code != 0)
  2247. {
  2248. return Ok(JsonView(false, groupData.Msg));
  2249. }
  2250. return Ok(JsonView(groupData.Data));
  2251. }
  2252. /// <summary>
  2253. /// IOS获取团组签证拍照上传进度01(团组列表)
  2254. /// </summary>
  2255. /// <param name="dto">请求dto</param>
  2256. /// <returns></returns>
  2257. [HttpPost]
  2258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2259. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2260. {
  2261. if (dto == null)
  2262. {
  2263. return Ok(JsonView(false, "参数为空"));
  2264. }
  2265. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2266. return Ok(JsonView(visaList));
  2267. }
  2268. /// <summary>
  2269. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2270. /// </summary>
  2271. /// <returns></returns>
  2272. [HttpPost]
  2273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2274. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2275. {
  2276. if (dto == null)
  2277. {
  2278. return Ok(JsonView(false, "请求错误:"));
  2279. }
  2280. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2281. return Ok(JsonView(list));
  2282. }
  2283. /// <summary>
  2284. /// IOS获取团组签证拍照上传进度03(相册)
  2285. /// </summary>
  2286. /// <returns></returns>
  2287. [HttpPost]
  2288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2289. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2290. {
  2291. if (dto == null)
  2292. {
  2293. return Ok(JsonView(false, "请求错误:"));
  2294. }
  2295. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2296. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2297. list.ForEach(s => s.url = url);
  2298. return Ok(JsonView(list));
  2299. }
  2300. /// <summary>
  2301. /// IOS获取团组签证拍照上传进度04(图片上传)
  2302. /// </summary>
  2303. /// <param name="dto"></param>
  2304. /// <returns></returns>
  2305. [HttpPost]
  2306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2307. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2308. {
  2309. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2310. //if (!string.IsNullOrEmpty(result))
  2311. //{
  2312. //}
  2313. //else {
  2314. // return Ok(JsonView(false, "上传失败"));
  2315. //}
  2316. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2317. int sucNum = 0;
  2318. try
  2319. {
  2320. foreach (var item in dto.base64DataList)
  2321. {
  2322. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2323. string result = DecodeBase64ToImage(item, imageName);
  2324. if (!string.IsNullOrEmpty(result))
  2325. {
  2326. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2327. pic.CreateUserId = dto.CreateUserId;
  2328. pic.PicName = imageName;
  2329. pic.PicPath = result;
  2330. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2331. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2332. if (insertResult > 0)
  2333. {
  2334. sucNum++;
  2335. }
  2336. }
  2337. }
  2338. }
  2339. catch (Exception ex)
  2340. {
  2341. return Ok(JsonView(false, ex.Message));
  2342. }
  2343. string msg = string.Format(@"成功上传{0}张", sucNum);
  2344. return Ok(JsonView(true, msg));
  2345. }
  2346. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2347. {
  2348. string filename = "";//声明一个string类型的相对路径
  2349. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2350. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2351. try//会有异常抛出,try,catch一下
  2352. {
  2353. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2354. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2355. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2356. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2357. //文件名称
  2358. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2359. //上传的文件的路径
  2360. string filePath = "";
  2361. if (!Directory.Exists(fileDir))
  2362. {
  2363. Directory.CreateDirectory(fileDir);
  2364. }
  2365. //上传的文件的路径
  2366. filePath = fileDir + filename;
  2367. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2368. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2369. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2370. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2371. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2372. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2373. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2374. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2375. bitmap.Dispose();
  2376. }
  2377. catch (Exception e)
  2378. {
  2379. string massage = e.Message;
  2380. Logs("IOS图片上传Error:" + massage);
  2381. //filename = e.Message;
  2382. }
  2383. return filename;//返回相对路径
  2384. }
  2385. /// <summary>
  2386. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2387. /// </summary>
  2388. /// <param name="dto"></param>
  2389. /// <returns></returns>
  2390. [HttpPost]
  2391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2392. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2393. {
  2394. if (dto == null)
  2395. {
  2396. return Ok(JsonView(false, "请求错误:"));
  2397. }
  2398. string msg = "参数错误";
  2399. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2400. {
  2401. try
  2402. {
  2403. //_delegationVisaRep.BeginTran();
  2404. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2405. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2406. .Where(s => s.Id == dto.visaProgressCustomerId)
  2407. .ExecuteCommandAsync();
  2408. if (updCount > 0 && dto.publishCode == 1)
  2409. {
  2410. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2411. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2412. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2413. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2414. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2415. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2416. if (groupData == null)
  2417. {
  2418. _delegationVisaRep.RollbackTran();
  2419. }
  2420. string title = string.Format(@"[签证进度更新]");
  2421. string content = string.Format(@"测试文本");
  2422. bool rst = await _message.AddMsg(new MessageDto()
  2423. {
  2424. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2425. IssuerId = dto.publisher,
  2426. Title = title,
  2427. Content = content,
  2428. ReleaseTime = DateTime.Now,
  2429. UIdList = new List<int> {
  2430. 234
  2431. }
  2432. });
  2433. if (rst)
  2434. {
  2435. return Ok(JsonView(true, "发送通知成功"));
  2436. }
  2437. }
  2438. //_delegationVisaRep.CommitTran();
  2439. }
  2440. catch (Exception)
  2441. {
  2442. //_delegationVisaRep.RollbackTran();
  2443. }
  2444. }
  2445. return Ok(JsonView(true, msg));
  2446. }
  2447. #endregion
  2448. #region 团组任务分配
  2449. /// <summary>
  2450. /// 团组任务分配初始化
  2451. /// </summary>
  2452. /// <returns></returns>
  2453. [HttpPost]
  2454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2455. public async Task<IActionResult> GetTaskAssignmen()
  2456. {
  2457. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2458. if (groupData.Code != 0)
  2459. {
  2460. return Ok(JsonView(false, groupData.Msg));
  2461. }
  2462. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2463. }
  2464. /// <summary>
  2465. /// 团组任务分配查询
  2466. /// </summary>
  2467. /// <param name="dto"></param>
  2468. /// <returns></returns>
  2469. [HttpPost]
  2470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2471. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2472. {
  2473. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2474. if (groupData.Code != 0)
  2475. {
  2476. return Ok(JsonView(false, groupData.Msg));
  2477. }
  2478. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2479. }
  2480. /// <summary>
  2481. /// 团组任务分配操作
  2482. /// </summary>
  2483. /// <param name="dto"></param>
  2484. /// <returns></returns>
  2485. [HttpPost]
  2486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2487. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2488. {
  2489. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2490. if (groupData.Code != 0)
  2491. {
  2492. return Ok(JsonView(false, groupData.Msg));
  2493. }
  2494. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2495. }
  2496. /// <summary>
  2497. /// 团组任务分配
  2498. /// 批量分配
  2499. /// 查询团组
  2500. /// </summary>
  2501. /// <param name="dto"></param>
  2502. /// <returns></returns>
  2503. [HttpPost]
  2504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2505. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2506. {
  2507. //参数验证
  2508. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2509. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2510. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2511. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2512. }
  2513. /// <summary>
  2514. /// 团组任务分配
  2515. /// 批量分配
  2516. /// </summary>
  2517. /// <param name="dto"></param>
  2518. /// <returns></returns>
  2519. [HttpPost]
  2520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2521. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2522. {
  2523. //参数验证
  2524. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2525. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2526. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2527. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2528. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2529. }
  2530. #endregion
  2531. #region 团组费用审核
  2532. /// <summary>
  2533. /// 费用审核
  2534. /// 团组列表 Page
  2535. /// </summary>
  2536. /// <param name="_dto">团组列表请求dto</param>
  2537. /// <returns></returns>
  2538. [HttpPost]
  2539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2540. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2541. {
  2542. #region 参数验证
  2543. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2544. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2545. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2546. #region 页面操作权限验证
  2547. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2548. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2549. #endregion
  2550. #endregion
  2551. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2552. {
  2553. string sqlWhere = string.Empty;
  2554. if (_dto.IsSure == 0) //未完成
  2555. {
  2556. sqlWhere += string.Format(@" And IsSure = 0");
  2557. }
  2558. else if (_dto.IsSure == 1) //已完成
  2559. {
  2560. sqlWhere += string.Format(@" And IsSure = 1");
  2561. }
  2562. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2563. {
  2564. string tj = _dto.SearchCriteria;
  2565. 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}%')",
  2566. tj, tj, tj, tj, tj);
  2567. }
  2568. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2569. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2570. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2571. From (
  2572. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2573. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2574. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2575. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2576. From Grp_DelegationInfo gdi
  2577. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2578. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2579. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2580. Where gdi.IsDel = 0 {0}
  2581. ) temp ", sqlWhere);
  2582. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2583. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2584. var _view = new
  2585. {
  2586. PageFuncAuth = pageFunAuthView,
  2587. Data = _DelegationList
  2588. };
  2589. return Ok(JsonView(true, "查询成功!", _view, total));
  2590. }
  2591. else
  2592. {
  2593. return Ok(JsonView(false, "查询失败"));
  2594. }
  2595. }
  2596. /// <summary>
  2597. /// 获取团组费用审核
  2598. /// </summary>
  2599. /// <param name="_dto"></param>
  2600. /// <returns></returns>
  2601. [HttpPost]
  2602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2603. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2604. {
  2605. try
  2606. {
  2607. #region 参数验证
  2608. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2609. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2610. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2611. #region 页面操作权限验证
  2612. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2613. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2614. #endregion
  2615. #endregion
  2616. var _view = new Grp_CreditCardPaymentView();
  2617. var clientNameList = getSimplClientList(_dto.DiId);
  2618. #region 费用清单
  2619. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2620. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2621. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2622. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2623. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2624. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2625. /*
  2626. * 76://酒店预订
  2627. */
  2628. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2629. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2630. /*
  2631. * 79://车/导游地接
  2632. */
  2633. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2634. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2635. /*
  2636. * 80: //签证
  2637. */
  2638. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2639. /*
  2640. *81: //邀请/公务活动
  2641. */
  2642. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2643. /*
  2644. * 82: //团组客户保险
  2645. */
  2646. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2647. /*
  2648. * Lable = 85 机票预订
  2649. */
  2650. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2651. /*
  2652. * 85 机票预定
  2653. */
  2654. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2655. /*
  2656. * 98 其他款项
  2657. */
  2658. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2659. /*
  2660. * 285:收款退还
  2661. */
  2662. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2663. /*
  2664. * 1015: //超支费用
  2665. */
  2666. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2667. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2668. /*
  2669. * 币种信息
  2670. */
  2671. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2672. /*
  2673. * 车/导游地接 费用类型
  2674. */
  2675. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2676. /*
  2677. * 车/导游地接 费用类型
  2678. */
  2679. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2680. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2681. /*
  2682. * 用户信息
  2683. */
  2684. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2685. /*
  2686. * 费用模块
  2687. */
  2688. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2689. string priceModule = string.Empty;
  2690. if (sdPriceName != null)
  2691. {
  2692. priceModule = sdPriceName.Name;
  2693. }
  2694. /*
  2695. * 成本信息
  2696. */
  2697. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2698. decimal _groupRate = 0.0000M;
  2699. string _groupCurrencyCode = "-";
  2700. if (groupCost != null)
  2701. {
  2702. _groupRate = groupCost.Rate;
  2703. if (int.TryParse(groupCost.Currency, out int _currency))
  2704. {
  2705. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2706. }
  2707. else _groupCurrencyCode = groupCost.Currency;
  2708. }
  2709. string costContentSql = $"Select * From Grp_GroupCost";
  2710. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2711. //处理日期为空的天数
  2712. for (int i = 0; i < groupCostDetails.Count; i++)
  2713. if (i != 0)
  2714. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2715. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2716. /*
  2717. * 处理详情数据
  2718. */
  2719. foreach (var entity in entityList)
  2720. {
  2721. var _detail = new Grp_CreditCardPaymentDetailView();
  2722. _detail.Id = entity.Id;
  2723. _detail.PriceName = priceModule;
  2724. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2725. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2726. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2727. //处理金额
  2728. if (entity.CTable == 1015)
  2729. {
  2730. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2731. if (czInfo != null)
  2732. {
  2733. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2734. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2735. }
  2736. }
  2737. /*
  2738. * 应付款金额
  2739. */
  2740. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2741. string PaymentCurrency_WaitPay = "Unknown";
  2742. string hotelCurrncyCode = "Unknown";
  2743. string hotelCurrncyName = "Unknown";
  2744. if (sdPaymentCurrency_WaitPay != null)
  2745. {
  2746. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2747. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2748. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2749. if (hotelCurrncyCode.Equals("CNY"))
  2750. {
  2751. entity.DayRate = 1.0000M;
  2752. }
  2753. }
  2754. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2755. /*
  2756. * 此次付款金额
  2757. */
  2758. decimal CurrPayStr = 0.00M,
  2759. OriginalCurrPay = 0.00M;
  2760. if (entity.PayPercentage == 0)
  2761. {
  2762. if (entity.PayThenMoney != 0)
  2763. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2764. }
  2765. else
  2766. {
  2767. if (entity.PayMoney != 0)
  2768. {
  2769. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2770. }
  2771. }
  2772. //if (_dto.Label == 79)
  2773. //{
  2774. // string original = string.Empty;
  2775. // if (hotelCurrncyCode.Equals("CNY"))
  2776. // {
  2777. // OriginalCurrPay = CurrPayStr;
  2778. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2779. // }
  2780. // else
  2781. // {
  2782. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2783. // //760 EUR(7600.00 CNY)
  2784. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2785. // }
  2786. //}
  2787. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2788. string original = string.Empty;
  2789. if (hotelCurrncyCode.Equals("CNY"))
  2790. {
  2791. OriginalCurrPay = CurrPayStr;
  2792. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2793. }
  2794. else
  2795. {
  2796. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2797. //760 EUR(7600.00 CNY)
  2798. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2799. }
  2800. /*
  2801. * 剩余尾款
  2802. */
  2803. decimal BalanceStr = 0;
  2804. if (CurrPayStr != 0)
  2805. {
  2806. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2807. BalanceStr = 0;
  2808. else
  2809. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2810. }
  2811. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2812. /*
  2813. * Bus名称
  2814. */
  2815. _detail.BusName = "待增加";
  2816. /*
  2817. *费用所属
  2818. */
  2819. switch (entity.CTable)
  2820. {
  2821. case 76://酒店预订
  2822. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2823. if (hotelReservations != null)
  2824. {
  2825. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2826. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2827. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2828. string roomFeeStr = "", roomFeestr1 = "";
  2829. //是否比较房型价格
  2830. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2831. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2832. roomFeeStr += $"<br/>";
  2833. var roomTotal = 0.00M;
  2834. if (hotelReservations.SingleRoomPrice > 0)
  2835. {
  2836. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2837. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2838. //__isSingle = true;
  2839. roomTotal += fee;
  2840. }
  2841. if (hotelReservations.DoubleRoomPrice > 0)
  2842. {
  2843. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2844. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2845. // __isDouble = true;
  2846. roomTotal += fee;
  2847. }
  2848. if (hotelReservations.SuiteRoomPrice > 0)
  2849. {
  2850. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2851. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2852. //__isSuite = true;
  2853. roomTotal += fee;
  2854. }
  2855. if (hotelReservations.OtherRoomPrice > 0)
  2856. {
  2857. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2858. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2859. //__isOther = true;
  2860. roomTotal += fee;
  2861. }
  2862. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2863. else roomFeeStr += " 0.00 * 0";
  2864. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2865. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2866. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2867. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2868. /*
  2869. * 费用类型
  2870. * 1:房费
  2871. * 2:早餐
  2872. * 3:地税
  2873. * 4:城市税
  2874. * </summary>
  2875. */
  2876. //地税
  2877. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2878. if (governmentRentData != null)
  2879. {
  2880. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2881. governmentRentFee = governmentRentData.Price;
  2882. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2883. if (governmentRentCurrData != null)
  2884. {
  2885. governmentRentCode = governmentRentCurrData.Name;
  2886. governmentRentName = $"({governmentRentCurrData.Remark})";
  2887. }
  2888. }
  2889. //城市税
  2890. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2891. if (cityTaxData != null)
  2892. {
  2893. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2894. cityTaxFee = cityTaxData.Price;
  2895. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2896. if (cityTaxCurrData != null)
  2897. {
  2898. cityTaxCode = cityTaxCurrData.Name;
  2899. cityTaxName = $"({cityTaxCurrData.Remark})";
  2900. }
  2901. }
  2902. //酒店早餐
  2903. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2904. if (breakfastData != null)
  2905. {
  2906. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2907. breakfastFee = breakfastData.Price;
  2908. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2909. if (breakfastCurrData != null)
  2910. {
  2911. breakfastCode = breakfastCurrData.Name;
  2912. breakfastName = $"({breakfastCurrData.Remark})";
  2913. }
  2914. }
  2915. //房间费用
  2916. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2917. if (roomData != null)
  2918. {
  2919. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2920. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2921. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2922. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2923. roomFee = roomData.Price;
  2924. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2925. if (roomCurrData != null)
  2926. {
  2927. roomCode = roomCurrData.Name;
  2928. roomName = $"({roomCurrData.Remark})";
  2929. }
  2930. }
  2931. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2932. string hotelCostStr = "";
  2933. decimal hotelCsotTotal = 0.00M;
  2934. if (groupCost != null)
  2935. {
  2936. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2937. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2938. }
  2939. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2940. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2941. string hotelCost_day = "";
  2942. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2943. foreach (var item in hotelCostDetails1)
  2944. {
  2945. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2946. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2947. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2948. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2949. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2950. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2951. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2952. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2953. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2954. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2955. hotelCost_day += @$"<br/>";
  2956. }
  2957. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2958. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2959. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2960. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2961. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2962. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2963. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2964. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2965. $"房间说明: {hotelReservations.Remark} <br/>" +
  2966. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2967. $"{hotelBreakfastStr}" +
  2968. $"{hotelGovernmentRentStr}" +
  2969. $"{hotelCityTaxStr}";
  2970. _detail.PriceNameContent = hotelReservations.HotelName;
  2971. }
  2972. break;
  2973. case 79://车/导游地接
  2974. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2975. if (touristGuideGroundReservations != null)
  2976. {
  2977. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2978. {
  2979. _detail.BusName = touristGuideGroundReservations.BusName;
  2980. }
  2981. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2982. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2983. //if (isInt)
  2984. //{
  2985. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2986. // if (cityInfo != null)
  2987. // {
  2988. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2989. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2990. // if (carFeeItem != null)
  2991. // {
  2992. // nameContent += $@"({carFeeItem.Name})";
  2993. // }
  2994. // _detail.PriceNameContent = nameContent;
  2995. // }
  2996. //}
  2997. //else
  2998. //{
  2999. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3000. //}
  3001. var touristGuideGroundReservationsContents =
  3002. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3003. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3004. foreach (var item in touristGuideGroundReservationsContents)
  3005. {
  3006. string typeName = "Unknown";
  3007. string carCurrencyCode = "Unknown";
  3008. string carCurrencyName = "Unknown";
  3009. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3010. if (carTypeData != null) typeName = carTypeData.Name;
  3011. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3012. if (currencyData != null)
  3013. {
  3014. carCurrencyCode = currencyData.Name;
  3015. carCurrencyName = currencyData.Remark;
  3016. }
  3017. //op、成本 币种是否一致
  3018. bool IsCurrencyAgreement = false;
  3019. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3020. string opCostStr = string.Empty;
  3021. decimal opCostTypePrice = 0.00M;
  3022. #region 处理成本各项费用
  3023. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3024. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3025. if (opCost.Count > 0)
  3026. {
  3027. switch (item.SId)
  3028. {
  3029. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3030. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3031. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3032. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3033. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3034. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3035. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3036. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3037. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3038. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3039. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3040. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3041. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3042. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3043. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3044. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3045. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3046. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3047. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3048. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3049. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3050. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3051. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3052. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3053. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3054. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3055. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3056. }
  3057. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  3058. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  3059. }
  3060. #endregion
  3061. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  3062. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  3063. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3064. $"{opTypeStr} {opCostStr}<br/>" +
  3065. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3066. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3067. }
  3068. _detail.PriceMsgContent = priceMsg;
  3069. }
  3070. break;
  3071. case 80: //签证
  3072. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3073. if (visaInfo != null)
  3074. {
  3075. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3076. _detail.PriceNameContent = visaInfo.VisaDescription;
  3077. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3078. }
  3079. break;
  3080. case 81: //邀请/公务活动
  3081. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3082. if (_ioa != null)
  3083. {
  3084. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3085. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3086. sendCurrName = "Unknown", //快递费用币种 Name
  3087. sendCurrCode = "Unknown", //快递费用币种 Code
  3088. eventsCurrName = "Unknown", //公务活动费币种 Name
  3089. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3090. translateCurrName = "Unknown", //公务翻译费 Name
  3091. translateCurrCode = "Unknown"; //公务翻译费 Code
  3092. #region 处理费用币种
  3093. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3094. if (inviteCurrData != null)
  3095. {
  3096. inviteCurrName = inviteCurrData.Remark;
  3097. inviteCurrCode = inviteCurrData.Name;
  3098. }
  3099. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3100. if (sendCurrData != null)
  3101. {
  3102. sendCurrName = sendCurrData.Remark;
  3103. sendCurrCode = sendCurrData.Name;
  3104. }
  3105. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3106. if (eventsCurrData != null)
  3107. {
  3108. eventsCurrName = eventsCurrData.Remark;
  3109. eventsCurrCode = eventsCurrData.Name;
  3110. }
  3111. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3112. if (translateCurrData != null)
  3113. {
  3114. translateCurrName = translateCurrData.Remark;
  3115. translateCurrCode = translateCurrData.Name;
  3116. }
  3117. #endregion
  3118. _detail.PriceNameContent = _ioa.InviterArea;
  3119. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3120. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3121. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3122. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3123. $@"备注:" + _ioa.Remark + "<br/>";
  3124. }
  3125. break;
  3126. case 82: //团组客户保险
  3127. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3128. if (customers != null)
  3129. {
  3130. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3131. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3132. }
  3133. break;
  3134. case 85: //机票预订
  3135. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3136. if (jpRes != null)
  3137. {
  3138. string FlightsDescription = jpRes.FlightsDescription;
  3139. string PriceDescription = jpRes.PriceDescription;
  3140. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3141. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3142. }
  3143. break;
  3144. case 98://其他款项
  3145. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3146. if (gdpRes != null)
  3147. {
  3148. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3149. _detail.PriceNameContent = gdpRes.PriceName;
  3150. }
  3151. break;
  3152. case 285://收款退还
  3153. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3154. if (refundAndOtherMoney != null)
  3155. {
  3156. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3157. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3158. }
  3159. break;
  3160. case 751://酒店早餐
  3161. break;
  3162. case 1015://超支费用
  3163. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3164. if (groupExtraCost != null)
  3165. {
  3166. _detail.PriceNameContent = groupExtraCost.PriceName;
  3167. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3168. }
  3169. break;
  3170. default:
  3171. break;
  3172. }
  3173. /*
  3174. * 申请人
  3175. */
  3176. string operatorName = " - ";
  3177. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3178. if (_opUser != null)
  3179. {
  3180. operatorName = _opUser.CnName;
  3181. }
  3182. _detail.OperatorName = operatorName;
  3183. /*
  3184. * 审核人
  3185. */
  3186. string auditOperatorName = "Unknown";
  3187. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3188. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3189. else
  3190. {
  3191. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3192. if (_adUser != null)
  3193. {
  3194. auditOperatorName = _adUser.CnName;
  3195. }
  3196. }
  3197. _detail.AuditOperatorName = auditOperatorName;
  3198. /*
  3199. * 超预算比例
  3200. */
  3201. string overBudgetStr = "";
  3202. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3203. else if (entity.ExceedBudget == 0)
  3204. {
  3205. if (entity.CTable == 76 || entity.CTable == 79)
  3206. {
  3207. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3208. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3209. }
  3210. else
  3211. {
  3212. overBudgetStr = "未超预算";
  3213. }
  3214. }
  3215. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3216. _detail.OverBudget = overBudgetStr;
  3217. decimal auditFee = 0.00M; //已审核金额 人名币
  3218. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3219. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3220. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3221. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3222. {
  3223. auditedFeeOriginal = entity.PayMoney;
  3224. auditFee = CurrPayStr;
  3225. }
  3226. else if (entity.IsAuditGM == 0)
  3227. {
  3228. unAuditFeeCNY = CurrPayStr;
  3229. unAuditFeeOriginal = OriginalCurrPay;
  3230. OriginalCurrPay = 0.00M;
  3231. }
  3232. /*
  3233. * 费用总计
  3234. */
  3235. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3236. {
  3237. CurrencyId = entity.PaymentCurrency,
  3238. CurrencyName = PaymentCurrency_WaitPay,
  3239. AmountPayable = entity.PayMoney,
  3240. ThisPayment = OriginalCurrPay,
  3241. BalancePayment = BalanceStr,
  3242. AuditedFunds = auditFee,
  3243. AuditedFundsOriginal = auditedFeeOriginal,
  3244. UnAuditFundsCNY = unAuditFeeCNY,
  3245. UnAuditFundsOriginal = unAuditFeeOriginal
  3246. });
  3247. _detail.IsAuditGM = entity.IsAuditGM;
  3248. detailList.Add(_detail);
  3249. }
  3250. #endregion
  3251. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3252. /*
  3253. * 下方描述处理
  3254. */
  3255. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3256. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3257. if (ccpCurrencyPrice != null)
  3258. {
  3259. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3260. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3261. }
  3262. else
  3263. {
  3264. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3265. }
  3266. string amountPayableStr = string.Format(@"应付款总金额: ");
  3267. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3268. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3269. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3270. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3271. foreach (var item in nonDuplicat)
  3272. {
  3273. var currencyName = item.CurrencyName;
  3274. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3275. if (strs.Count > 0)
  3276. {
  3277. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3278. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3279. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3280. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3281. //单独处理此次付款金额
  3282. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3283. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3284. //单独处理已审核费用
  3285. //if (item.CurrencyId == 836) //人民币
  3286. //{
  3287. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3288. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3289. //}
  3290. //else
  3291. //{
  3292. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3293. //}
  3294. if (currencyName.Equals("CNY"))
  3295. {
  3296. //已审核费用
  3297. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3298. //未审核费用
  3299. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3300. }
  3301. else
  3302. {
  3303. //已审核费用
  3304. 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"));
  3305. //未审核费用
  3306. 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"));
  3307. }
  3308. }
  3309. }
  3310. _view.TotalStr1 = amountPayableStr[..^1];
  3311. _view.TotalStr2 = thisPaymentStr[..^1];
  3312. _view.TotalStr3 = balancePaymentStr[..^1];
  3313. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3314. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3315. var _view1 = new
  3316. {
  3317. PageFuncAuth = pageFunAuthView,
  3318. Data = _view
  3319. };
  3320. return Ok(JsonView(_view1));
  3321. }
  3322. catch (Exception ex)
  3323. {
  3324. return Ok(JsonView(false, ex.Message));
  3325. }
  3326. }
  3327. /// <summary>
  3328. /// 费用审核
  3329. /// 修改团组费用审核状态
  3330. /// </summary>
  3331. /// <param name="_dto">参数Json字符串</param>
  3332. /// <returns></returns>
  3333. [HttpPost]
  3334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3335. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3336. {
  3337. #region 参数验证
  3338. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3339. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3340. #endregion
  3341. #region 页面操作权限验证
  3342. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3343. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3344. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3345. #endregion
  3346. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3347. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3348. DateTime dtNow = DateTime.Now;
  3349. _groupRepository.BeginTran();
  3350. int rst = 0;
  3351. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3352. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3353. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3354. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3355. List<dynamic> msgDatas = new List<dynamic>();
  3356. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3357. foreach (var item in idList)
  3358. {
  3359. int CreditId = int.Parse(item);
  3360. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3361. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3362. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3363. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3364. .Where(s => s.Id == CreditId)
  3365. .ExecuteCommandAsync();
  3366. if (result < 1)
  3367. {
  3368. rst = -1;
  3369. _groupRepository.RollbackTran();
  3370. return Ok(JsonView(false, "操作失败并回滚!"));
  3371. }
  3372. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3373. if (creditData != null)
  3374. {
  3375. #region 应用通知配置
  3376. try
  3377. {
  3378. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3379. }
  3380. catch (Exception ex)
  3381. {
  3382. }
  3383. #endregion
  3384. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3385. string groupNameStr = string.Empty;
  3386. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3387. if (groupData != null) groupNameStr = groupData.TeamName;
  3388. string creditTypeStr = string.Empty;
  3389. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3390. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3391. string creditCurrency = string.Empty;
  3392. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3393. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3394. if (creditCurrency.Equals("CNY"))
  3395. {
  3396. creditData.DayRate = 1.0000M;
  3397. }
  3398. if (creditData.PayPercentage == 0.00M)
  3399. {
  3400. creditData.PayPercentage = 100M;
  3401. }
  3402. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3403. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3404. string msgContent = "";
  3405. if (creditCurrency.Equals("CNY"))
  3406. {
  3407. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3408. }
  3409. else
  3410. {
  3411. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3412. }
  3413. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3414. }
  3415. }
  3416. if (rst == 0)
  3417. {
  3418. _groupRepository.CommitTran();
  3419. foreach (var item in msgDatas)
  3420. {
  3421. //发送消息
  3422. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3423. }
  3424. #region 应用推送
  3425. try
  3426. {
  3427. foreach (var ccpId in dic_ccp_user.Keys)
  3428. {
  3429. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3430. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3431. }
  3432. }
  3433. catch (Exception)
  3434. {
  3435. }
  3436. #endregion
  3437. return Ok(JsonView(true, "操作成功!"));
  3438. }
  3439. return Ok(JsonView(false, "操作失败!"));
  3440. }
  3441. #endregion
  3442. #region 机票费用录入
  3443. /// <summary>
  3444. /// 机票录入当前登录人可操作团组
  3445. /// </summary>
  3446. /// <param name="dto"></param>
  3447. /// <returns></returns>
  3448. [HttpPost]
  3449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3450. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3451. {
  3452. try
  3453. {
  3454. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3455. if (groupData.Code != 0)
  3456. {
  3457. return Ok(JsonView(false, groupData.Msg));
  3458. }
  3459. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3460. }
  3461. catch (Exception ex)
  3462. {
  3463. return Ok(JsonView(false, "程序错误!"));
  3464. throw;
  3465. }
  3466. }
  3467. /// <summary>
  3468. /// 机票费用录入列表
  3469. /// </summary>
  3470. /// <param name="dto"></param>
  3471. /// <returns></returns>
  3472. [HttpPost]
  3473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3474. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3475. {
  3476. try
  3477. {
  3478. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3479. if (groupData.Code != 0)
  3480. {
  3481. return Ok(JsonView(false, groupData.Msg));
  3482. }
  3483. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3484. }
  3485. catch (Exception ex)
  3486. {
  3487. return Ok(JsonView(false, ex.Message));
  3488. throw;
  3489. }
  3490. }
  3491. /// <summary>
  3492. /// 根据id查询费用录入信息
  3493. /// </summary>
  3494. /// <param name="dto"></param>
  3495. /// <returns></returns>
  3496. [HttpPost]
  3497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3498. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3499. {
  3500. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3501. if (groupData.Code != 0)
  3502. {
  3503. return Ok(JsonView(false, groupData.Msg));
  3504. }
  3505. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3506. }
  3507. /// <summary>
  3508. /// 机票费用录入操作(Status:1.新增,2.修改)
  3509. /// </summary>
  3510. /// <param name="dto"></param>
  3511. /// <returns></returns>
  3512. [HttpPost]
  3513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3514. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3515. {
  3516. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3517. if (groupData.Code != 0)
  3518. {
  3519. return Ok(JsonView(false, groupData.Msg));
  3520. }
  3521. #region 应用推送
  3522. try
  3523. {
  3524. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3525. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3526. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3527. //2024-10-21 新增LZ UID
  3528. var userIds = new List<int>() { 21 };
  3529. string title = $"系统通知";
  3530. string content = "";
  3531. var diId = dto.AirTicketResOpData.DiId;
  3532. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3533. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3534. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3535. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3536. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3537. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3538. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3539. }
  3540. catch (Exception ex)
  3541. {
  3542. }
  3543. #endregion
  3544. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3545. }
  3546. /// <summary>
  3547. /// 根据舱位类型查询接团客户名单信息
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3553. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3554. {
  3555. try
  3556. {
  3557. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3558. if (crm_Groups.Count != 0)
  3559. {
  3560. List<dynamic> Customer = new List<dynamic>();
  3561. foreach (var item in crm_Groups)
  3562. {
  3563. var data = new
  3564. {
  3565. Id = item.Id,
  3566. Pinyin = item.Pinyin,
  3567. Name = item.LastName + item.FirstName
  3568. };
  3569. Customer.Add(data);
  3570. }
  3571. return Ok(JsonView(true, "查询成功!", Customer));
  3572. }
  3573. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3574. }
  3575. catch (Exception ex)
  3576. {
  3577. return Ok(JsonView(false, "程序错误!"));
  3578. throw;
  3579. }
  3580. }
  3581. /// <summary>
  3582. /// 根据团号获取客户信息
  3583. /// </summary>
  3584. /// <param name="dto"></param>
  3585. /// <returns></returns>
  3586. [HttpPost]
  3587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3588. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3589. {
  3590. var jw = JsonView(false);
  3591. if (dto.DIID < 1)
  3592. {
  3593. jw.Msg += "请输入正确的diid";
  3594. return Ok(jw);
  3595. }
  3596. var arr = getSimplClientList(dto.DIID);
  3597. jw = JsonView(true, "获取成功!", arr);
  3598. return Ok(jw);
  3599. }
  3600. private List<SimplClientInfo> getSimplClientList(int diId)
  3601. {
  3602. 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);
  3603. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3604. foreach (var item in arr)
  3605. {
  3606. EncryptionProcessor.DecryptProperties(item);
  3607. }
  3608. return arr;
  3609. }
  3610. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3611. {
  3612. string result = origin;
  3613. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3614. {
  3615. string[] temparr = origin.Split(',');
  3616. string fistrStr = temparr[0];
  3617. int count = temparr.Count();
  3618. int tempId;
  3619. bool success = int.TryParse(fistrStr, out tempId);
  3620. if (success)
  3621. {
  3622. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3623. if (tempInfo != null)
  3624. {
  3625. if (count > 1)
  3626. {
  3627. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3628. }
  3629. else
  3630. {
  3631. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3632. }
  3633. }
  3634. }
  3635. }
  3636. return result;
  3637. }
  3638. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3639. {
  3640. string result = origin;
  3641. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3642. {
  3643. string[] temparr = origin.Split(',');
  3644. result = "";
  3645. foreach (var item in temparr)
  3646. {
  3647. int tempId;
  3648. bool success = int.TryParse(item, out tempId);
  3649. if (success)
  3650. {
  3651. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3652. if (tempInfo != null)
  3653. {
  3654. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3655. }
  3656. }
  3657. }
  3658. }
  3659. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3660. return result;
  3661. }
  3662. /// <summary>
  3663. /// 机票费用录入,删除
  3664. /// </summary>
  3665. /// <param name="dto"></param>
  3666. /// <returns></returns>
  3667. [HttpPost]
  3668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3669. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3670. {
  3671. try
  3672. {
  3673. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3674. if (res)
  3675. {
  3676. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3677. {
  3678. IsDel = 1,
  3679. DeleteUserId = dto.DeleteUserId,
  3680. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3681. }).ExecuteCommandAsync();
  3682. return Ok(JsonView(true, "删除成功!"));
  3683. }
  3684. return Ok(JsonView(false, "删除失败!"));
  3685. }
  3686. catch (Exception ex)
  3687. {
  3688. return Ok(JsonView(false, "程序错误!"));
  3689. throw;
  3690. }
  3691. }
  3692. /// <summary>
  3693. /// 导出机票录入报表
  3694. /// </summary>
  3695. /// <param name="dto"></param>
  3696. /// <returns></returns>
  3697. [HttpPost]
  3698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3699. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3700. {
  3701. try
  3702. {
  3703. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3704. if (groupData.Code != 0)
  3705. {
  3706. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3707. }
  3708. else
  3709. {
  3710. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3711. if (AirTicketReservations.Count != 0)
  3712. {
  3713. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3714. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3715. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3716. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3717. WorkbookDesigner designer = new WorkbookDesigner();
  3718. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3719. decimal countCost = 0;
  3720. foreach (var item in AirTicketReservations)
  3721. {
  3722. #region 处理客人姓名
  3723. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3724. item.ClientName = clientNames;
  3725. #endregion
  3726. if (item.BankType == "其他")
  3727. {
  3728. item.BankNo = "--";
  3729. }
  3730. else
  3731. {
  3732. if (!string.IsNullOrEmpty(item.BankType))
  3733. {
  3734. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3735. }
  3736. }
  3737. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3738. item.Price = System.Decimal.Round(item.Price, 2);
  3739. countCost += Convert.ToDecimal(item.Price);
  3740. }
  3741. designer.SetDataSource("Export", AirTicketReservations);
  3742. designer.SetDataSource("ExportDiCode", diCode);
  3743. designer.SetDataSource("ExportDiName", diName);
  3744. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3745. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3746. designer.Process();
  3747. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3748. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3749. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3750. return Ok(JsonView(true, "成功", url = rst));
  3751. }
  3752. else
  3753. {
  3754. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3755. }
  3756. }
  3757. }
  3758. catch (Exception ex)
  3759. {
  3760. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3761. throw;
  3762. }
  3763. }
  3764. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3765. /// <summary>
  3766. /// 行程单导出
  3767. /// </summary>
  3768. /// <param name="dto"></param>
  3769. /// <returns></returns>
  3770. [HttpPost]
  3771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3772. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3773. {
  3774. try
  3775. {
  3776. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3777. if (groupData.Code != 0)
  3778. {
  3779. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3780. }
  3781. else
  3782. {
  3783. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3784. if (dto.Language == "CN")
  3785. {
  3786. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3787. DocumentBuilder builder = new DocumentBuilder(doc);
  3788. int tableIndex = 0;//表格索引
  3789. //得到文档中的第一个表格
  3790. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3791. foreach (var item in _AirTicketReservations)
  3792. {
  3793. #region 处理固定数据
  3794. string[] FlightsCode = item.FlightsCode.Split('/');
  3795. if (FlightsCode.Length != 0)
  3796. {
  3797. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3798. if (_AirCompany != null)
  3799. {
  3800. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3801. }
  3802. else
  3803. {
  3804. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3805. }
  3806. }
  3807. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3808. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3809. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3810. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3811. string name = "";
  3812. foreach (string clientName in nameArray)
  3813. {
  3814. if (!name.Contains(clientName))
  3815. {
  3816. name += clientName + ",";
  3817. }
  3818. }
  3819. if (!string.IsNullOrWhiteSpace(name))
  3820. {
  3821. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3822. }
  3823. else
  3824. {
  3825. table.Range.Bookmarks["ClientName"].Text = "--";
  3826. }
  3827. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3828. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3829. table.Range.Bookmarks["JointTicket"].Text = "--";
  3830. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3831. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3832. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3833. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3834. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3835. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3836. #endregion
  3837. #region 循环数据处理
  3838. List<AirInfo> airs = new List<AirInfo>();
  3839. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3840. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3841. for (int i = 0; i < FlightsCode.Length; i++)
  3842. {
  3843. AirInfo air = new AirInfo();
  3844. string[] tempstr = DayArray[i]
  3845. .Replace("\r\n", string.Empty)
  3846. .Replace("\\r\\n", string.Empty)
  3847. .TrimStart().TrimEnd()
  3848. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3849. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3850. string starCity = "";
  3851. if (star_Three != null)
  3852. {
  3853. starCity = star_Three.AirPort;
  3854. }
  3855. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3856. string EndCity = "";
  3857. if (End_Three != null)
  3858. {
  3859. EndCity = End_Three.AirPort;
  3860. }
  3861. air.Destination = starCity + "/" + EndCity;
  3862. air.Flight = FlightsCode[i];
  3863. air.SeatingClass = item.CTypeName;
  3864. string dateTime = tempstr[2];
  3865. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3866. air.FlightDate = DateTemp;
  3867. air.DepartureTime = tempstr[5];
  3868. air.LandingTime = tempstr[6];
  3869. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3870. air.TicketStatus = "--";
  3871. air.Luggage = "--";
  3872. air.DepartureTerminal = "--";
  3873. air.LandingTerminal = "--";
  3874. airs.Add(air);
  3875. }
  3876. int row = 13;
  3877. for (int i = 0; i < airs.Count; i++)
  3878. {
  3879. if (airs.Count > 2)
  3880. {
  3881. for (int j = 0; j < airs.Count - 2; j++)
  3882. {
  3883. var CopyRow = table.Rows[12].Clone(true);
  3884. table.Rows.Add(CopyRow);
  3885. }
  3886. }
  3887. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3888. int index = 0;
  3889. foreach (PropertyInfo property in properties)
  3890. {
  3891. string value = property.GetValue(airs[i]).ToString();
  3892. Cell ishcel0 = table.Rows[row].Cells[index];
  3893. Paragraph p = new Paragraph(doc);
  3894. string s = value;
  3895. p.AppendChild(new Run(doc, s));
  3896. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3897. ishcel0.AppendChild(p);
  3898. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3899. index++;
  3900. }
  3901. row++;
  3902. }
  3903. #endregion
  3904. Paragraph lastParagraph = new Paragraph(doc);
  3905. //第一个表格末尾加段落
  3906. table.ParentNode.InsertAfter(lastParagraph, table);
  3907. //复制第一个表格
  3908. Table cloneTable = (Table)table.Clone(true);
  3909. //在文档末尾段落后面加入复制的表格
  3910. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3911. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3912. {
  3913. int rownewsIndex = 13;
  3914. for (int i = 0; i < 2; i++)
  3915. {
  3916. var CopyRow = table.Rows[12].Clone(true);
  3917. table.Rows.RemoveAt(13);
  3918. table.Rows.Add(CopyRow);
  3919. rownewsIndex++;
  3920. }
  3921. }
  3922. else
  3923. {
  3924. table.Rows.RemoveAt(12);
  3925. }
  3926. cloneTable.Rows.RemoveAt(12);
  3927. }
  3928. if (_AirTicketReservations.Count != 0)
  3929. {
  3930. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3931. if (FlightsCode.Length != 0)
  3932. {
  3933. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3934. if (_AirCompany != null)
  3935. {
  3936. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3937. }
  3938. else
  3939. {
  3940. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3941. }
  3942. }
  3943. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3944. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3945. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3946. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3947. string name = "";
  3948. foreach (string clientName in nameArray)
  3949. {
  3950. if (!name.Contains(clientName))
  3951. {
  3952. name += clientName + ",";
  3953. }
  3954. }
  3955. if (!string.IsNullOrWhiteSpace(name))
  3956. {
  3957. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3958. }
  3959. else
  3960. {
  3961. table.Range.Bookmarks["ClientName"].Text = "--";
  3962. }
  3963. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3964. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3965. table.Range.Bookmarks["JointTicket"].Text = "--";
  3966. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3967. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3968. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3969. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3970. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3971. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3972. }
  3973. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3974. //保存合并后的文档
  3975. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3976. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3977. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3978. return Ok(JsonView(true, "成功!", rst));
  3979. }
  3980. else
  3981. {
  3982. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3983. DocumentBuilder builder = new DocumentBuilder(doc);
  3984. int tableIndex = 0;//表格索引
  3985. //得到文档中的第一个表格
  3986. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3987. List<string> texts = new List<string>();
  3988. foreach (var item in _AirTicketReservations)
  3989. {
  3990. string[] FlightsCode = item.FlightsCode.Split('/');
  3991. if (FlightsCode.Length != 0)
  3992. {
  3993. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3994. if (_AirCompany != null)
  3995. {
  3996. if (!transDic.ContainsKey(_AirCompany.CnName))
  3997. {
  3998. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3999. }
  4000. }
  4001. else
  4002. {
  4003. if (!transDic.ContainsKey("--"))
  4004. {
  4005. transDic.Add("--", "--");
  4006. }
  4007. }
  4008. }
  4009. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4010. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4011. string name = "";
  4012. foreach (string clientName in nameArray)
  4013. {
  4014. name += clientName + ",";
  4015. }
  4016. if (!texts.Contains(name))
  4017. {
  4018. texts.Add(name);
  4019. }
  4020. List<AirInfo> airs = new List<AirInfo>();
  4021. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4022. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4023. for (int i = 0; i < FlightsCode.Length; i++)
  4024. {
  4025. AirInfo air = new AirInfo();
  4026. string[] tempstr = DayArray[i]
  4027. .Replace("\r\n", string.Empty)
  4028. .Replace("\\r\\n", string.Empty)
  4029. .TrimStart().TrimEnd()
  4030. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4031. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4032. if (star_Three != null)
  4033. {
  4034. if (!transDic.ContainsKey(star_Three.AirPort))
  4035. {
  4036. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4037. }
  4038. }
  4039. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4040. if (End_Three != null)
  4041. {
  4042. if (!transDic.ContainsKey(End_Three.AirPort))
  4043. {
  4044. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4045. }
  4046. }
  4047. if (!texts.Contains(item.CTypeName))
  4048. {
  4049. texts.Add(item.CTypeName);
  4050. }
  4051. }
  4052. }
  4053. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4054. if (transData.Count > 0)
  4055. {
  4056. foreach (TranslateResult item in transData)
  4057. {
  4058. if (!transDic.ContainsKey(item.Query))
  4059. {
  4060. transDic.Add(item.Query, item.Translation);
  4061. }
  4062. }
  4063. }
  4064. foreach (var item in _AirTicketReservations)
  4065. {
  4066. #region 处理固定数据
  4067. string[] FlightsCode = item.FlightsCode.Split('/');
  4068. if (FlightsCode.Length != 0)
  4069. {
  4070. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4071. if (_AirCompany != null)
  4072. {
  4073. string str = "--";
  4074. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4075. if (!string.IsNullOrEmpty(translateResult))
  4076. {
  4077. str = translateResult;
  4078. str = _airTicketResRep.Processing(str);
  4079. }
  4080. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4081. }
  4082. else
  4083. {
  4084. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4085. }
  4086. }
  4087. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4088. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4089. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4090. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4091. string names = "";
  4092. foreach (string clientName in nameArray)
  4093. {
  4094. names += clientName + ",";
  4095. }
  4096. if (!string.IsNullOrWhiteSpace(names))
  4097. {
  4098. string str = "--";
  4099. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4100. if (!string.IsNullOrEmpty(translateResult))
  4101. {
  4102. str = translateResult;
  4103. str = _airTicketResRep.Processing(str);
  4104. }
  4105. table.Range.Bookmarks["ClientName"].Text = str;
  4106. }
  4107. else
  4108. {
  4109. table.Range.Bookmarks["ClientName"].Text = "--";
  4110. }
  4111. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4112. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4113. table.Range.Bookmarks["JointTicket"].Text = "--";
  4114. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4115. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4116. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4117. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4118. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4119. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4120. #endregion
  4121. #region 循环数据处理
  4122. List<AirInfo> airs = new List<AirInfo>();
  4123. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4124. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4125. for (int i = 0; i < FlightsCode.Length; i++)
  4126. {
  4127. AirInfo air = new AirInfo();
  4128. string[] tempstr = DayArray[i]
  4129. .Replace("\r\n", string.Empty)
  4130. .Replace("\\r\\n", string.Empty)
  4131. .TrimStart().TrimEnd()
  4132. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4133. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4134. string starCity = "";
  4135. if (star_Three != null)
  4136. {
  4137. string str2 = "--";
  4138. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4139. if (!string.IsNullOrEmpty(translateResult2))
  4140. {
  4141. str2 = translateResult2;
  4142. str2 = _airTicketResRep.Processing(str2);
  4143. }
  4144. starCity = str2;
  4145. }
  4146. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4147. string EndCity = "";
  4148. if (End_Three != null)
  4149. {
  4150. string str1 = "--";
  4151. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4152. if (!string.IsNullOrEmpty(translateResult1))
  4153. {
  4154. str1 = translateResult1;
  4155. str1 = _airTicketResRep.Processing(str1);
  4156. }
  4157. EndCity = str1;
  4158. }
  4159. air.Destination = starCity + "/" + EndCity;
  4160. air.Flight = FlightsCode[i];
  4161. string str = "--";
  4162. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4163. if (!string.IsNullOrEmpty(translateResult))
  4164. {
  4165. str = translateResult;
  4166. str = _airTicketResRep.Processing(str);
  4167. }
  4168. air.SeatingClass = str;
  4169. string dateTime = tempstr[2];
  4170. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4171. air.FlightDate = DateTemp;
  4172. air.DepartureTime = tempstr[5];
  4173. air.LandingTime = tempstr[6];
  4174. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4175. air.TicketStatus = "--";
  4176. air.Luggage = "--";
  4177. air.DepartureTerminal = "--";
  4178. air.LandingTerminal = "--";
  4179. airs.Add(air);
  4180. }
  4181. int row = 13;
  4182. for (int i = 0; i < airs.Count; i++)
  4183. {
  4184. if (airs.Count > 2)
  4185. {
  4186. for (int j = 0; j < airs.Count - 2; j++)
  4187. {
  4188. var CopyRow = table.Rows[12].Clone(true);
  4189. table.Rows.Add(CopyRow);
  4190. }
  4191. }
  4192. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4193. int index = 0;
  4194. foreach (PropertyInfo property in properties)
  4195. {
  4196. string value = property.GetValue(airs[i]).ToString();
  4197. Cell ishcel0 = table.Rows[row].Cells[index];
  4198. Paragraph p = new Paragraph(doc);
  4199. string s = value;
  4200. p.AppendChild(new Run(doc, s));
  4201. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4202. ishcel0.AppendChild(p);
  4203. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4204. //ishcel0.CellFormat.VerticalAlignment=
  4205. index++;
  4206. }
  4207. row++;
  4208. }
  4209. #endregion
  4210. Paragraph lastParagraph = new Paragraph(doc);
  4211. //第一个表格末尾加段落
  4212. table.ParentNode.InsertAfter(lastParagraph, table);
  4213. //复制第一个表格
  4214. Table cloneTable = (Table)table.Clone(true);
  4215. //在文档末尾段落后面加入复制的表格
  4216. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4217. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4218. {
  4219. int rownewsIndex = 13;
  4220. for (int i = 0; i < 2; i++)
  4221. {
  4222. var CopyRow = table.Rows[12].Clone(true);
  4223. table.Rows.RemoveAt(13);
  4224. table.Rows.Add(CopyRow);
  4225. rownewsIndex++;
  4226. }
  4227. }
  4228. else
  4229. {
  4230. table.Rows.RemoveAt(12);
  4231. }
  4232. cloneTable.Rows.RemoveAt(12);
  4233. }
  4234. if (_AirTicketReservations.Count != 0)
  4235. {
  4236. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4237. if (FlightsCode.Length != 0)
  4238. {
  4239. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4240. if (_AirCompany != null)
  4241. {
  4242. string str = "--";
  4243. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4244. if (!string.IsNullOrEmpty(translateResult))
  4245. {
  4246. str = translateResult;
  4247. str = _airTicketResRep.Processing(str);
  4248. }
  4249. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4250. }
  4251. else
  4252. {
  4253. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4254. }
  4255. }
  4256. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4257. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4258. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4259. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4260. string names = "";
  4261. foreach (string clientName in nameArray)
  4262. {
  4263. names += clientName + ",";
  4264. }
  4265. if (!string.IsNullOrWhiteSpace(names))
  4266. {
  4267. string str = "--";
  4268. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4269. if (!string.IsNullOrEmpty(translateResult))
  4270. {
  4271. str = translateResult;
  4272. str = _airTicketResRep.Processing(str);
  4273. }
  4274. table.Range.Bookmarks["ClientName"].Text = str;
  4275. }
  4276. else
  4277. {
  4278. table.Range.Bookmarks["ClientName"].Text = "--";
  4279. }
  4280. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4281. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4282. table.Range.Bookmarks["JointTicket"].Text = "--";
  4283. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4284. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4285. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4286. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4287. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4288. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4289. }
  4290. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4291. //保存合并后的文档
  4292. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4293. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4294. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4295. return Ok(JsonView(true, "成功!", rst));
  4296. }
  4297. }
  4298. }
  4299. catch (Exception ex)
  4300. {
  4301. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4302. throw;
  4303. }
  4304. }
  4305. #endregion
  4306. #region 团组增减款项 --> 其他款项
  4307. /// <summary>
  4308. /// 团组增减款项下拉框绑定
  4309. /// </summary>
  4310. /// <param name="dto"></param>
  4311. /// <returns></returns>
  4312. [HttpPost]
  4313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4314. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4315. {
  4316. #region 参数验证
  4317. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4318. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4319. #endregion
  4320. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4321. }
  4322. /// <summary>
  4323. /// 根据团组Id查询团组增减款项
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4330. {
  4331. #region 参数验证
  4332. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4333. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4334. #endregion
  4335. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4336. }
  4337. /// <summary>
  4338. /// 团组增减款项操作(Status:1.新增,2.修改)
  4339. /// </summary>
  4340. /// <param name="dto"></param>
  4341. /// <returns></returns>
  4342. [HttpPost]
  4343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4344. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4345. {
  4346. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4347. if (groupData.Code != 200)
  4348. {
  4349. return Ok(JsonView(false, groupData.Msg));
  4350. }
  4351. #region 应用推送
  4352. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4353. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4354. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4355. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4356. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4357. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4358. //自动审核
  4359. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4360. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4361. //2024-10-21 新增LZ UID
  4362. var userIds = new List<int>() { 21 };
  4363. string title = $"系统通知";
  4364. string content = "";
  4365. var diId = dto.DiId;
  4366. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4367. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4368. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4369. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4370. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4371. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4372. #endregion
  4373. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4374. }
  4375. /// <summary>
  4376. /// 团组增减款项操作 自动审核test
  4377. /// </summary>
  4378. /// <param name="groupId"></param>
  4379. /// <param name="dataId"></param>
  4380. /// <returns></returns>
  4381. [HttpPost]
  4382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4383. public async Task<IActionResult> DecreaseFeeAutomaticAudit(int groupId,int dataId)
  4384. {
  4385. //自动审核
  4386. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, groupId, dataId);
  4387. return Ok(autoAdit);
  4388. }
  4389. /// <summary>
  4390. /// 团组增减款项操作 删除
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4397. {
  4398. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4399. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4400. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4401. if (res.Code == 0)
  4402. {
  4403. return Ok(JsonView(true, "删除成功!"));
  4404. }
  4405. return Ok(JsonView(false, "删除失败!"));
  4406. }
  4407. /// <summary>
  4408. /// 根据团组增减款项Id查询
  4409. /// </summary>
  4410. /// <param name="dto"></param>
  4411. /// <returns></returns>
  4412. [HttpPost]
  4413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4414. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4415. {
  4416. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4417. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4418. }
  4419. /// <summary>
  4420. /// 查询供应商名称
  4421. /// </summary>
  4422. /// <param name="dto"></param>
  4423. /// <returns></returns>
  4424. [HttpPost]
  4425. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4426. {
  4427. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4428. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4429. ?? new List<Grp_DecreasePayments>();
  4430. dbResult = dbResult.Distinct(new
  4431. ProductComparer()).ToList();
  4432. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4433. {
  4434. x.Id,
  4435. x.SupplierAddress,
  4436. x.SupplierArea,
  4437. x.SupplierContact,
  4438. x.SupplierContactNumber,
  4439. x.SupplierEmail,
  4440. x.SupplierName,
  4441. x.SupplierSocialAccount,
  4442. x.SupplierTypeId,
  4443. }).ToList());
  4444. return Ok(jw);
  4445. }
  4446. /// <summary>
  4447. /// 团组增减款项 OTA匹配
  4448. /// </summary>
  4449. /// <param name="file"></param>
  4450. /// <returns></returns>
  4451. [HttpPost]
  4452. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4453. {
  4454. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4455. string fileName = file.FileName;
  4456. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4457. {
  4458. return Ok(JsonView(false, "请上传Excel文件!"));
  4459. }
  4460. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4461. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4462. if (!Directory.Exists(path))
  4463. {
  4464. Directory.CreateDirectory(path);
  4465. }
  4466. var filePath = @$"{path}/{fileName}";
  4467. //保存文件
  4468. using (FileStream fs = System.IO.File.Create(filePath))
  4469. {
  4470. file.CopyTo(fs);
  4471. fs.Flush();
  4472. }
  4473. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4474. //读取ExcelFile
  4475. DataTable dt = ConvertExcelToDataTable(filePath);
  4476. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4477. dt.TableName = "TB";
  4478. //修改table列名
  4479. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4480. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4481. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4482. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4483. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4484. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4485. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4486. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4487. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4488. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4489. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4490. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4491. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4492. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4493. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4494. var otaOrderNos = new List<string>();
  4495. foreach (DataRow item in dt.Rows)
  4496. {
  4497. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4498. }
  4499. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4500. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4501. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4502. .Select((dp, di) => new
  4503. {
  4504. dp.PriceName,
  4505. dp.OTAOrderNo,
  4506. dp.FeeTotal,
  4507. di.TeamName,
  4508. })
  4509. .ToListAsync();
  4510. foreach (DataRow item in dt.Rows)
  4511. {
  4512. var otaOrderNo = item["OTAOrderNo"].ToString();
  4513. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4514. if (oaData == null) continue;
  4515. item["GroupName"] = oaData.TeamName;
  4516. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4517. }
  4518. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4519. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4520. List<DataTable> datas = new List<DataTable>();
  4521. datas.Add(dt);
  4522. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4523. return Ok(JsonView(true, "操作成功", new { url = url }));
  4524. }
  4525. #region
  4526. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4527. {
  4528. // 创建Workbook对象
  4529. Workbook workbook = new Workbook(excelFilePath);
  4530. // 获取第一个工作表
  4531. Worksheet worksheet = workbook.Worksheets[0];
  4532. // 将工作表转换为DataTable
  4533. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4534. return dataTable;
  4535. }
  4536. #endregion
  4537. #endregion
  4538. #region 文件上传、删除
  4539. /// <summary>
  4540. /// region 文件上传 可以带参数
  4541. /// </summary>
  4542. /// <param name="file"></param>
  4543. /// <returns></returns>
  4544. [HttpPost]
  4545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4546. public async Task<IActionResult> UploadProject(IFormFile file)
  4547. {
  4548. //var TypeName = Request.Headers["TypeName"].ToString();
  4549. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4550. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4551. ////文件名称
  4552. //string projectFileName = file.FileName;
  4553. ////上传的文件的路径
  4554. //string filePath = $"{fileDir}/{projectFileName}";
  4555. //if (TypeName == "A")//A代表团组增减款项
  4556. //{
  4557. // filePath = fileDir + $@"\团组增减款项相关文件";
  4558. // if (!Directory.Exists(filePath))
  4559. // {
  4560. // Directory.CreateDirectory(filePath);
  4561. // }
  4562. // //上传的文件的路径
  4563. // filePath += $@"\{projectFileName}";
  4564. //}
  4565. //else if (TypeName == "B")//B代表商邀相关文件
  4566. //{
  4567. // //上传的文件的路径
  4568. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4569. // if (!Directory.Exists(filePath))
  4570. // {
  4571. // Directory.CreateDirectory(filePath);
  4572. // }
  4573. // //上传的文件的路径
  4574. // filePath = $@"\{projectFileName}";
  4575. //}
  4576. //try
  4577. //{
  4578. // using (FileStream fs = System.IO.File.Create(filePath))
  4579. // {
  4580. // file.CopyTo(fs);
  4581. // fs.Flush();
  4582. // }
  4583. //}
  4584. //catch (Exception ex)
  4585. //{
  4586. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4587. //}
  4588. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4589. try
  4590. {
  4591. var TypeName = Request.Headers["TypeName"].ToString();
  4592. if (file != null)
  4593. {
  4594. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4595. //文件名称
  4596. string projectFileName = file.FileName;
  4597. //上传的文件的路径
  4598. string filePath = $"{fileDir}/{projectFileName}";
  4599. if (TypeName == "A")//A代表团组增减款项
  4600. {
  4601. if (!Directory.Exists(fileDir))
  4602. {
  4603. Directory.CreateDirectory(fileDir);
  4604. }
  4605. //上传的文件的路径
  4606. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4607. }
  4608. else if (TypeName == "B")//B代表商邀相关文件
  4609. {
  4610. if (!Directory.Exists(fileDir))
  4611. {
  4612. Directory.CreateDirectory(fileDir);
  4613. }
  4614. //上传的文件的路径
  4615. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4616. }
  4617. using (FileStream fs = System.IO.File.Create(filePath))
  4618. {
  4619. file.CopyTo(fs);
  4620. fs.Flush();
  4621. }
  4622. return Ok(JsonView(true, "上传成功!", projectFileName));
  4623. }
  4624. else
  4625. {
  4626. return Ok(JsonView(false, "上传失败!"));
  4627. }
  4628. }
  4629. catch (Exception ex)
  4630. {
  4631. return Ok(JsonView(false, "程序错误!"));
  4632. }
  4633. }
  4634. /// <summary>
  4635. /// 删除指定文件
  4636. /// </summary>
  4637. /// <param name="dto"></param>
  4638. /// <returns></returns>
  4639. [HttpPost]
  4640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4641. public async Task<IActionResult> DelFile(DelFileDto dto)
  4642. {
  4643. try
  4644. {
  4645. var TypeName = Request.Headers["TypeName"].ToString();
  4646. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4647. string filePath = "";
  4648. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4649. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4650. int id = 0;
  4651. if (TypeName == "A")
  4652. {
  4653. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4654. // 删除该文件
  4655. System.IO.File.Delete(filePath);
  4656. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4657. .Where(a => a.Id == dto.Id)
  4658. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4659. .ExecuteCommandAsync();
  4660. }
  4661. else if (TypeName == "B")
  4662. {
  4663. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4664. // 删除该文件
  4665. System.IO.File.Delete(filePath);
  4666. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4667. if (info != null)
  4668. {
  4669. string[] files = new string[] { };
  4670. if (!string.IsNullOrEmpty(info.Attachment))
  4671. {
  4672. try
  4673. {
  4674. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4675. }
  4676. catch (Exception)
  4677. {
  4678. files = new List<string>() { info.Attachment }.ToArray();
  4679. }
  4680. }
  4681. if (files.Length > 0)
  4682. {
  4683. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4684. string filePath2 = string.Empty;
  4685. if (files1.Length > 0)
  4686. {
  4687. filePath2 = JsonConvert.SerializeObject(files1);
  4688. }
  4689. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4690. .Where(a => a.Id == dto.Id)
  4691. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4692. .ExecuteCommandAsync();
  4693. }
  4694. }
  4695. }
  4696. if (id != 0)
  4697. {
  4698. return Ok(JsonView(true, "成功!"));
  4699. }
  4700. else
  4701. {
  4702. return Ok(JsonView(false, "失败!"));
  4703. }
  4704. }
  4705. catch (Exception ex)
  4706. {
  4707. return Ok(JsonView(false, "程序错误!"));
  4708. throw;
  4709. }
  4710. }
  4711. /// <summary>
  4712. /// 文件上传多个文件 可以带参数
  4713. /// </summary>
  4714. /// <param name="files"></param>
  4715. /// <returns></returns>
  4716. [HttpPost]
  4717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4718. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4719. {
  4720. try
  4721. {
  4722. var TypeName = Request.Headers["TypeName"].ToString();
  4723. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4724. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4725. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4726. var filePahts = new List<string>();
  4727. foreach (var file in files)
  4728. {
  4729. //文件名称
  4730. string projectFileName = file.FileName;
  4731. //上传的文件的路径
  4732. string filePath = $"{fileDir}/{projectFileName}";
  4733. if (TypeName == "A")//A代表团组增减款项
  4734. {
  4735. if (!Directory.Exists(fileDir))
  4736. {
  4737. Directory.CreateDirectory(fileDir);
  4738. }
  4739. //上传的文件的路径
  4740. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4741. }
  4742. else if (TypeName == "B")//B代表商邀相关文件
  4743. {
  4744. if (!Directory.Exists(fileDir))
  4745. {
  4746. Directory.CreateDirectory(fileDir);
  4747. }
  4748. //上传的文件的路径
  4749. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4750. }
  4751. using (FileStream fs = System.IO.File.Create(filePath))
  4752. {
  4753. file.CopyTo(fs);
  4754. fs.Flush();
  4755. }
  4756. filePahts.Add(projectFileName);
  4757. }
  4758. return Ok(JsonView(true, "上传成功!", filePahts));
  4759. }
  4760. catch (Exception ex)
  4761. {
  4762. return Ok(JsonView(false, "程序错误!"));
  4763. }
  4764. }
  4765. #endregion
  4766. #region 商邀费用录入
  4767. /// <summary>
  4768. /// 根据团组Id查询商邀费用列表
  4769. /// </summary>
  4770. /// <param name="dto"></param>
  4771. /// <returns></returns>
  4772. [HttpPost]
  4773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4774. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4775. {
  4776. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4777. if (groupData.Code != 0)
  4778. {
  4779. return Ok(JsonView(false, groupData.Msg));
  4780. }
  4781. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4782. }
  4783. /// <summary>
  4784. /// 商邀费用列表
  4785. /// 下载文件
  4786. /// </summary>
  4787. /// <param name="id"></param>
  4788. /// <returns></returns>
  4789. [HttpGet("{id}")]
  4790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4791. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4792. {
  4793. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4794. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4795. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4796. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4797. var filePaths = new List<string>();
  4798. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4799. try
  4800. {
  4801. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4802. }
  4803. catch (Exception ex)
  4804. {
  4805. filePaths.Add(info.Attachment);
  4806. }
  4807. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4808. for (int i = 0; i < filePaths.Count; i++)
  4809. {
  4810. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4811. }
  4812. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4813. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4814. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4815. {
  4816. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4817. {
  4818. foreach (string filePath in filePaths)
  4819. {
  4820. if (System.IO.File.Exists(filePath))
  4821. {
  4822. // 获取文件名
  4823. string fileName = Path.GetFileName(filePath);
  4824. // 将文件添加到ZIP归档中
  4825. zipArchive.CreateEntryFromFile(filePath, fileName);
  4826. }
  4827. }
  4828. }
  4829. }
  4830. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4831. }
  4832. /// <summary>
  4833. /// 商邀费用 Info Page 基础数据源
  4834. /// </summary>
  4835. /// <returns></returns>
  4836. [HttpPost]
  4837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4838. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4839. {
  4840. try
  4841. {
  4842. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4843. if (groupData.Code != 0)
  4844. {
  4845. return Ok(JsonView(false, groupData.Msg));
  4846. }
  4847. return Ok(JsonView(true, "操作成功", groupData.Data));
  4848. }
  4849. catch (Exception ex)
  4850. {
  4851. return Ok(JsonView(false, ex.Message));
  4852. throw;
  4853. }
  4854. }
  4855. /// <summary>
  4856. /// 根据商邀费用ID查询C表和商邀费用数据
  4857. /// </summary>
  4858. /// <param name="dto"></param>
  4859. /// <returns></returns>
  4860. [HttpPost]
  4861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4862. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4863. {
  4864. try
  4865. {
  4866. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4867. if (groupData.Code != 0)
  4868. {
  4869. return Ok(JsonView(false, groupData.Msg));
  4870. }
  4871. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4872. }
  4873. catch (Exception ex)
  4874. {
  4875. return Ok(JsonView(false, ex.Message));
  4876. throw;
  4877. }
  4878. }
  4879. /// <summary>
  4880. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4881. /// </summary>
  4882. /// <param name="dto"></param>
  4883. /// <returns></returns>
  4884. [HttpPost]
  4885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4886. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4887. {
  4888. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4889. if (groupData.Code != 0)
  4890. {
  4891. return Ok(JsonView(false, groupData.Msg));
  4892. }
  4893. #region 应用推送
  4894. try
  4895. {
  4896. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4897. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4898. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4899. //2024-10-21 新增LZ UID
  4900. var userIds = new List<int>() { 21 };
  4901. string title = $"系统通知";
  4902. string content = "";
  4903. var diId = dto.DiId;
  4904. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4905. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4906. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4907. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4908. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4909. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4910. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4911. }
  4912. catch (Exception ex)
  4913. {
  4914. }
  4915. #endregion
  4916. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4917. }
  4918. /// <summary>
  4919. /// 商邀删除
  4920. /// </summary>
  4921. /// <param name="dto"></param>
  4922. /// <returns></returns>
  4923. [HttpPost]
  4924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4925. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4926. {
  4927. try
  4928. {
  4929. _sqlSugar.BeginTran();
  4930. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4931. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4932. {
  4933. IsDel = 1,
  4934. DeleteUserId = dto.DeleteUserId,
  4935. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4936. })
  4937. .Where(it => it.Id == dto.Id)
  4938. .ExecuteCommand();
  4939. if (res1 > 0)
  4940. {
  4941. int _diId = 0;
  4942. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4943. if (_ioaInfo != null)
  4944. {
  4945. _diId = _ioaInfo.DiId;
  4946. }
  4947. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4948. .SetColumns(a => new Grp_CreditCardPayment()
  4949. {
  4950. IsDel = 1,
  4951. DeleteUserId = dto.DeleteUserId,
  4952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4953. })
  4954. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4955. .ExecuteCommand();
  4956. if (res2 > 0)
  4957. {
  4958. _sqlSugar.CommitTran();
  4959. return Ok(JsonView(true, "删除成功!"));
  4960. }
  4961. }
  4962. _sqlSugar.RollbackTran();
  4963. return Ok(JsonView(false, "删除失败"));
  4964. }
  4965. catch (Exception ex)
  4966. {
  4967. _sqlSugar.RollbackTran();
  4968. return Ok(JsonView(false, ex.Message));
  4969. }
  4970. }
  4971. #endregion
  4972. #region 票据上传
  4973. /// <summary>
  4974. /// 团组模块文件上传
  4975. /// </summary>
  4976. /// <param name="dto"></param>
  4977. /// <returns></returns>
  4978. [HttpPost]
  4979. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4980. {
  4981. var jw = JsonView(false);
  4982. long M = 1024 * 1024;
  4983. if (dto.Files == null || dto.Files.Count == 0)
  4984. {
  4985. jw.Msg = "无文件信息!";
  4986. return Ok(jw);
  4987. }
  4988. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4989. {
  4990. jw.Msg = "文件大小超过20M!";
  4991. return Ok(jw);
  4992. }
  4993. //var nameSp = dto.File.FileName.Split(".");
  4994. //if (nameSp.Length < 2)
  4995. //{
  4996. // jw.Msg = "拓展名称有误!";
  4997. // return Ok(jw);
  4998. //}
  4999. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5000. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5001. //{
  5002. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5003. // return Ok(jw);
  5004. //}
  5005. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5006. if (Ctable == null)
  5007. {
  5008. jw.Msg = "Ctable指向有误!";
  5009. return Ok(jw);
  5010. }
  5011. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5012. if (groupInfo == null)
  5013. {
  5014. jw.Msg = "团组信息不存在!";
  5015. return Ok(jw);
  5016. }
  5017. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5018. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5019. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5020. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5021. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5022. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5023. try
  5024. {
  5025. if (!Directory.Exists(fileBase))
  5026. {
  5027. Directory.CreateDirectory(fileBase);
  5028. }
  5029. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5030. foreach (var fileStream in dto.Files)
  5031. {
  5032. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5033. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5034. {
  5035. Cid = dto.Cid,
  5036. CreateTime = DateTime.Now,
  5037. CreateUserId = dto.Userid,
  5038. Ctable = dto.Ctable,
  5039. Diid = dto.Diid,
  5040. IsDel = 0,
  5041. FilePath = saveFilePath,
  5042. FileName = fileStream.FileName
  5043. };
  5044. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5045. {
  5046. fileStream.CopyTo(fs);
  5047. fs.Flush();
  5048. }
  5049. saveArr.Add(file);
  5050. }
  5051. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5052. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5053. jw = JsonView(true, "保存成功!", new
  5054. {
  5055. count = addResult,
  5056. filesName = saveArr.Select(x => x.FileName)
  5057. });
  5058. }
  5059. catch (Exception ex)
  5060. {
  5061. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5062. {
  5063. count = 0,
  5064. filesName = new string[0],
  5065. });
  5066. }
  5067. return Ok(jw);
  5068. }
  5069. /// <summary>
  5070. /// 查询各模块已保存文件
  5071. /// </summary>
  5072. /// <param name="dto"></param>
  5073. /// <returns></returns>
  5074. [HttpPost]
  5075. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5076. {
  5077. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5078. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5079. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5080. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5081. {
  5082. expression = Expressionable.Create<Grp_GroupModelFile>()
  5083. .And(x => visaIds.Contains(x.CreateUserId));
  5084. }
  5085. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5086. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5087. .Where(expression.ToExpression())
  5088. .ToList();
  5089. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5090. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5091. {
  5092. x.FileName,
  5093. x.Id,
  5094. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5095. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5096. })));
  5097. }
  5098. /// <summary>
  5099. /// 下载该团组下的所有文件
  5100. /// </summary>
  5101. /// <param name="dto"></param>
  5102. /// <returns></returns>
  5103. [HttpPost]
  5104. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5105. {
  5106. var jw = JsonView(false);
  5107. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5108. if (groupInfo == null)
  5109. {
  5110. jw.Msg = "团组信息不存在!";
  5111. return Ok(jw);
  5112. }
  5113. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5114. var isModule = Convert.ToBoolean(dto.isModule);
  5115. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5116. IOOperatorHelper io = new IOOperatorHelper();
  5117. if (isModule)
  5118. {
  5119. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5120. foreach (var moduleArr in moduleGroup)
  5121. {
  5122. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5123. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5124. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5125. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5126. foreach (var item in moduleArr)
  5127. {
  5128. if (System.IO.File.Exists(item.FilePath))
  5129. {
  5130. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5131. {
  5132. byte[] bytes = new byte[fileStream.Length];
  5133. fileStream.Read(bytes, 0, bytes.Length);
  5134. fileStream.Close();
  5135. Stream stream = new MemoryStream(bytes);
  5136. chiZips.Add(item.FileName, stream);
  5137. }
  5138. }
  5139. }
  5140. if (chiZips.Count > 0)
  5141. {
  5142. var byts = io.ConvertZipStream(chiZips);
  5143. Stream stream = new MemoryStream(byts);
  5144. Zips.Add(key.Name + "_.zip", stream);
  5145. }
  5146. }
  5147. }
  5148. else
  5149. {
  5150. foreach (var item in dbQuery)
  5151. {
  5152. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5153. {
  5154. byte[] bytes = new byte[fileStream.Length];
  5155. fileStream.Read(bytes, 0, bytes.Length);
  5156. fileStream.Close();
  5157. Stream stream = new MemoryStream(bytes);
  5158. while (Zips.Keys.Contains(item.FileName))
  5159. {
  5160. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5161. }
  5162. Zips.Add(item.FileName, stream);
  5163. }
  5164. }
  5165. }
  5166. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5167. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5168. if (Zips.Count > 0)
  5169. {
  5170. var byts = io.ConvertZipStream(Zips);
  5171. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5172. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5173. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5174. }
  5175. else
  5176. {
  5177. jw.Msg = "暂无生成文件!";
  5178. }
  5179. return Ok(jw);
  5180. }
  5181. /// <summary>
  5182. /// 下载该团组下此模块的所有文件
  5183. /// </summary>
  5184. /// <param name="dto"></param>
  5185. /// <returns></returns>
  5186. [HttpPost]
  5187. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5188. {
  5189. var jw = JsonView(false);
  5190. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5191. if (groupInfo == null)
  5192. {
  5193. jw.Msg = "团组信息不存在!";
  5194. return Ok(jw);
  5195. }
  5196. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5197. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5198. && x.IsDel == 0);
  5199. if (key == null)
  5200. {
  5201. jw.Msg = "Ctable指向错误!";
  5202. return Ok(jw);
  5203. }
  5204. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5205. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5206. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5207. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5208. IOOperatorHelper io = new IOOperatorHelper();
  5209. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5210. foreach (var item in dbQuery)
  5211. {
  5212. if (System.IO.File.Exists(item.FilePath))
  5213. {
  5214. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5215. {
  5216. byte[] bytes = new byte[fileStream.Length];
  5217. fileStream.Read(bytes, 0, bytes.Length);
  5218. fileStream.Close();
  5219. Stream stream = new MemoryStream(bytes);
  5220. while (Zips.Keys.Contains(item.FileName))
  5221. {
  5222. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5223. }
  5224. Zips.Add(item.FileName, stream);
  5225. }
  5226. }
  5227. }
  5228. if (Zips.Count > 0)
  5229. {
  5230. var byts = io.ConvertZipStream(Zips);
  5231. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5232. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5233. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5234. }
  5235. else
  5236. {
  5237. jw.Msg = "暂无生成文件!";
  5238. }
  5239. return Ok(jw);
  5240. }
  5241. /// <summary>
  5242. /// 删除该团组下的指定文件
  5243. /// </summary>
  5244. /// <param name="dto"></param>
  5245. /// <returns></returns>
  5246. [HttpPost]
  5247. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5248. {
  5249. var jw = JsonView(false);
  5250. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5251. if (sing == null)
  5252. {
  5253. jw.Msg = "暂无";
  5254. return Ok(jw);
  5255. }
  5256. if (System.IO.File.Exists(sing.FilePath))
  5257. {
  5258. try
  5259. {
  5260. System.IO.File.Delete(sing.FilePath);
  5261. }
  5262. catch (Exception ex)
  5263. {
  5264. jw.Msg = "删除失败!" + ex.Message;
  5265. return Ok(jw);
  5266. }
  5267. }
  5268. sing.IsDel = 1;
  5269. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5270. sing.DeleteUserId = dto.UserId;
  5271. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5272. jw = JsonView(true, "删除成功!");
  5273. return Ok(jw);
  5274. }
  5275. #endregion
  5276. #region 共享文件上传
  5277. /// <summary>
  5278. /// 共享文件数据初始化
  5279. /// </summary>
  5280. /// <returns></returns>
  5281. [HttpGet]
  5282. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5283. {
  5284. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5285. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5286. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5287. .Select(x => x.Id)
  5288. .ToList()
  5289. .Contains(userid);
  5290. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5291. .Where(x => x.STid == 111 && x.IsDel == 0)
  5292. .Select(x => new
  5293. {
  5294. x.Name,
  5295. x.Id,
  5296. }).ToList();
  5297. if (isMarketingDepartment)
  5298. {
  5299. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5300. }
  5301. if (portType == 1)
  5302. {
  5303. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5304. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5305. .Where(x => x.IsDel == 0)
  5306. .OrderByDescending(x=> x.VisitDate )
  5307. .Select(x => new
  5308. {
  5309. x.TeamName,
  5310. x.Id,
  5311. x.CityId,
  5312. })
  5313. .ToList()
  5314. .Select(x=>
  5315. {
  5316. var provinceId = x.CityId;
  5317. var isDefualtVal = true;
  5318. if (provinceId > 0)
  5319. {
  5320. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5321. if (parentId != null)
  5322. {
  5323. isDefualtVal = false;
  5324. provinceId = (int)parentId;
  5325. }
  5326. }
  5327. if (isDefualtVal)
  5328. {
  5329. provinceId = 122; //默认四川
  5330. }
  5331. return new
  5332. {
  5333. x.TeamName,
  5334. x.Id,
  5335. provinceId,
  5336. };
  5337. })
  5338. .ToList();
  5339. return Ok(JsonView(true, "SUCCESS!", new
  5340. {
  5341. dropDownType,
  5342. dropDownGroupList,
  5343. isMarketingDepartment
  5344. }));
  5345. }
  5346. else if (portType == 2 || portType == 3)
  5347. {
  5348. return Ok(JsonView(true, "SUCCESS!", new
  5349. {
  5350. dropDownType,
  5351. isMarketingDepartment
  5352. }));
  5353. }
  5354. else
  5355. {
  5356. return Ok(JsonView(false, "portType有误!"));
  5357. }
  5358. }
  5359. /// <summary>
  5360. /// 共享文件上传
  5361. /// </summary>
  5362. /// <param name="dto"></param>
  5363. /// <returns></returns>
  5364. [HttpPost]
  5365. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5366. {
  5367. var isGroup = new List<int> { 1412 };
  5368. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5369. {
  5370. return Ok(JsonView(false, "该文件需要关联团组!"));
  5371. }
  5372. if (dto.Files == null || dto.Files.Count == 0)
  5373. {
  5374. return Ok(JsonView(false, "无文件信息!"));
  5375. }
  5376. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5377. {
  5378. return Ok(JsonView(false, "文件大小超过20M!"));
  5379. }
  5380. if (dto.Userid < 1)
  5381. {
  5382. return Ok(JsonView(false, "请传入有效的Userid!"));
  5383. }
  5384. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5385. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5386. .Select((u, j) => new
  5387. {
  5388. u.CnName,
  5389. UserId = u.Id,
  5390. j.JobName,
  5391. })
  5392. .First();
  5393. if (jobInfo == null)
  5394. {
  5395. return Ok(JsonView(false, "请传入有效的Userid!"));
  5396. }
  5397. List<string> commonFileExtensions = new List<string>
  5398. {
  5399. // 文本文件
  5400. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5401. // 图片文件
  5402. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5403. // 视频文件
  5404. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5405. // 音频文件
  5406. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5407. // 压缩文件
  5408. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5409. // 数据文件
  5410. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5411. };
  5412. try
  5413. {
  5414. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5415. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5416. commonFileExtensions.AddRange(settingExtend);
  5417. }
  5418. catch (Exception)
  5419. { }
  5420. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5421. if (setdata == null)
  5422. {
  5423. return Ok(JsonView(false, "请传入有效的FileType!"));
  5424. }
  5425. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5426. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5427. if (!Directory.Exists(winPath))
  5428. {
  5429. Directory.CreateDirectory(winPath);
  5430. }
  5431. foreach (var item in dto.Files)
  5432. {
  5433. var houzui = Path.GetExtension(item.FileName);
  5434. if (!commonFileExtensions.Contains(houzui))
  5435. {
  5436. return Ok(JsonView(false, "未知后缀名称!"));
  5437. }
  5438. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5439. var saveFilePath = winPath + fileName;
  5440. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5441. {
  5442. item.CopyTo(fs);
  5443. fs.Flush();
  5444. }
  5445. var fileDetail = new Grp_GroupShareFile()
  5446. {
  5447. CreateUserId = dto.Userid,
  5448. CreateTime = DateTime.Now,
  5449. UploadJob = jobInfo.JobName,
  5450. FileName = fileName,
  5451. FileType = dto.FileType,
  5452. Diid = dto.Diid,
  5453. FilePath = winPath + fileName,
  5454. };
  5455. insertList.Add(fileDetail);
  5456. }
  5457. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5458. return Ok(JsonView(true, "保存成功!"));
  5459. }
  5460. /// <summary>
  5461. /// 查询共享文件列表
  5462. /// </summary>
  5463. /// <param name="dto"></param>
  5464. /// <returns></returns>
  5465. [HttpPost]
  5466. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5467. {
  5468. var isGroup = new List<int> { 1412 };
  5469. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5470. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5471. .And(x => x.Diid == dto.Diid)
  5472. .And(x => x.FileType == dto.FileType)
  5473. .And(x => x.IsDel == 0)
  5474. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5475. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5476. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5477. int totalCount = 0;
  5478. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5479. .Where(queryExpression.ToExpression())
  5480. .OrderBy(x => x.UploadJob)
  5481. .Select(x => new
  5482. {
  5483. x.Id,
  5484. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5485. x.FileName,
  5486. x.FileType,
  5487. x.CreateTime,
  5488. })
  5489. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5490. return Ok(JsonView(true, "SUCCESS!", new
  5491. {
  5492. FileList = dbQuery,
  5493. dto.PageSize,
  5494. dto.PageIndex,
  5495. totalCount
  5496. }));
  5497. }
  5498. /// <summary>
  5499. /// 删除共享文件模块下的指定文件
  5500. /// </summary>
  5501. /// <param name="dto"></param>
  5502. /// <returns></returns>
  5503. [HttpPost]
  5504. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5505. {
  5506. var jw = JsonView(false);
  5507. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5508. if (sing == null)
  5509. {
  5510. jw.Msg = "暂无文件信息!";
  5511. return Ok(jw);
  5512. }
  5513. if (sing.CreateUserId != dto.UserId)
  5514. {
  5515. jw.Msg = "只能删除自己上传的文件!";
  5516. return Ok(jw);
  5517. }
  5518. if (System.IO.File.Exists(sing.FilePath))
  5519. {
  5520. try
  5521. {
  5522. System.IO.File.Delete(sing.FilePath);
  5523. }
  5524. catch (Exception ex)
  5525. {
  5526. jw.Msg = "删除失败!" + ex.Message;
  5527. return Ok(jw);
  5528. }
  5529. }
  5530. sing.IsDel = 1;
  5531. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5532. sing.DeleteUserId = dto.UserId;
  5533. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5534. jw = JsonView(true, "删除成功!");
  5535. return Ok(jw);
  5536. }
  5537. #endregion
  5538. #region 团组英文资料
  5539. /// <summary>
  5540. /// 查询团组英文所有资料
  5541. /// </summary>
  5542. /// <param name="dto"></param>
  5543. /// <returns></returns>
  5544. [HttpPost]
  5545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5546. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5547. {
  5548. try
  5549. {
  5550. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5551. if (groupData.Code != 0)
  5552. {
  5553. return Ok(JsonView(false, groupData.Msg));
  5554. }
  5555. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5556. }
  5557. catch (Exception ex)
  5558. {
  5559. return Ok(JsonView(false, "程序错误!"));
  5560. throw;
  5561. }
  5562. }
  5563. /// <summary>
  5564. /// 团组英文资料操作(Status:1.新增,2.修改)
  5565. /// </summary>
  5566. /// <param name="dto"></param>
  5567. /// <returns></returns>
  5568. [HttpPost]
  5569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5570. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5571. {
  5572. try
  5573. {
  5574. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5575. if (groupData.Code != 0)
  5576. {
  5577. return Ok(JsonView(false, groupData.Msg));
  5578. }
  5579. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5580. }
  5581. catch (Exception ex)
  5582. {
  5583. return Ok(JsonView(false, "程序错误!"));
  5584. throw;
  5585. }
  5586. }
  5587. /// <summary>
  5588. /// 团组英文资料Id查询数据
  5589. /// </summary>
  5590. /// <param name="dto"></param>
  5591. /// <returns></returns>
  5592. [HttpPost]
  5593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5594. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5595. {
  5596. try
  5597. {
  5598. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5599. if (_DelegationEnData != null)
  5600. {
  5601. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5602. }
  5603. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5604. }
  5605. catch (Exception ex)
  5606. {
  5607. return Ok(JsonView(false, "程序错误!"));
  5608. throw;
  5609. }
  5610. }
  5611. /// <summary>
  5612. /// 团组英文资料删除
  5613. /// </summary>
  5614. /// <param name="dto"></param>
  5615. /// <returns></returns>
  5616. [HttpPost]
  5617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5618. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5619. {
  5620. try
  5621. {
  5622. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5623. if (!res)
  5624. {
  5625. return Ok(JsonView(false, "删除失败"));
  5626. }
  5627. return Ok(JsonView(true, "删除成功!"));
  5628. }
  5629. catch (Exception ex)
  5630. {
  5631. return Ok(JsonView(false, "程序错误!"));
  5632. throw;
  5633. }
  5634. }
  5635. #endregion
  5636. #region 导出邀请函
  5637. /// <summary>
  5638. /// 导出邀请函页面初始化
  5639. /// </summary>
  5640. /// <param name="dto"></param>
  5641. /// <returns></returns>
  5642. [HttpPost]
  5643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5644. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5645. {
  5646. try
  5647. {
  5648. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5649. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5650. if (dto.DiId == 0)
  5651. {
  5652. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5653. }
  5654. else
  5655. {
  5656. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5657. }
  5658. return Ok(JsonView(true, "查询成功!", new
  5659. {
  5660. deleClient = crm_Deles,
  5661. delegations = grp_Delegations
  5662. }));
  5663. }
  5664. catch (Exception ex)
  5665. {
  5666. return Ok(JsonView(false, "程序错误!"));
  5667. throw;
  5668. }
  5669. }
  5670. /// <summary>
  5671. /// 导出邀请函
  5672. /// </summary>
  5673. /// <param name="dto"></param>
  5674. /// <returns></returns>
  5675. [HttpPost]
  5676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5677. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5678. {
  5679. #region 参数验证
  5680. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5681. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5682. #endregion
  5683. try
  5684. {
  5685. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5686. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5687. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5688. From Grp_TourClientList tcl
  5689. Left Join
  5690. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5691. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5692. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5693. From Crm_DeleClient dc
  5694. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5695. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5696. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5697. Where dc.IsDel = 0) temp
  5698. On temp.DcId =tcl.ClientId
  5699. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5700. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5701. List<string> texts = new List<string>();
  5702. if (datas.Count != 0)
  5703. {
  5704. foreach (TourClientListDetailsView item in datas)
  5705. {
  5706. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5707. {
  5708. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5709. }
  5710. else
  5711. {
  5712. string name = item.LastName + item.FirstName;
  5713. texts.Add(name);
  5714. }
  5715. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5716. {
  5717. if (!transDic.ContainsKey(item.Job))
  5718. {
  5719. texts.Add(item.Job);
  5720. }
  5721. }
  5722. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5723. {
  5724. texts.Add(item.CompanyFullName);
  5725. }
  5726. }
  5727. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5728. if (transData.Count > 0)
  5729. {
  5730. foreach (TranslateResult item in transData)
  5731. {
  5732. if (!transDic.ContainsKey(item.Query))
  5733. {
  5734. transDic.Add(item.Query, item.Translation);
  5735. }
  5736. }
  5737. }
  5738. List<GuestList> list = new List<GuestList>();
  5739. foreach (TourClientListDetailsView dele in datas)
  5740. {
  5741. GuestList guestList = new GuestList();
  5742. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5743. {
  5744. guestList.Name = dele.Pinyin;
  5745. }
  5746. else
  5747. {
  5748. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5749. guestList.Name = Name;
  5750. }
  5751. if (dele.Sex == 0)
  5752. {
  5753. guestList.Sex = "Male";
  5754. }
  5755. else if (dele.Sex == 1)
  5756. {
  5757. guestList.Sex = "Female";
  5758. }
  5759. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5760. if (!string.IsNullOrEmpty(dele.Job))
  5761. {
  5762. guestList.Job = dele.Job;
  5763. }
  5764. list.Add(guestList);
  5765. }
  5766. //载入模板
  5767. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5768. DocumentBuilder builder = new DocumentBuilder(doc);
  5769. //获取word里所有表格
  5770. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5771. //获取所填表格的序数
  5772. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5773. var rowStart = tableOne.Rows[0]; //获取第1行
  5774. //循环赋值
  5775. for (int i = 0; i < list.Count; i++)
  5776. {
  5777. builder.MoveToCell(0, i + 1, 0, 0);
  5778. builder.Write(list[i].Name.ToString());
  5779. builder.MoveToCell(0, i + 1, 1, 0);
  5780. builder.Write(list[i].Sex.ToString());
  5781. builder.MoveToCell(0, i + 1, 2, 0);
  5782. builder.Write(list[i].DOB.ToString());
  5783. builder.MoveToCell(0, i + 1, 3, 0);
  5784. builder.Write(list[i].Job.ToString());
  5785. }
  5786. //删除多余行
  5787. while (tableOne.Rows.Count > list.Count + 1)
  5788. {
  5789. tableOne.Rows.RemoveAt(list.Count + 1);
  5790. }
  5791. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5792. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5793. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5794. doc.Save(filePath);
  5795. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5796. return Ok(JsonView(true, "操作成功!", Url));
  5797. }
  5798. else
  5799. {
  5800. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5801. }
  5802. }
  5803. catch (Exception ex)
  5804. {
  5805. return Ok(JsonView(false, ex.Message));
  5806. throw;
  5807. }
  5808. }
  5809. #endregion
  5810. #region 团组经理模块 出入境费用
  5811. /// <summary>
  5812. /// 团组模块 - 出入境费用 - 省份基础数据源
  5813. /// </summary>
  5814. /// <returns></returns>
  5815. [HttpGet]
  5816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5817. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5818. {
  5819. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5820. }
  5821. /// <summary>
  5822. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5823. /// </summary>
  5824. /// <returns></returns>
  5825. [HttpPost]
  5826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5827. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5828. {
  5829. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5830. var groupNamFirst = groupNameData.FirstOrDefault();
  5831. //SetDataInfoView
  5832. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5833. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5834. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5835. //验证城市归属并给默认值
  5836. int provinceId = 122;
  5837. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5838. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5839. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5840. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5841. return Ok(JsonView(true, "查询成功!", new
  5842. {
  5843. GroupNameData = groupNameData,
  5844. CurrencyData = _CurrencyData,
  5845. WordTypeData = wordTypeData,
  5846. ExcelTypeData = excelTypeData,
  5847. CurrencyInit = _currencyInfos,
  5848. ViewPermissionData = viewPermissionData
  5849. }));
  5850. }
  5851. /// <summary>
  5852. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5853. /// </summary>
  5854. /// <returns></returns>
  5855. [HttpGet("{provinceId}")]
  5856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5857. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5858. {
  5859. //验证城市归属并给默认值
  5860. if (provinceId < 1) provinceId = 122;
  5861. /*
  5862. * 122 四川
  5863. * 108 贵州
  5864. * 103 重庆
  5865. * 132 云南
  5866. */
  5867. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5868. return Ok(JsonView(true, "查询成功!", new
  5869. {
  5870. WordTypeData = wordTypeData,
  5871. ExcelTypeData = excelTypeData,
  5872. }));
  5873. }
  5874. /// <summary>
  5875. /// 团组模块 - 出入境费用
  5876. /// 实时汇率 tips
  5877. /// 签证费用 tips
  5878. /// 机票费用 tips
  5879. /// </summary>
  5880. /// <returns></returns>
  5881. [HttpPost]
  5882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5883. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5884. {
  5885. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5886. //默认币种显示
  5887. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5888. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5889. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5890. return Ok(JsonView(true, "查询成功!", new
  5891. {
  5892. //GroupNameData = groupNameData.Data,
  5893. visaData = visaData.Data,
  5894. airData = airData.Data,
  5895. reteInfos = reteInfos
  5896. }));
  5897. }
  5898. /// <summary>
  5899. /// 团组模块 - 出入境费用 - Info
  5900. /// </summary>
  5901. /// <returns></returns>
  5902. [HttpPost]
  5903. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5905. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5906. {
  5907. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5908. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5909. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5910. }
  5911. /// <summary>
  5912. /// 团组模块 - 出入境费用 - 设置view权限
  5913. /// </summary>
  5914. /// <returns></returns>
  5915. [HttpPost]
  5916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5917. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5918. {
  5919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5920. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5921. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5922. var permissions = new List<Grp_EnterExitCostPermission>();
  5923. foreach (var userId in dto.UserIds)
  5924. {
  5925. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5926. }
  5927. if (permissions.Any())
  5928. {
  5929. _sqlSugar.BeginTran();
  5930. try
  5931. {
  5932. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5933. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5934. if (result < 1)
  5935. {
  5936. _sqlSugar.RollbackTran();
  5937. return Ok(JsonView(false));
  5938. }
  5939. }
  5940. catch (Exception ex)
  5941. {
  5942. _sqlSugar.RollbackTran();
  5943. return Ok(JsonView(false, ex.Message));
  5944. }
  5945. _sqlSugar.CommitTran();
  5946. return Ok(JsonView(true));
  5947. }
  5948. return Ok(JsonView(false));
  5949. }
  5950. /// <summary>
  5951. /// 团组模块 - 出入境费用 - Add And Update
  5952. /// </summary>
  5953. /// <returns></returns>
  5954. [HttpPost]
  5955. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5957. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5958. {
  5959. try
  5960. {
  5961. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5962. if (dto.DayOtherPriceData.Any())
  5963. {
  5964. var inserList = dto.DayOtherPriceData
  5965. .Where(x => x.Id == 0)
  5966. .Select(x => new Grp_DayOtherPrice
  5967. {
  5968. Cost = x.Cost,
  5969. Id = x.Id,
  5970. CreateTime = DateTime.Now,
  5971. CreateUserId = dto.UserId,
  5972. Currency = x.Currency,
  5973. Diid = x.DiId,
  5974. Index = x.Index,
  5975. IsDel = 0,
  5976. SetDataId = x.SetDataId,
  5977. SubTotal = x.SubTotal,
  5978. Remark = x.Remark
  5979. })
  5980. .ToList();
  5981. var updateList = dto.DayOtherPriceData
  5982. .Where(x => x.Id != 0)
  5983. .Select(x => new Grp_DayOtherPrice
  5984. {
  5985. Cost = x.Cost,
  5986. Id = x.Id,
  5987. CreateTime = DateTime.Now,
  5988. CreateUserId = dto.UserId,
  5989. Currency = x.Currency,
  5990. Diid = x.DiId,
  5991. Index = x.Index,
  5992. IsDel = 0,
  5993. SetDataId = x.SetDataId,
  5994. SubTotal = x.SubTotal,
  5995. Remark = x.Remark
  5996. })
  5997. .ToList();
  5998. //添加
  5999. _sqlSugar.BeginTran();
  6000. if (inserList.Any())
  6001. {
  6002. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6003. }
  6004. if (updateList.Any())
  6005. {
  6006. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6007. }
  6008. _sqlSugar.CommitTran();
  6009. }
  6010. if (data.Code != 0)
  6011. {
  6012. return Ok(JsonView(false, data.Msg));
  6013. }
  6014. //生成默认文件pdf并且通知人员
  6015. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6016. {
  6017. DiId = dto.DiId,
  6018. ExportType = 1,
  6019. SubTypeId = 1005
  6020. }, "pdf");
  6021. //发送通知
  6022. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6023. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6024. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6025. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6026. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6027. //汇率信息记录
  6028. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6029. return Ok(JsonView(true, data.Msg, data.Data));
  6030. }
  6031. catch (Exception ex)
  6032. {
  6033. return Ok(JsonView(false, ex.Message));
  6034. }
  6035. }
  6036. /// <summary>
  6037. /// 团组模块 - 出入境费用 - Confirm 费用
  6038. /// </summary>
  6039. /// <returns></returns>
  6040. [HttpPost]
  6041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6042. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6043. {
  6044. //TODO:测试完毕需把对应的用户ID更改
  6045. //1、数据表添加字段
  6046. //2、更改字段接口()
  6047. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6048. //3、确认成功 给财务发送消息
  6049. if (_view.Code == 200)
  6050. {
  6051. if (dto.Type == 1)
  6052. {
  6053. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6054. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6055. }
  6056. }
  6057. return Ok(_view);
  6058. }
  6059. /// <summary>
  6060. /// 团组模块 - 出入境费用 - File download
  6061. /// </summary>
  6062. /// <param name="dto"></param>
  6063. /// <returns></returns>
  6064. [HttpPost]
  6065. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6067. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6068. {
  6069. try
  6070. {
  6071. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6072. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6073. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6074. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6075. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6076. 3 团组成员名单 1 团组成员名单", ""));
  6077. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6078. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6079. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6080. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6081. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6082. //数据源
  6083. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6084. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6085. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6086. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6087. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6088. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6089. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6090. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6091. .Select((x, a, b) => new
  6092. {
  6093. x.Index,
  6094. itemName = a.Name,
  6095. CurrencyStr = b.Name,
  6096. x.Cost,
  6097. x.SubTotal,
  6098. x.Remark
  6099. })
  6100. .OrderBy((x) => x.Index)
  6101. .ToList(); //其他款项费用
  6102. var peiceItemCurrencys = new List<string>();
  6103. if (_DayAndCosts.Any())
  6104. {
  6105. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6106. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6107. }
  6108. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6109. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6110. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6111. {
  6112. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6113. }
  6114. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6115. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6116. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6117. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6118. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6119. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6120. .Select((tcl, dc, cc) => new ClientInfo
  6121. {
  6122. LastName = dc.LastName,
  6123. FirstName = dc.FirstName,
  6124. Sex = dc.Sex,
  6125. Birthday = dc.BirthDay,
  6126. Company = cc.CompanyFullName,
  6127. Job = dc.Job
  6128. })
  6129. .ToList();
  6130. foreach (var item in DeleClientList)
  6131. {
  6132. EncryptionProcessor.DecryptProperties(item);
  6133. }
  6134. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6135. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6136. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6137. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6138. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6139. if (dto.ExportType == 1) //明细表
  6140. {
  6141. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6142. {
  6143. //获取模板
  6144. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6145. //载入模板
  6146. Document doc = new Document(tempPath);
  6147. DocumentBuilder builder = new DocumentBuilder(doc);
  6148. //利用键值对存放数据
  6149. Dictionary<string, string> dic = new Dictionary<string, string>();
  6150. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6151. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6152. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6153. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6154. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6155. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6156. //境内费用(其他费用)
  6157. if (_EnterExitCosts.ChoiceOne == 1)
  6158. {
  6159. string row1_1 = "";
  6160. if (_EnterExitCosts.Visa > 0)
  6161. {
  6162. //insidePayTotal += _EnterExitCosts.Visa;
  6163. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6164. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6165. //{
  6166. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6167. //}
  6168. }
  6169. string row1_2 = "";
  6170. if (_EnterExitCosts.YiMiao > 0)
  6171. {
  6172. //insidePayTotal += _EnterExitCosts.YiMiao;
  6173. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6174. }
  6175. if (_EnterExitCosts.HeSuan > 0)
  6176. {
  6177. //insidePayTotal += _EnterExitCosts.HeSuan;
  6178. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6179. }
  6180. if (_EnterExitCosts.Service > 0)
  6181. {
  6182. //insidePayTotal += _EnterExitCosts.Service;
  6183. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6184. }
  6185. string row1_3 = "";
  6186. if (_EnterExitCosts.Safe > 0)
  6187. {
  6188. //insidePayTotal += _EnterExitCosts.Safe;
  6189. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6190. }
  6191. if (_EnterExitCosts.Ticket > 0)
  6192. {
  6193. //insidePayTotal += _EnterExitCosts.Ticket;
  6194. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6195. }
  6196. string row1 = "";
  6197. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6198. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6199. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6200. row1 += $"备注:{_EnterExitCosts.Remark}";
  6201. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6202. dic.Add("Row1Str", row1);
  6203. }
  6204. string airTotalStr = string.Empty,
  6205. airPriceStr = string.Empty;
  6206. //经济舱
  6207. if (_EnterExitCosts.SumJJC == 1)
  6208. {
  6209. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6210. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6211. }
  6212. //公务舱
  6213. if (_EnterExitCosts.SumGWC == 1)
  6214. {
  6215. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6216. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6217. }
  6218. //头等舱
  6219. if (_EnterExitCosts.SumTDC == 1)
  6220. {
  6221. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6222. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6223. }
  6224. //汇率描述
  6225. string rateStr = "";
  6226. if (peiceItemCurrencyInfos.Any())
  6227. {
  6228. rateStr = "\r\n汇率描述:";
  6229. foreach (var item in peiceItemCurrencyInfos)
  6230. {
  6231. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6232. }
  6233. }
  6234. string twoItemRemark = "备注:";
  6235. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6236. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6237. dic.Add("AirTotalStr", airTotalStr);
  6238. dic.Add("AirPriceStr", airPriceStr);
  6239. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6240. dic.Add("TwoItemRemark", twoItemRemark);
  6241. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6242. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6243. int table1Row = 0,
  6244. table2Row = 0,
  6245. table3Row = 0,
  6246. table4Row = 0,
  6247. table5Row = 0;
  6248. //住宿费
  6249. if (_EnterExitCosts.ChoiceThree == 1)
  6250. {
  6251. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6252. table1Row = dac1.Count;
  6253. #region 填充word表格内容
  6254. for (int i = 0; i < dac1.Count; i++)
  6255. {
  6256. Grp_DayAndCost dac = dac1[i];
  6257. if (dac == null) continue;
  6258. builder.MoveToCell(0, i, 0, 0);
  6259. builder.Write("第" + dac.Days.ToString() + "晚:");
  6260. builder.MoveToCell(0, i, 1, 0);
  6261. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6262. //builder.Write(dac.Place == null ? "" : dac.Place);
  6263. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6264. builder.MoveToCell(0, i, 2, 0);
  6265. builder.Write("费用标准:");
  6266. string curr = "";
  6267. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6268. if (currData != null)
  6269. {
  6270. curr = currData.Name;
  6271. }
  6272. builder.MoveToCell(0, i, 3, 0);
  6273. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6274. builder.MoveToCell(0, i, 4, 0);
  6275. builder.Write("费用小计:");
  6276. builder.MoveToCell(0, i, 5, 0);
  6277. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6278. }
  6279. #endregion
  6280. }
  6281. else dic.Add("SubZS", "0.00");
  6282. //删除多余行
  6283. while (table1.Rows.Count > table1Row)
  6284. {
  6285. table1.Rows.RemoveAt(table1Row);
  6286. }
  6287. //伙食费
  6288. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6289. if (_EnterExitCosts.ChoiceFour == 1)
  6290. {
  6291. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6292. table2Row = dac2.Count;
  6293. #region 填充word表格内容
  6294. for (int i = 0; i < dac2.Count; i++)
  6295. {
  6296. Grp_DayAndCost dac = dac2[i];
  6297. if (dac == null) continue;
  6298. builder.MoveToCell(1, i, 0, 0);
  6299. builder.Write("第" + dac.Days.ToString() + "天:");
  6300. builder.MoveToCell(1, i, 1, 0);
  6301. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6302. builder.MoveToCell(1, i, 2, 0);
  6303. builder.Write("费用标准:");
  6304. string curr = "";
  6305. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6306. if (currData != null)
  6307. {
  6308. curr = currData.Name;
  6309. }
  6310. builder.MoveToCell(1, i, 3, 0);
  6311. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6312. builder.MoveToCell(1, i, 4, 0);
  6313. builder.Write("费用小计:");
  6314. builder.MoveToCell(1, i, 5, 0);
  6315. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6316. }
  6317. #endregion
  6318. }
  6319. else dic.Add("SubHS", "0.00");
  6320. //删除多余行
  6321. while (table2.Rows.Count > table2Row)
  6322. {
  6323. table2.Rows.RemoveAt(table2Row);
  6324. }
  6325. //公杂费
  6326. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6327. if (_EnterExitCosts.ChoiceFive == 1)
  6328. {
  6329. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6330. table3Row = dac3.Count;
  6331. #region 填充word表格内容
  6332. for (int i = 0; i < dac3.Count; i++)
  6333. {
  6334. Grp_DayAndCost dac = dac3[i];
  6335. if (dac == null) continue;
  6336. builder.MoveToCell(2, i, 0, 0);
  6337. builder.Write("第" + dac.Days.ToString() + "天:");
  6338. builder.MoveToCell(2, i, 1, 0);
  6339. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6340. builder.MoveToCell(2, i, 2, 0);
  6341. builder.Write("费用标准:");
  6342. string curr = "";
  6343. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6344. if (currData != null)
  6345. {
  6346. curr = currData.Name;
  6347. }
  6348. builder.MoveToCell(2, i, 3, 0);
  6349. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6350. builder.MoveToCell(2, i, 4, 0);
  6351. builder.Write("费用小计:");
  6352. builder.MoveToCell(2, i, 5, 0);
  6353. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6354. }
  6355. //删除多余行
  6356. while (table3.Rows.Count > table3Row)
  6357. {
  6358. table3.Rows.RemoveAt(table3Row);
  6359. }
  6360. #endregion
  6361. }
  6362. else dic.Add("SubGZF", "0.00");
  6363. //删除多余行
  6364. while (table3.Rows.Count > table3Row)
  6365. {
  6366. table3.Rows.RemoveAt(table3Row);
  6367. }
  6368. //培训费
  6369. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6370. if (_EnterExitCosts.ChoiceSix == 1)
  6371. {
  6372. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6373. dic.Add("SubPX", pxStr);
  6374. table4Row = dac4.Count;
  6375. #region 填充word表格内容
  6376. for (int i = 0; i < dac4.Count; i++)
  6377. {
  6378. Grp_DayAndCost dac = dac4[i];
  6379. if (dac == null) continue;
  6380. builder.MoveToCell(3, i, 0, 0);
  6381. builder.Write("第" + dac.Days.ToString() + "天:");
  6382. builder.MoveToCell(3, i, 1, 0);
  6383. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6384. builder.MoveToCell(3, i, 2, 0);
  6385. builder.Write("费用标准:");
  6386. string curr = "";
  6387. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6388. if (currData != null)
  6389. {
  6390. curr = currData.Name;
  6391. }
  6392. builder.MoveToCell(3, i, 3, 0);
  6393. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6394. builder.MoveToCell(3, i, 4, 0);
  6395. builder.Write("费用小计:");
  6396. builder.MoveToCell(3, i, 5, 0);
  6397. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6398. }
  6399. #endregion
  6400. }
  6401. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6402. //删除多余行
  6403. while (table4.Rows.Count > table4Row)
  6404. {
  6405. table4.Rows.RemoveAt(table4Row);
  6406. }
  6407. //其他费用
  6408. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6409. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6410. {
  6411. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6412. dic.Add("titleQi", qtStr);
  6413. table5Row = dac5.Count;
  6414. #region 填充word表格内容
  6415. for (int i = 0; i < dac5.Count; i++)
  6416. {
  6417. var dac = dac5[i];
  6418. if (dac == null) continue;
  6419. builder.MoveToCell(4, i, 0, 0);
  6420. builder.Write("第" + dac.Index.ToString() + "项:");
  6421. builder.MoveToCell(4, i, 1, 0);
  6422. builder.Write(dac.itemName);
  6423. builder.MoveToCell(4, i, 2, 0);
  6424. builder.Write("费用标准:");
  6425. builder.MoveToCell(4, i, 3, 0);
  6426. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6427. builder.MoveToCell(4, i, 4, 0);
  6428. builder.Write("费用小计:");
  6429. builder.MoveToCell(4, i, 5, 0);
  6430. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6431. builder.MoveToCell(4, i, 6, 0);
  6432. builder.Write("备注:");
  6433. builder.MoveToCell(4, i, 7, 0);
  6434. builder.Write(dac.Remark);
  6435. }
  6436. #endregion
  6437. }
  6438. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6439. //删除多余行
  6440. while (table5.Rows.Count > table5Row)
  6441. {
  6442. table5.Rows.RemoveAt(table5Row);
  6443. }
  6444. //加上其他费用
  6445. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6446. decimal subJJC = 0.00M,
  6447. subGWC = 0.00M,
  6448. subTDC = 0.00M;
  6449. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6450. string totalLabel = string.Format("全部费用总计:");
  6451. //经济舱
  6452. if (_EnterExitCosts.SumJJC == 1)
  6453. {
  6454. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6455. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6456. }
  6457. //公务舱
  6458. if (_EnterExitCosts.SumGWC == 1)
  6459. {
  6460. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6461. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6462. }
  6463. //头等舱
  6464. if (_EnterExitCosts.SumTDC == 1)
  6465. {
  6466. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6467. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6468. }
  6469. //TotalLabel
  6470. dic.Add("TotalLabel", totalLabel);
  6471. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6472. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6473. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6474. #region 填充word模板书签内容
  6475. foreach (var key in dic.Keys)
  6476. {
  6477. Bookmark bookmark = doc.Range.Bookmarks[key];
  6478. if (bookmark != null)
  6479. {
  6480. builder.MoveToBookmark(key);
  6481. builder.Write(dic[key]);
  6482. }
  6483. }
  6484. #endregion
  6485. #region 设置页眉
  6486. string userLabel = string.Empty;
  6487. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6488. if (currUserInfo != null)
  6489. {
  6490. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6491. if (userInfo != null)
  6492. {
  6493. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6494. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6495. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6496. }
  6497. }
  6498. //设置页脚
  6499. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6500. #endregion
  6501. //文件名
  6502. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6503. AsposeHelper.removewatermark_v2180();
  6504. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6505. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6506. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6507. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6508. }
  6509. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6510. {
  6511. //获取模板
  6512. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6513. //载入模板
  6514. Document doc = new Document(tempPath);
  6515. DocumentBuilder builder = new DocumentBuilder(doc);
  6516. Dictionary<string, string> dic = new Dictionary<string, string>();
  6517. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6518. {
  6519. List<string> list = new List<string>();
  6520. try
  6521. {
  6522. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6523. foreach (var item in spilitArr)
  6524. {
  6525. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6526. var depCode = spDotandEmpty[2].Substring(0, 3);
  6527. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6528. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6529. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6530. list.Add(depName);
  6531. list.Add(arrName);
  6532. }
  6533. list = list.Distinct().ToList();
  6534. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6535. }
  6536. catch (Exception)
  6537. {
  6538. dic.Add("ReturnCode", "行程录入不正确!");
  6539. }
  6540. }
  6541. else
  6542. {
  6543. dic.Add("ReturnCode", "未录入行程!");
  6544. }
  6545. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6546. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6547. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6548. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6549. {
  6550. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6551. dic.Add("Day", sp.Days.ToString());
  6552. }
  6553. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6554. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6555. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6556. //dic.Add("Names", Names);
  6557. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6558. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6559. decimal dac1totalPrice = 0.00M;
  6560. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6561. foreach (var dac in dac1)
  6562. {
  6563. if (dac.SubTotal == 0.00M)
  6564. {
  6565. continue;
  6566. }
  6567. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6568. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6569. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6570. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6571. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6572. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6573. builder.Write(currency);//币种
  6574. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6575. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6576. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6577. builder.Write("");//人数
  6578. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6579. builder.Write("");//天数
  6580. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6581. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6582. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6583. decimal rate = 0.00M;
  6584. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6585. builder.Write(rate.ToString("#0.0000"));//汇率
  6586. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6587. decimal rbmPrice = dac.SubTotal;
  6588. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6589. accommodationStartIndex++;
  6590. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6591. }
  6592. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6593. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6594. {
  6595. table1.Rows.RemoveAt(i - 1);
  6596. foodandotherStartIndex--;
  6597. }
  6598. if (dac2.Count == dac3.Count)//国家 币种 金额
  6599. {
  6600. for (int i = 0; i < dac2.Count; i++)
  6601. {
  6602. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6603. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6604. }
  6605. }
  6606. decimal dac2totalPrice = 0.00M;
  6607. foreach (var dac in dac2)
  6608. {
  6609. if (dac.SubTotal == 0)
  6610. {
  6611. continue;
  6612. }
  6613. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6614. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6615. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6616. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6617. builder.Write(currency);//币种
  6618. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6619. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6620. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6621. builder.Write("");//人数
  6622. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6623. builder.Write("");//天数
  6624. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6625. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6626. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6627. decimal rate = 0.00M;
  6628. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6629. builder.Write(rate.ToString("#0.0000"));//汇率
  6630. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6631. decimal rbmPrice = dac.SubTotal;
  6632. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6633. foodandotherStartIndex++;
  6634. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6635. }
  6636. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6637. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6638. {
  6639. table1.Rows.RemoveAt(i - 1);
  6640. }
  6641. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6642. string otherFeeStr = "";
  6643. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6644. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6645. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6646. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6647. foreach (var otherInfo in dac5)
  6648. {
  6649. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6650. }
  6651. #endregion
  6652. if (otherFeeStr.Length > 0)
  6653. {
  6654. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6655. otherFeeStr = $"({otherFeeStr})";
  6656. dic.Add("OtherFeeStr", otherFeeStr);
  6657. }
  6658. //总计
  6659. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6660. //国际旅费
  6661. string outsideAir = string.Empty;
  6662. string allPriceAir = string.Empty;
  6663. if (_EnterExitCosts.SumJJC == 1)
  6664. {
  6665. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6666. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6667. }
  6668. if (_EnterExitCosts.SumGWC == 1)
  6669. {
  6670. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6671. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6672. }
  6673. if (_EnterExitCosts.SumTDC == 1)
  6674. {
  6675. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6676. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6677. }
  6678. dic.Add("InTravelPrice", $"({outsideAir})");
  6679. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6680. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6681. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6682. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6683. foreach (var key in dic.Keys)
  6684. {
  6685. builder.MoveToBookmark(key);
  6686. builder.Write(dic[key]);
  6687. }
  6688. //模板文件名
  6689. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6690. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6691. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6692. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6693. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6694. }
  6695. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6696. {
  6697. //获取模板
  6698. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6699. //载入模板
  6700. WorkbookDesigner designer = new WorkbookDesigner();
  6701. designer.Workbook = new Workbook(tempPath);
  6702. Dictionary<string, string> dic = new Dictionary<string, string>();
  6703. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6704. {
  6705. List<string> list = new List<string>();
  6706. try
  6707. {
  6708. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6709. foreach (var item in spilitArr)
  6710. {
  6711. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6712. var depCode = spDotandEmpty[2].Substring(0, 3);
  6713. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6714. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6715. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6716. list.Add(depName);
  6717. list.Add(arrName);
  6718. }
  6719. list = list.Distinct().ToList();
  6720. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6721. }
  6722. catch (Exception)
  6723. {
  6724. dic.Add("ReturnCode", "行程录入不正确!");
  6725. }
  6726. }
  6727. else
  6728. {
  6729. dic.Add("ReturnCode", "未录入行程!");
  6730. }
  6731. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6732. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6733. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6734. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6735. {
  6736. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6737. dic.Add("Day", sp.Days.ToString());
  6738. }
  6739. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6740. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6741. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6742. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6743. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6744. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6745. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6746. designer.SetDataSource("Name", Names);
  6747. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6748. designer.SetDataSource("Day", dic["Day"] + "天");
  6749. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6750. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6751. int startIndex = 10;
  6752. const int startIndexcopy = 10;
  6753. if (dac2.Count == dac3.Count)//国家 币种 金额
  6754. {
  6755. for (int i = 0; i < dac2.Count; i++)
  6756. {
  6757. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6758. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6759. }
  6760. }
  6761. DataTable dtdac1 = new DataTable();
  6762. List<string> place = new List<string>();
  6763. dtdac1.Columns.AddRange(new DataColumn[] {
  6764. new DataColumn(){ ColumnName = "city"},
  6765. new DataColumn(){ ColumnName = "curr"},
  6766. new DataColumn(){ ColumnName = "criterion"},
  6767. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6768. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6769. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6770. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6771. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6772. });
  6773. DataTable dtdac2 = new DataTable();
  6774. dtdac2.Columns.AddRange(new DataColumn[] {
  6775. new DataColumn(){ ColumnName = "city"},
  6776. new DataColumn(){ ColumnName = "curr"},
  6777. new DataColumn(){ ColumnName = "criterion"},
  6778. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6779. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6780. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6781. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6782. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6783. });
  6784. dtdac1.TableName = "tb1";
  6785. dtdac2.TableName = "tb2";
  6786. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6787. foreach (var item in dac1)
  6788. {
  6789. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6790. if (place.Contains(item.Place))
  6791. {
  6792. continue;
  6793. }
  6794. DataRow row = dtdac1.NewRow();
  6795. row["city"] = item.Place;
  6796. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6797. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6798. row["curr"] = currency;
  6799. row["rate"] = rate.ToString("#0.0000");
  6800. row["criterion"] = item.Cost.ToString("#0.00");
  6801. row["number"] = 1;
  6802. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6803. //row["costRMB"] = rbmPrice;
  6804. dtdac1.Rows.Add(row);
  6805. place.Add(item.Place);
  6806. }
  6807. place = new List<string>();
  6808. foreach (var item in dac2)
  6809. {
  6810. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6811. if (place.Contains(item.Place))
  6812. {
  6813. continue;
  6814. }
  6815. DataRow row = dtdac2.NewRow();
  6816. row["city"] = item.Place;
  6817. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6818. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6819. row["curr"] = currency;
  6820. row["rate"] = rate.ToString("#0.0000");
  6821. row["criterion"] = item.Cost.ToString("#0.00");
  6822. row["number"] = 1;
  6823. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6824. //row["cost"] = item.SubTotal;
  6825. //row["costRMB"] = rbmPrice;
  6826. dtdac2.Rows.Add(row);
  6827. place.Add(item.Place);
  6828. //dac2totalPrice += rbmPrice;
  6829. }
  6830. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6831. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6832. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6833. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6834. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6835. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6836. string cell4Str1 = string.Empty;
  6837. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6838. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6839. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6840. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6841. string cellStr = $" 5.其他费用(";
  6842. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6843. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6844. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6845. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6846. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6847. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6848. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6849. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6850. foreach (var otherInfo in dac5)
  6851. {
  6852. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6853. }
  6854. #endregion
  6855. if (cellStr.Length > 8)
  6856. {
  6857. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6858. }
  6859. cellStr += ")";
  6860. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6861. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6862. decimal pxFee = dac4.Sum(it => it.Cost);
  6863. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6864. string celllastStr1 = "";
  6865. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6866. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6867. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6868. celllastStr1 += $",国际旅费 元";
  6869. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6870. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6871. designer.SetDataSource("cell4Str", cell4Str);
  6872. designer.SetDataSource("cellStr", cellStr);
  6873. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6874. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6875. designer.SetDataSource("celllastStr", celllastStr);
  6876. Workbook wb = designer.Workbook;
  6877. var sheet = wb.Worksheets[0];
  6878. //绑定datatable数据集
  6879. designer.SetDataSource(dtdac1);
  6880. designer.SetDataSource(dtdac2);
  6881. designer.Process();
  6882. var rowStart = dtdac1.Rows.Count;
  6883. while (rowStart > 0)
  6884. {
  6885. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6886. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6887. startIndex++;
  6888. rowStart--;
  6889. }
  6890. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6891. startIndex += 1; //总计行
  6892. rowStart = dtdac2.Rows.Count;
  6893. while (rowStart > 0)
  6894. {
  6895. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6896. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6897. startIndex++;
  6898. rowStart--;
  6899. }
  6900. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6901. wb.CalculateFormula(true);
  6902. //模板文件名
  6903. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6904. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6905. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6906. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6907. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6908. }
  6909. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6910. {
  6911. //获取模板
  6912. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6913. //载入模板
  6914. Document doc = new Document(tempPath);
  6915. DocumentBuilder builder = new DocumentBuilder(doc);
  6916. Dictionary<string, string> dic = new Dictionary<string, string>();
  6917. dic.Add("GroupName", _DelegationInfo.TeamName);
  6918. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6919. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6920. string missionLeaderJob = "";//负责人job
  6921. //int groupNumber = 0; //团人数
  6922. if (DeleClientList.Count > 0)
  6923. {
  6924. missionLeader = DeleClientList[0]?.Name ?? "";
  6925. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6926. }
  6927. dic.Add("MissionLeader", missionLeader); //团负责人
  6928. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6929. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6930. #region MyRegion
  6931. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6932. //{
  6933. // List<string> list = new List<string>();
  6934. // try
  6935. // {
  6936. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6937. // foreach (var item in spilitArr)
  6938. // {
  6939. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6940. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6941. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6942. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6943. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6944. // list.Add(depName);
  6945. // list.Add(arrName);
  6946. // }
  6947. // list = list.Distinct().ToList();
  6948. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6949. // }
  6950. // catch (Exception)
  6951. // {
  6952. // dic.Add("ReturnCode", "行程录入不正确!");
  6953. // }
  6954. //}
  6955. //else
  6956. //{
  6957. // dic.Add("ReturnCode", "未录入行程!");
  6958. //}
  6959. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6960. dic.Add("ReturnCode", string.Join("、", countrys));
  6961. #endregion
  6962. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6963. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6964. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6965. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6966. //{
  6967. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6968. // dic.Add("Day", sp.Days.ToString());
  6969. //}
  6970. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6971. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6972. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6973. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6974. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6975. //培训人员名单
  6976. int cultivateRowIndex = 7;
  6977. foreach (var item in DeleClientList)
  6978. {
  6979. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6980. builder.Write(item.Name);
  6981. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6982. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6983. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6984. string birthDay = "";
  6985. if (item.Birthday != null)
  6986. {
  6987. DateTime dt = Convert.ToDateTime(item.Birthday);
  6988. birthDay = $"{dt.Year}.{dt.Month}";
  6989. }
  6990. builder.Write(birthDay);
  6991. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6992. builder.Write(item.Company);
  6993. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6994. builder.Write(item.Job);
  6995. cultivateRowIndex++;
  6996. }
  6997. //删除多余行
  6998. //cultivateRowIndex -= 2;
  6999. int delRows = 10 + 7 - cultivateRowIndex;
  7000. if (delRows > 0)
  7001. {
  7002. for (int i = 0; i < delRows; i++)
  7003. {
  7004. table1.Rows.RemoveAt(cultivateRowIndex);
  7005. //cultivateRowIndex++;
  7006. }
  7007. }
  7008. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7009. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7010. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7011. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7012. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7013. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7014. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7015. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7016. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7017. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7018. //其他费用
  7019. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7020. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7021. //其他费用合计
  7022. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7023. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7024. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7025. //公务舱合计
  7026. //国际旅费
  7027. //string outsideJJ = "";
  7028. //string allPriceJJ = "";
  7029. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7030. {
  7031. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7032. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7033. }
  7034. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7035. {
  7036. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7037. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7038. }
  7039. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7040. {
  7041. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7042. dic.Add("AirFeeTotal", airFeeTotalStr);
  7043. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7044. dic.Add("FeeTotal", feeTotalStr);
  7045. }
  7046. foreach (var key in dic.Keys)
  7047. {
  7048. builder.MoveToBookmark(key);
  7049. builder.Write(dic[key]);
  7050. }
  7051. //模板文件名
  7052. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7053. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7054. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7055. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7056. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7057. }
  7058. }
  7059. else if (dto.ExportType == 2) //表格
  7060. {
  7061. //利用键值对存放数据
  7062. Dictionary<string, string> dic = new Dictionary<string, string>();
  7063. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7064. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7065. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7066. dic.Add("Day", sp.Days.ToString());
  7067. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7068. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7069. {
  7070. //获取模板
  7071. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7072. //载入模板
  7073. Document doc = new Document(tempPath);
  7074. DocumentBuilder builder = new DocumentBuilder(doc);
  7075. dic.Add("TeamName", _DelegationInfo.TeamName);
  7076. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7077. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7078. string missionLeaderName = "",
  7079. missionLeaderJob = "";
  7080. if (DeleClientList.Count > 0)
  7081. {
  7082. missionLeaderName = DeleClientList[0].Name;
  7083. missionLeaderJob = DeleClientList[0].Job;
  7084. }
  7085. dic.Add("MissionLeaderName", missionLeaderName);
  7086. dic.Add("MissionLeaderJob", missionLeaderJob);
  7087. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7088. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7089. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7090. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7091. int rowCount = 10;//总人数行
  7092. int startRowIndex = 7; //起始行
  7093. for (int i = 0; i < DeleClientList.Count; i++)
  7094. {
  7095. builder.MoveToCell(0, startRowIndex, 0, 0);
  7096. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7097. builder.MoveToCell(0, startRowIndex, 1, 0);
  7098. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7099. builder.Write(sex);//性别
  7100. builder.MoveToCell(0, startRowIndex, 2, 0);
  7101. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7102. builder.MoveToCell(0, startRowIndex, 3, 0);
  7103. builder.Write(DeleClientList[i].Company);//工作单位
  7104. builder.MoveToCell(0, startRowIndex, 4, 0);
  7105. builder.Write(DeleClientList[i].Job);//职务及级别
  7106. builder.MoveToCell(0, startRowIndex, 5, 0);
  7107. builder.Write("");//人员属性
  7108. builder.MoveToCell(0, startRowIndex, 6, 0);
  7109. builder.Write("");//上次出国时间
  7110. startRowIndex++;
  7111. }
  7112. int nullRow = rowCount - DeleClientList.Count;//空行
  7113. for (int i = 0; i < nullRow; i++)
  7114. {
  7115. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7116. }
  7117. foreach (var key in dic.Keys)
  7118. {
  7119. builder.MoveToBookmark(key);
  7120. builder.Write(dic[key]);
  7121. }
  7122. //模板文件名
  7123. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7124. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7125. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7126. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7127. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7128. }
  7129. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7130. {
  7131. //获取模板
  7132. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7133. //载入模板
  7134. Document doc = new Document(tempPath);
  7135. DocumentBuilder builder = new DocumentBuilder(doc);
  7136. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7137. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7138. dic.Add("Names", Names);
  7139. int accommodationRows = 12;
  7140. //int foodandotherRows = 12;
  7141. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7142. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7143. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7144. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7145. int accommodationStartIndex = 6;
  7146. decimal dac1totalPrice = 0.00M;
  7147. foreach (var dac in dac1)
  7148. {
  7149. if (dac.SubTotal == 0)
  7150. {
  7151. continue;
  7152. }
  7153. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7154. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7155. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7156. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7157. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7158. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7159. builder.Write(currency);//币种
  7160. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7161. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7162. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7163. builder.Write("");//人数
  7164. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7165. builder.Write("");//天数
  7166. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7167. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7168. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7169. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7170. builder.Write(rate.ToString("#0.0000"));//汇率
  7171. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7172. decimal rbmPrice = rate * dac.SubTotal;
  7173. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7174. accommodationStartIndex++;
  7175. dac1totalPrice += rbmPrice;
  7176. }
  7177. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7178. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7179. builder.Write("小计");
  7180. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7181. builder.Write(dac1totalPrice.ToString("#0.00"));
  7182. accommodationStartIndex++;
  7183. int nullRow = accommodationRows - dac1.Count;
  7184. //删除空行
  7185. //if (nullRow > 0)
  7186. //{
  7187. // int rowIndex = accommodationStartIndex;
  7188. // for (int i = 0; i < nullRow; i++)
  7189. // {
  7190. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7191. // row.Remove();
  7192. // rowIndex++;
  7193. // }
  7194. //}
  7195. if (dac2.Count == dac3.Count)//国家 币种 金额
  7196. {
  7197. for (int i = 0; i < dac2.Count; i++)
  7198. {
  7199. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7200. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7201. }
  7202. }
  7203. int foodandotherStartIndex = 19;//
  7204. decimal dac2totalPrice = 0.00M;
  7205. foreach (var dac in dac2)
  7206. {
  7207. if (dac.SubTotal == 0)
  7208. {
  7209. continue;
  7210. }
  7211. //foodandotherStartIndex = 12;
  7212. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7213. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7214. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7215. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7216. builder.Write(currency);//币种
  7217. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7218. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7219. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7220. builder.Write("");//人数
  7221. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7222. builder.Write("");//天数
  7223. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7224. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7225. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7226. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7227. builder.Write(rate.ToString("#0.0000"));//汇率
  7228. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7229. decimal rbmPrice = rate * dac.SubTotal;
  7230. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7231. foodandotherStartIndex++;
  7232. dac2totalPrice += rbmPrice;
  7233. }
  7234. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7235. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7236. //删除空行
  7237. //if (dac2.Count < foodandotherRows)
  7238. //{
  7239. // while (table2.Rows.Count > dac2.Count)
  7240. // {
  7241. // table2.Rows.RemoveAt(dac2.Count);
  7242. // }
  7243. //}
  7244. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7245. string otherFeeStr = "";
  7246. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7247. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7248. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7249. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7250. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7251. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7252. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7253. foreach (var otherInfo in dac5)
  7254. {
  7255. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7256. }
  7257. #endregion
  7258. if (otherFeeStr.Length > 0)
  7259. {
  7260. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7261. otherFeeStr = $"({otherFeeStr})";
  7262. dic.Add("OtherFeeStr", otherFeeStr);
  7263. }
  7264. foreach (var key in dic.Keys)
  7265. {
  7266. builder.MoveToBookmark(key);
  7267. builder.Write(dic[key]);
  7268. }
  7269. //模板文件名
  7270. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7271. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7272. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7273. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7274. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7275. }
  7276. }
  7277. else if (dto.ExportType == 3)
  7278. {
  7279. if (dto.SubTypeId == 1) //团组成员名单
  7280. {
  7281. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7282. //获取模板
  7283. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7284. //载入模板
  7285. Document doc = new Document(tempPath);
  7286. DocumentBuilder builder = new DocumentBuilder(doc);
  7287. //获取word里所有表格
  7288. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7289. //获取所填表格的序数
  7290. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7291. var rowStart = tableOne.Rows[0]; //获取第1行
  7292. //循环赋值
  7293. for (int i = 0; i < DeleClientList.Count; i++)
  7294. {
  7295. builder.MoveToCell(0, i + 1, 0, 0);
  7296. builder.Write(DeleClientList[i].Name);
  7297. builder.MoveToCell(0, i + 1, 1, 0);
  7298. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7299. builder.Write(sex);
  7300. builder.MoveToCell(0, i + 1, 2, 0);
  7301. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7302. builder.MoveToCell(0, i + 1, 3, 0);
  7303. builder.Write(DeleClientList[i].Company);
  7304. builder.MoveToCell(0, i + 1, 4, 0);
  7305. builder.Write(DeleClientList[i].Job);
  7306. }
  7307. //删除多余行
  7308. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7309. {
  7310. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7311. }
  7312. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7313. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7314. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7315. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7316. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7317. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7318. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7319. }
  7320. }
  7321. return Ok(JsonView(400, "操作失败!", ""));
  7322. }
  7323. catch (Exception ex)
  7324. {
  7325. return Ok(JsonView(400, ex.Message, ""));
  7326. }
  7327. }
  7328. /// <summary>
  7329. /// 获取三公费用标准city
  7330. /// </summary>
  7331. /// <param name="placeData"></param>
  7332. /// <param name="nationalTravelFeeId"></param>
  7333. /// <returns></returns>
  7334. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7335. {
  7336. string _city = string.Empty;
  7337. if (placeData.Count < 1) return _city;
  7338. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7339. if (data == null) return _city;
  7340. string country = data.Country;
  7341. string city = data.City;
  7342. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7343. else _city = city;
  7344. return _city;
  7345. }
  7346. ///// <summary>
  7347. ///// 团组模块 - 出入境费用 - 明细表导出
  7348. ///// </summary>
  7349. ///// <returns></returns>
  7350. //[HttpPost]
  7351. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7352. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7353. //{
  7354. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7355. // if (data.Code != 0)
  7356. // {
  7357. // return Ok(JsonView(false, data.Msg));
  7358. // }
  7359. // return Ok(JsonView(true, data.Msg, data.Data));
  7360. //}
  7361. /// <summary>
  7362. /// 团组模块 - 出入境费用 - 一键清空
  7363. /// </summary>
  7364. /// <returns></returns>
  7365. [HttpPost]
  7366. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7368. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7369. {
  7370. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7371. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7372. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7373. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7374. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7375. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7376. .SetColumns(x => new Grp_DayOtherPrice
  7377. {
  7378. IsDel = 1,
  7379. DeleteUserId = dto.UserId,
  7380. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7381. })
  7382. .ExecuteCommandAsync();
  7383. if (_view.Code == 0)
  7384. {
  7385. return Ok(JsonView(true, "操作成功"));
  7386. }
  7387. return Ok(JsonView(false, "操作失败"));
  7388. }
  7389. /// <summary>
  7390. /// 团组模块 - 出入境费用 - 子项删除
  7391. /// </summary>
  7392. /// <returns></returns>
  7393. [HttpPost]
  7394. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7396. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7397. {
  7398. try
  7399. {
  7400. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7401. if (data.Code != 0)
  7402. {
  7403. return Ok(JsonView(false, data.Msg));
  7404. }
  7405. return Ok(JsonView(true, "操作成功!", data.Data));
  7406. }
  7407. catch (Exception ex)
  7408. {
  7409. return Ok(JsonView(false, ex.Message));
  7410. }
  7411. }
  7412. /// <summary>
  7413. /// 删除三公其他费用
  7414. /// </summary>
  7415. /// <param name="dto"></param>
  7416. /// <returns></returns>
  7417. [HttpPost]
  7418. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7419. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7420. {
  7421. var jw = JsonView(false, "删除失败!");
  7422. var data = new Grp_DayOtherPrice()
  7423. {
  7424. Id = dto.Id,
  7425. IsDel = 1,
  7426. DeleteUserId = dto.DeleteUserId,
  7427. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7428. };
  7429. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7430. if (del > 0)
  7431. {
  7432. jw.Code = 200;
  7433. jw.Msg = "删除成功!";
  7434. }
  7435. return Ok(jw);
  7436. }
  7437. /// <summary>
  7438. /// 团组模块 - 出入境国家费用标准 List
  7439. /// </summary>
  7440. /// <returns></returns>
  7441. [HttpPost]
  7442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7443. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7444. {
  7445. int provinceId = dto.ProvinceId;
  7446. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7447. var nftData = await _sqlSugar
  7448. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7449. JoinType.Left, ntf.Currency == sd1.Id,
  7450. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7451. JoinType.Left, ntf.ProvinceId == c.Id
  7452. ))
  7453. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7454. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7455. {
  7456. Id = ntf.Id,
  7457. ProvinceId = ntf.ProvinceId,
  7458. ProvinceName = c.Name_CN,
  7459. Continent = ntf.Continent,
  7460. Country = ntf.Country,
  7461. City = ntf.City,
  7462. Currency = ntf.Currency,
  7463. CurrencyCode = sd1.Name,
  7464. CurrencyName = sd1.Remark,
  7465. RoomCost = ntf.RoomCost,
  7466. FoodCost = ntf.FoodCost,
  7467. PublicCost = ntf.PublicCost,
  7468. LastUpdateUserId = ntf.LastUpdateUserId,
  7469. LastUpdateUserName = u.CnName,
  7470. LastUpdateTime = ntf.LastUpdateTime
  7471. })
  7472. .ToListAsync();
  7473. return Ok(JsonView(true, "查询成功!", nftData));
  7474. }
  7475. /// <summary>
  7476. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7477. /// </summary>
  7478. /// <returns></returns>
  7479. [HttpPost]
  7480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7481. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7482. {
  7483. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7484. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7485. List<string> countryData = new List<string>();
  7486. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7487. countryData = countryData.Distinct().ToList();
  7488. List<dynamic> dataSource = new List<dynamic>();
  7489. foreach (var item in countryData)
  7490. {
  7491. var cityData1 = new List<string>();
  7492. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7493. var countryData2 = new
  7494. {
  7495. CountryName = item,
  7496. CityData = cityData1
  7497. };
  7498. if (!dataSource.Contains(countryData2))
  7499. {
  7500. dataSource.Add(countryData2);
  7501. }
  7502. }
  7503. return Ok(JsonView(true, "查询成功!", dataSource));
  7504. }
  7505. /// <summary>
  7506. /// 团组模块 - 出入境国家费用标准 Page List
  7507. /// </summary>
  7508. /// <returns></returns>
  7509. [HttpPost]
  7510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7511. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7512. {
  7513. int portId = dto.PortType,
  7514. pageIndex = dto.PageIndex,
  7515. pageSize = dto.PageSize;
  7516. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7517. if (pageIndex == 0) pageIndex = 1;
  7518. if (pageSize == 0) pageSize = 10;
  7519. RefAsync<int> total = 0;
  7520. var nationalTravelFeeData = await _sqlSugar
  7521. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7522. JoinType.Left, ntf.Currency == sd1.Id,
  7523. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7524. JoinType.Left, ntf.ProvinceId == sd2.Id
  7525. ))
  7526. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7527. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7528. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7529. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7530. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7531. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7532. {
  7533. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7534. Id = ntf.Id,
  7535. ProvinceId = ntf.ProvinceId,
  7536. ProvinceName = sd2.Name_CN,
  7537. Continent = ntf.Continent,
  7538. Country = ntf.Country,
  7539. City = ntf.City,
  7540. Currency = ntf.Currency,
  7541. CurrencyCode = sd1.Name,
  7542. CurrencyName = sd1.Remark,
  7543. RoomCost = ntf.RoomCost,
  7544. FoodCost = ntf.FoodCost,
  7545. PublicCost = ntf.PublicCost,
  7546. LastUpdateUserId = ntf.LastUpdateUserId,
  7547. LastUpdateUserName = u.CnName,
  7548. LastUpdateTime = ntf.LastUpdateTime,
  7549. Remark = ntf.Remark
  7550. })
  7551. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7552. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7553. }
  7554. /// <summary>
  7555. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7556. /// </summary>
  7557. /// <returns></returns>
  7558. [HttpPost]
  7559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7560. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7561. {
  7562. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7563. int portId = dto.PortType;
  7564. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7565. string whereSql = string.Empty;
  7566. if (!string.IsNullOrEmpty(dto.Country))
  7567. {
  7568. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7569. }
  7570. if (!string.IsNullOrEmpty(dto.City))
  7571. {
  7572. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7573. }
  7574. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7575. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7576. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7577. From Grp_NationalTravelFee gntf
  7578. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7579. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7580. Where gntf.Isdel = 0 {0} ", whereSql);
  7581. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7582. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7583. }
  7584. /// <summary>
  7585. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7586. /// </summary>
  7587. /// <returns></returns>
  7588. [HttpPost]
  7589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7590. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7591. {
  7592. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7593. }
  7594. /// <summary>
  7595. /// 团组模块 - 出入境国家费用标准 - Del
  7596. /// </summary>
  7597. /// <returns></returns>
  7598. [HttpPost]
  7599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7600. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7601. {
  7602. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7603. {
  7604. Id = dto.Id,
  7605. DeleteUserId = dto.DeleteUserId,
  7606. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7607. IsDel = 1
  7608. };
  7609. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7610. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7611. .WhereColumns(it => new { it.Id })
  7612. .ExecuteCommandAsync();
  7613. if (delStatus <= 0)
  7614. {
  7615. return Ok(JsonView(false, "删除失败!"));
  7616. }
  7617. return Ok(JsonView(true, "操作成功!"));
  7618. }
  7619. /// <summary>
  7620. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7621. /// 注:Get 请求Headers 加 Token
  7622. /// </summary>
  7623. /// <param name="groupId"></param>
  7624. /// <returns></returns>
  7625. [HttpGet("{groupId}")]
  7626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7627. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7628. {
  7629. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7630. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7631. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7632. data.ForEach(x =>
  7633. {
  7634. x.CreateUserId = _currUserInfo.UserId;
  7635. });
  7636. if (data.Any())
  7637. {
  7638. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7639. if (add > 0)
  7640. {
  7641. return Ok(JsonView(true, "操作成功!"));
  7642. }
  7643. }
  7644. return Ok(JsonView(false, "未操作!"));
  7645. }
  7646. #endregion
  7647. #region 团组经理模块 出入境费用-草稿
  7648. /// <summary>
  7649. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7650. /// </summary>
  7651. /// <returns></returns>
  7652. [HttpGet]
  7653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7654. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7655. {
  7656. var provData = await _groupRepository.ProvinceBasicSource();
  7657. return Ok(JsonView(true, "查询成功!", provData));
  7658. }
  7659. /// <summary>
  7660. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7661. /// </summary>
  7662. /// <returns></returns>
  7663. [HttpGet("{provinceId}")]
  7664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7665. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7666. {
  7667. //验证城市归属并给默认值
  7668. if (provinceId < 1) provinceId = 122;
  7669. /*
  7670. * 122 四川
  7671. * 108 贵州
  7672. * 103 重庆
  7673. * 132 云南
  7674. */
  7675. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7676. return Ok(JsonView(true, "查询成功!", new
  7677. {
  7678. WordTypeData = wordTypeData,
  7679. ExcelTypeData = excelTypeData,
  7680. }));
  7681. }
  7682. /// <summary>
  7683. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7684. /// </summary>
  7685. /// <returns></returns>
  7686. [HttpPost]
  7687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7688. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7689. {
  7690. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7691. .Where(x => x.IsDel == 0)
  7692. .OrderByDescending(x => x.CreateTime)
  7693. .Select(x => new { x.Id, x.DraftName })
  7694. .ToListAsync();
  7695. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7696. //SetDataInfoView
  7697. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7698. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7699. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7700. int provinceId = dto.ProvinceId;
  7701. if (provinceId < 1) provinceId = 122;
  7702. /*
  7703. * 122 四川
  7704. * 108 贵州
  7705. * 103 重庆
  7706. * 132 云南
  7707. */
  7708. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7709. //默认币种显示
  7710. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7711. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7712. return Ok(JsonView(true, "查询成功!", new
  7713. {
  7714. DraftNameDatas = draftNameDatas,
  7715. CurrencyData = _CurrencyData,
  7716. WordTypeData = wordTypeData,
  7717. ExcelTypeData = excelTypeData,
  7718. CurrencyInit = _currencyInfos,
  7719. ViewPermissionData = viewPermissionData
  7720. }));
  7721. }
  7722. /// <summary>
  7723. /// 团组模块 - 出入境费用-草稿
  7724. /// 实时汇率 tips
  7725. /// 机票费用 tips
  7726. /// </summary>
  7727. /// <returns></returns>
  7728. [HttpPost]
  7729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7730. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7731. {
  7732. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7733. return Ok(JsonView(true, "查询成功!", new
  7734. {
  7735. //GroupNameData = groupNameData.Data,
  7736. //visaData = visaData.Data,
  7737. //airData = airData.Data,
  7738. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7739. }));
  7740. }
  7741. /// <summary>
  7742. /// 团组模块 - 出入境费用-草稿
  7743. /// 签证费用 tips
  7744. /// </summary>
  7745. /// <returns></returns>
  7746. [HttpPost]
  7747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7748. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7749. {
  7750. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7751. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7752. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7753. .Select(x => x.NationalTravelFeeId)
  7754. .Distinct()
  7755. .ToListAsync();
  7756. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7757. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7758. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7759. .Select(x => x.Country)
  7760. .Distinct()
  7761. .ToArrayAsync();
  7762. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7763. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7764. return Ok(JsonView(true, "查询成功!", new
  7765. {
  7766. totalAmt = totalAmt,
  7767. remark = remark
  7768. }));
  7769. }
  7770. /// <summary>
  7771. /// 团组模块 - 出入境费用-草稿 - Info
  7772. /// </summary>
  7773. /// <returns></returns>
  7774. [HttpPost]
  7775. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7777. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7778. {
  7779. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7780. }
  7781. /// <summary>
  7782. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7783. /// </summary>
  7784. /// <returns></returns>
  7785. [HttpPost]
  7786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7787. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7788. {
  7789. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7790. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7791. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7792. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7793. foreach (var userId in dto.UserIds)
  7794. {
  7795. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7796. }
  7797. if (permissions.Any())
  7798. {
  7799. _sqlSugar.BeginTran();
  7800. try
  7801. {
  7802. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7803. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7804. if (result < 1)
  7805. {
  7806. _sqlSugar.RollbackTran();
  7807. return Ok(JsonView(false));
  7808. }
  7809. }
  7810. catch (Exception ex)
  7811. {
  7812. _sqlSugar.RollbackTran();
  7813. return Ok(JsonView(false, ex.Message));
  7814. }
  7815. _sqlSugar.CommitTran();
  7816. return Ok(JsonView(true));
  7817. }
  7818. return Ok(JsonView(false));
  7819. }
  7820. /// <summary>
  7821. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7822. /// </summary>
  7823. /// <returns></returns>
  7824. [HttpPost]
  7825. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7827. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7828. {
  7829. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7830. if (data.Code != 0)
  7831. {
  7832. return Ok(JsonView(false, data.Msg));
  7833. }
  7834. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7835. //汇率信息记录
  7836. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7837. return Ok(JsonView(true, data.Msg, data.Data));
  7838. }
  7839. /// <summary>
  7840. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7841. /// </summary>
  7842. /// <param name="dto"></param>
  7843. /// <returns></returns>
  7844. [HttpPost]
  7845. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7847. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7848. {
  7849. try
  7850. {
  7851. var id = dto.Id;
  7852. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7853. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7854. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7855. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7856. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7857. 3 团组成员名单 1 团组成员名单", ""));
  7858. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7859. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7860. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7861. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7862. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7863. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7864. //数据源
  7865. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7866. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7867. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7868. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7869. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7870. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7871. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7872. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7873. .Select((x, a, b) => new
  7874. {
  7875. x.Index,
  7876. itemName = a.Name,
  7877. CurrencyStr = b.Name,
  7878. x.Cost,
  7879. x.SubTotal,
  7880. x.Remark
  7881. })
  7882. .OrderBy((x) => x.Index)
  7883. .ToList(); //其他款项费用
  7884. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7885. var peiceItemCurrencys = new List<string>();
  7886. if (_DayAndCosts.Any())
  7887. {
  7888. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7889. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7890. }
  7891. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7892. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7893. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7894. {
  7895. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7896. }
  7897. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7898. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7899. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7900. if (dto.ExportType == 1) //明细表
  7901. {
  7902. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7903. {
  7904. //获取模板
  7905. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7906. //载入模板
  7907. Document doc = new Document(tempPath);
  7908. DocumentBuilder builder = new DocumentBuilder(doc);
  7909. //利用键值对存放数据
  7910. Dictionary<string, string> dic = new Dictionary<string, string>();
  7911. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7912. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7913. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7914. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7915. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7916. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7917. //境内费用(其他费用)
  7918. if (_EnterExitCosts.ChoiceOne == 1)
  7919. {
  7920. string row1_1 = "";
  7921. if (_EnterExitCosts.Visa > 0)
  7922. {
  7923. //insidePayTotal += _EnterExitCosts.Visa;
  7924. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7925. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7926. //{
  7927. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7928. //}
  7929. }
  7930. string row1_2 = "";
  7931. if (_EnterExitCosts.YiMiao > 0)
  7932. {
  7933. //insidePayTotal += _EnterExitCosts.YiMiao;
  7934. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7935. }
  7936. if (_EnterExitCosts.HeSuan > 0)
  7937. {
  7938. //insidePayTotal += _EnterExitCosts.HeSuan;
  7939. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7940. }
  7941. if (_EnterExitCosts.Service > 0)
  7942. {
  7943. //insidePayTotal += _EnterExitCosts.Service;
  7944. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7945. }
  7946. string row1_3 = "";
  7947. if (_EnterExitCosts.Safe > 0)
  7948. {
  7949. //insidePayTotal += _EnterExitCosts.Safe;
  7950. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7951. }
  7952. if (_EnterExitCosts.Ticket > 0)
  7953. {
  7954. //insidePayTotal += _EnterExitCosts.Ticket;
  7955. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7956. }
  7957. string row1 = "";
  7958. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7959. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7960. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7961. row1 += $"备注:{_EnterExitCosts.Remark}";
  7962. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7963. dic.Add("Row1Str", row1);
  7964. }
  7965. string airTotalStr = string.Empty,
  7966. airPriceStr = string.Empty;
  7967. //经济舱
  7968. if (_EnterExitCosts.SumJJC == 1)
  7969. {
  7970. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7971. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7972. }
  7973. //公务舱
  7974. if (_EnterExitCosts.SumGWC == 1)
  7975. {
  7976. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7977. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7978. }
  7979. //头等舱
  7980. if (_EnterExitCosts.SumTDC == 1)
  7981. {
  7982. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7983. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7984. }
  7985. //汇率描述
  7986. string rateStr = "";
  7987. if (peiceItemCurrencyInfos.Any())
  7988. {
  7989. rateStr = "\r\n汇率描述:";
  7990. foreach (var item in peiceItemCurrencyInfos)
  7991. {
  7992. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7993. }
  7994. }
  7995. string twoItemRemark = "备注:";
  7996. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7997. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7998. dic.Add("AirTotalStr", airTotalStr);
  7999. dic.Add("AirPriceStr", airPriceStr);
  8000. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8001. dic.Add("TwoItemRemark", twoItemRemark);
  8002. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8003. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8004. int table1Row = 0,
  8005. table2Row = 0,
  8006. table3Row = 0,
  8007. table4Row = 0,
  8008. table5Row = 0;
  8009. //住宿费
  8010. if (_EnterExitCosts.ChoiceThree == 1)
  8011. {
  8012. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8013. table1Row = dac1.Count;
  8014. #region 填充word表格内容
  8015. for (int i = 0; i < dac1.Count; i++)
  8016. {
  8017. var dac = dac1[i];
  8018. if (dac == null) continue;
  8019. builder.MoveToCell(0, i, 0, 0);
  8020. builder.Write("第" + dac.Days.ToString() + "晚:");
  8021. builder.MoveToCell(0, i, 1, 0);
  8022. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8023. //builder.Write(dac.Place == null ? "" : dac.Place);
  8024. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8025. builder.MoveToCell(0, i, 2, 0);
  8026. builder.Write("费用标准:");
  8027. string curr = "";
  8028. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8029. if (currData != null)
  8030. {
  8031. curr = currData.Name;
  8032. }
  8033. builder.MoveToCell(0, i, 3, 0);
  8034. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8035. builder.MoveToCell(0, i, 4, 0);
  8036. builder.Write("费用小计:");
  8037. builder.MoveToCell(0, i, 5, 0);
  8038. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8039. }
  8040. #endregion
  8041. }
  8042. else dic.Add("SubZS", "0.00");
  8043. //删除多余行
  8044. while (table1.Rows.Count > table1Row)
  8045. {
  8046. table1.Rows.RemoveAt(table1Row);
  8047. }
  8048. //伙食费
  8049. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8050. if (_EnterExitCosts.ChoiceFour == 1)
  8051. {
  8052. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8053. table2Row = dac2.Count;
  8054. #region 填充word表格内容
  8055. for (int i = 0; i < dac2.Count; i++)
  8056. {
  8057. var dac = dac2[i];
  8058. if (dac == null) continue;
  8059. builder.MoveToCell(1, i, 0, 0);
  8060. builder.Write("第" + dac.Days.ToString() + "天:");
  8061. builder.MoveToCell(1, i, 1, 0);
  8062. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8063. builder.MoveToCell(1, i, 2, 0);
  8064. builder.Write("费用标准:");
  8065. string curr = "";
  8066. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8067. if (currData != null)
  8068. {
  8069. curr = currData.Name;
  8070. }
  8071. builder.MoveToCell(1, i, 3, 0);
  8072. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8073. builder.MoveToCell(1, i, 4, 0);
  8074. builder.Write("费用小计:");
  8075. builder.MoveToCell(1, i, 5, 0);
  8076. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8077. }
  8078. #endregion
  8079. }
  8080. else dic.Add("SubHS", "0.00");
  8081. //删除多余行
  8082. while (table2.Rows.Count > table2Row)
  8083. {
  8084. table2.Rows.RemoveAt(table2Row);
  8085. }
  8086. //公杂费
  8087. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8088. if (_EnterExitCosts.ChoiceFive == 1)
  8089. {
  8090. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8091. table3Row = dac3.Count;
  8092. #region 填充word表格内容
  8093. for (int i = 0; i < dac3.Count; i++)
  8094. {
  8095. var dac = dac3[i];
  8096. if (dac == null) continue;
  8097. builder.MoveToCell(2, i, 0, 0);
  8098. builder.Write("第" + dac.Days.ToString() + "天:");
  8099. builder.MoveToCell(2, i, 1, 0);
  8100. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8101. builder.MoveToCell(2, i, 2, 0);
  8102. builder.Write("费用标准:");
  8103. string curr = "";
  8104. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8105. if (currData != null)
  8106. {
  8107. curr = currData.Name;
  8108. }
  8109. builder.MoveToCell(2, i, 3, 0);
  8110. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8111. builder.MoveToCell(2, i, 4, 0);
  8112. builder.Write("费用小计:");
  8113. builder.MoveToCell(2, i, 5, 0);
  8114. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8115. }
  8116. //删除多余行
  8117. while (table3.Rows.Count > table3Row)
  8118. {
  8119. table3.Rows.RemoveAt(table3Row);
  8120. }
  8121. #endregion
  8122. }
  8123. else dic.Add("SubGZF", "0.00");
  8124. //删除多余行
  8125. while (table3.Rows.Count > table3Row)
  8126. {
  8127. table3.Rows.RemoveAt(table3Row);
  8128. }
  8129. //培训费
  8130. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8131. if (_EnterExitCosts.ChoiceSix == 1)
  8132. {
  8133. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8134. dic.Add("SubPX", pxStr);
  8135. table4Row = dac4.Count;
  8136. #region 填充word表格内容
  8137. for (int i = 0; i < dac4.Count; i++)
  8138. {
  8139. var dac = dac4[i];
  8140. if (dac == null) continue;
  8141. builder.MoveToCell(3, i, 0, 0);
  8142. builder.Write("第" + dac.Days.ToString() + "天:");
  8143. builder.MoveToCell(3, i, 1, 0);
  8144. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8145. builder.MoveToCell(3, i, 2, 0);
  8146. builder.Write("费用标准:");
  8147. string curr = "";
  8148. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8149. if (currData != null)
  8150. {
  8151. curr = currData.Name;
  8152. }
  8153. builder.MoveToCell(3, i, 3, 0);
  8154. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8155. builder.MoveToCell(3, i, 4, 0);
  8156. builder.Write("费用小计:");
  8157. builder.MoveToCell(3, i, 5, 0);
  8158. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8159. }
  8160. #endregion
  8161. }
  8162. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8163. //删除多余行
  8164. while (table4.Rows.Count > table4Row)
  8165. {
  8166. table4.Rows.RemoveAt(table4Row);
  8167. }
  8168. //其他费用
  8169. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8170. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8171. {
  8172. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8173. dic.Add("titleQi", qtStr);
  8174. table5Row = dac5.Count;
  8175. #region 填充word表格内容
  8176. for (int i = 0; i < dac5.Count; i++)
  8177. {
  8178. var dac = dac5[i];
  8179. if (dac == null) continue;
  8180. builder.MoveToCell(4, i, 0, 0);
  8181. builder.Write("第" + dac.Index.ToString() + "项:");
  8182. builder.MoveToCell(4, i, 1, 0);
  8183. builder.Write(dac.itemName);
  8184. builder.MoveToCell(4, i, 2, 0);
  8185. builder.Write("费用标准:");
  8186. builder.MoveToCell(4, i, 3, 0);
  8187. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8188. builder.MoveToCell(4, i, 4, 0);
  8189. builder.Write("费用小计:");
  8190. builder.MoveToCell(4, i, 5, 0);
  8191. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8192. builder.MoveToCell(4, i, 6, 0);
  8193. builder.Write("备注:");
  8194. builder.MoveToCell(4, i, 7, 0);
  8195. builder.Write(dac.Remark);
  8196. }
  8197. #endregion
  8198. }
  8199. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8200. //删除多余行
  8201. while (table5.Rows.Count > table5Row)
  8202. {
  8203. table5.Rows.RemoveAt(table5Row);
  8204. }
  8205. //加上其他费用
  8206. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8207. decimal subJJC = 0.00M,
  8208. subGWC = 0.00M,
  8209. subTDC = 0.00M;
  8210. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8211. string totalLabel = string.Format("全部费用总计:");
  8212. //经济舱
  8213. if (_EnterExitCosts.SumJJC == 1)
  8214. {
  8215. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8216. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8217. }
  8218. //公务舱
  8219. if (_EnterExitCosts.SumGWC == 1)
  8220. {
  8221. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8222. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8223. }
  8224. //头等舱
  8225. if (_EnterExitCosts.SumTDC == 1)
  8226. {
  8227. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8228. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8229. }
  8230. //TotalLabel
  8231. dic.Add("TotalLabel", totalLabel);
  8232. #region 填充word模板书签内容
  8233. foreach (var key in dic.Keys)
  8234. {
  8235. Bookmark bookmark = doc.Range.Bookmarks[key];
  8236. if (bookmark != null)
  8237. {
  8238. builder.MoveToBookmark(key);
  8239. builder.Write(dic[key]);
  8240. }
  8241. }
  8242. #endregion
  8243. //文件名
  8244. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8245. strFileName = CommonFun.ValidFileName(strFileName);
  8246. AsposeHelper.removewatermark_v2180();
  8247. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8248. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8249. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8250. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8251. }
  8252. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8253. {
  8254. //获取模板
  8255. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8256. //载入模板
  8257. Document doc = new Document(tempPath);
  8258. DocumentBuilder builder = new DocumentBuilder(doc);
  8259. Dictionary<string, string> dic = new Dictionary<string, string>();
  8260. string returnCodeLabel = string.Empty;
  8261. if (nationalTravelFeeData.Any())
  8262. {
  8263. List<string> list = new List<string>();
  8264. foreach (var item in nationalTravelFeeData)
  8265. {
  8266. list.Add($"{item.Country}({item.City})");
  8267. }
  8268. list = list.Distinct().ToList();
  8269. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8270. }
  8271. var countryLabel = string.Empty;
  8272. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8273. if (countryData.Any())
  8274. {
  8275. countryLabel = string.Join("、", countryData);
  8276. }
  8277. dic.Add("ReturnCodeAir", returnCodeLabel);
  8278. dic.Add("VisitStartDate", "-");
  8279. dic.Add("VisitEndDate", "-");
  8280. dic.Add("Day", "-");
  8281. dic.Add("VisitCountry", countryLabel);
  8282. dic.Add("ClientUnit", "-");
  8283. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8284. //dic.Add("Names", Names);
  8285. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8286. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8287. decimal dac1totalPrice = 0.00M;
  8288. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8289. foreach (var dac in dac1)
  8290. {
  8291. if (dac.SubTotal == 0.00M)
  8292. {
  8293. continue;
  8294. }
  8295. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8296. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8297. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8298. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8299. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8300. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8301. builder.Write(currency);//币种
  8302. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8303. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8304. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8305. builder.Write("");//人数
  8306. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8307. builder.Write("");//天数
  8308. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8309. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8310. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8311. decimal rate = 0.00M;
  8312. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8313. builder.Write(rate.ToString("#0.0000"));//汇率
  8314. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8315. decimal rbmPrice = dac.SubTotal;
  8316. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8317. accommodationStartIndex++;
  8318. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8319. }
  8320. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8321. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8322. {
  8323. table1.Rows.RemoveAt(i - 1);
  8324. foodandotherStartIndex--;
  8325. }
  8326. if (dac2.Count == dac3.Count)//国家 币种 金额
  8327. {
  8328. for (int i = 0; i < dac2.Count; i++)
  8329. {
  8330. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8331. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8332. }
  8333. }
  8334. decimal dac2totalPrice = 0.00M;
  8335. foreach (var dac in dac2)
  8336. {
  8337. if (dac.SubTotal == 0)
  8338. {
  8339. continue;
  8340. }
  8341. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8342. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8343. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8344. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8345. builder.Write(currency);//币种
  8346. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8347. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8348. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8349. builder.Write("");//人数
  8350. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8351. builder.Write("");//天数
  8352. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8353. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8354. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8355. decimal rate = 0.00M;
  8356. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8357. builder.Write(rate.ToString("#0.0000"));//汇率
  8358. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8359. decimal rbmPrice = dac.SubTotal;
  8360. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8361. foodandotherStartIndex++;
  8362. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8363. }
  8364. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8365. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8366. {
  8367. table1.Rows.RemoveAt(i - 1);
  8368. }
  8369. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8370. string otherFeeStr = "";
  8371. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8372. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8373. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8374. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8375. foreach (var otherInfo in dac5)
  8376. {
  8377. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8378. }
  8379. #endregion
  8380. if (otherFeeStr.Length > 0)
  8381. {
  8382. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8383. otherFeeStr = $"({otherFeeStr})";
  8384. dic.Add("OtherFeeStr", otherFeeStr);
  8385. }
  8386. //总计
  8387. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8388. //国际旅费
  8389. string outsideAir = string.Empty;
  8390. string allPriceAir = string.Empty;
  8391. if (_EnterExitCosts.SumJJC == 1)
  8392. {
  8393. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8394. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8395. }
  8396. if (_EnterExitCosts.SumGWC == 1)
  8397. {
  8398. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8399. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8400. }
  8401. if (_EnterExitCosts.SumTDC == 1)
  8402. {
  8403. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8404. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8405. }
  8406. dic.Add("InTravelPrice", $"({outsideAir})");
  8407. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8408. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8409. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8410. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8411. foreach (var key in dic.Keys)
  8412. {
  8413. builder.MoveToBookmark(key);
  8414. builder.Write(dic[key]);
  8415. }
  8416. //模板文件名
  8417. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8418. strFileName = CommonFun.ValidFileName(strFileName);
  8419. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8420. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8421. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8422. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8423. }
  8424. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8425. {
  8426. //获取模板
  8427. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8428. //载入模板
  8429. WorkbookDesigner designer = new WorkbookDesigner();
  8430. designer.Workbook = new Workbook(tempPath);
  8431. Dictionary<string, string> dic = new Dictionary<string, string>();
  8432. string returnCodeLabel = string.Empty;
  8433. if (nationalTravelFeeData.Any())
  8434. {
  8435. List<string> list = new List<string>();
  8436. foreach (var item in nationalTravelFeeData)
  8437. {
  8438. list.Add($"{item.Country}({item.City})");
  8439. }
  8440. list = list.Distinct().ToList();
  8441. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8442. }
  8443. var countryLabel = string.Empty;
  8444. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8445. if (countryData.Any())
  8446. {
  8447. countryLabel = string.Join("、", countryData);
  8448. }
  8449. dic.Add("ReturnCodeAir", returnCodeLabel);
  8450. dic.Add("VisitStartDate", "-");
  8451. dic.Add("VisitEndDate", "-");
  8452. dic.Add("Day", "0");
  8453. dic.Add("VisitCountry", countryLabel);
  8454. dic.Add("ClientUnit", "-");
  8455. designer.SetDataSource("ClientUnit", "-");
  8456. designer.SetDataSource("VisitCountry", countryLabel);
  8457. designer.SetDataSource("Group", "-");
  8458. designer.SetDataSource("ClientUnitTitle", "-");
  8459. designer.SetDataSource("Name", "-");
  8460. designer.SetDataSource("VisitStartDate", "-");
  8461. designer.SetDataSource("Day", "0");
  8462. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8463. designer.SetDataSource("ReturnCodeAir", "-");
  8464. int startIndex = 10;
  8465. const int startIndexcopy = 10;
  8466. if (dac2.Count == dac3.Count)//国家 币种 金额
  8467. {
  8468. for (int i = 0; i < dac2.Count; i++)
  8469. {
  8470. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8471. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8472. }
  8473. }
  8474. DataTable dtdac1 = new DataTable();
  8475. List<string> place = new List<string>();
  8476. dtdac1.Columns.AddRange(new DataColumn[] {
  8477. new DataColumn(){ ColumnName = "city"},
  8478. new DataColumn(){ ColumnName = "curr"},
  8479. new DataColumn(){ ColumnName = "criterion"},
  8480. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8481. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8482. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8483. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8484. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8485. });
  8486. DataTable dtdac2 = new DataTable();
  8487. dtdac2.Columns.AddRange(new DataColumn[] {
  8488. new DataColumn(){ ColumnName = "city"},
  8489. new DataColumn(){ ColumnName = "curr"},
  8490. new DataColumn(){ ColumnName = "criterion"},
  8491. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8492. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8493. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8494. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8495. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8496. });
  8497. dtdac1.TableName = "tb1";
  8498. dtdac2.TableName = "tb2";
  8499. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8500. foreach (var item in dac1)
  8501. {
  8502. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8503. if (place.Contains(item.Place))
  8504. {
  8505. continue;
  8506. }
  8507. DataRow row = dtdac1.NewRow();
  8508. row["city"] = item.Place;
  8509. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8510. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8511. row["curr"] = currency;
  8512. row["rate"] = rate.ToString("#0.0000");
  8513. row["criterion"] = item.Cost.ToString("#0.00");
  8514. row["number"] = 1;
  8515. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8516. //row["costRMB"] = rbmPrice;
  8517. dtdac1.Rows.Add(row);
  8518. place.Add(item.Place);
  8519. }
  8520. place = new List<string>();
  8521. foreach (var item in dac2)
  8522. {
  8523. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8524. if (place.Contains(item.Place))
  8525. {
  8526. continue;
  8527. }
  8528. DataRow row = dtdac2.NewRow();
  8529. row["city"] = item.Place;
  8530. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8531. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8532. row["curr"] = currency;
  8533. row["rate"] = rate.ToString("#0.0000");
  8534. row["criterion"] = item.Cost.ToString("#0.00");
  8535. row["number"] = 1;
  8536. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8537. //row["cost"] = item.SubTotal;
  8538. //row["costRMB"] = rbmPrice;
  8539. dtdac2.Rows.Add(row);
  8540. place.Add(item.Place);
  8541. //dac2totalPrice += rbmPrice;
  8542. }
  8543. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8544. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8545. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8546. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8547. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8548. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8549. string cell4Str1 = string.Empty;
  8550. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8551. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8552. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8553. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8554. string cellStr = $" 5.其他费用(";
  8555. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8556. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8557. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8558. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8559. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8560. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8561. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8562. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8563. foreach (var otherInfo in dac5)
  8564. {
  8565. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8566. }
  8567. #endregion
  8568. if (cellStr.Length > 8)
  8569. {
  8570. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8571. }
  8572. cellStr += ")";
  8573. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8574. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8575. decimal pxFee = dac4.Sum(it => it.Cost);
  8576. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8577. string celllastStr1 = "";
  8578. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8579. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8580. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8581. celllastStr1 += $",国际旅费 元";
  8582. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8583. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8584. designer.SetDataSource("cell4Str", cell4Str);
  8585. designer.SetDataSource("cellStr", cellStr);
  8586. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8587. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8588. designer.SetDataSource("celllastStr", celllastStr);
  8589. Workbook wb = designer.Workbook;
  8590. var sheet = wb.Worksheets[0];
  8591. //绑定datatable数据集
  8592. designer.SetDataSource(dtdac1);
  8593. designer.SetDataSource(dtdac2);
  8594. designer.Process();
  8595. var rowStart = dtdac1.Rows.Count;
  8596. while (rowStart > 0)
  8597. {
  8598. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8599. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8600. startIndex++;
  8601. rowStart--;
  8602. }
  8603. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8604. startIndex += 1; //总计行
  8605. rowStart = dtdac2.Rows.Count;
  8606. while (rowStart > 0)
  8607. {
  8608. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8609. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8610. startIndex++;
  8611. rowStart--;
  8612. }
  8613. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8614. wb.CalculateFormula(true);
  8615. //模板文件名
  8616. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8617. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8618. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8619. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8620. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8621. }
  8622. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8623. {
  8624. //获取模板
  8625. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8626. //载入模板
  8627. Document doc = new Document(tempPath);
  8628. DocumentBuilder builder = new DocumentBuilder(doc);
  8629. Dictionary<string, string> dic = new Dictionary<string, string>();
  8630. dic.Add("GroupName", "-");
  8631. dic.Add("ClientUnit", "-");
  8632. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8633. //string missionLeaderJob = "";//负责人job
  8634. //int groupNumber = 0; //团人数
  8635. dic.Add("MissionLeader", "-"); //团负责人
  8636. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8637. dic.Add("GroupNumber", "0"); //团人数
  8638. dic.Add("Day", "0");
  8639. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8640. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8641. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8642. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8643. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8644. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8645. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8646. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8647. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8648. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8649. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8650. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8651. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8652. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8653. //其他费用
  8654. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8655. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8656. //其他费用合计
  8657. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8658. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8659. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8660. //公务舱合计
  8661. //国际旅费
  8662. //string outsideJJ = "";
  8663. //string allPriceJJ = "";
  8664. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8665. {
  8666. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8667. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8668. }
  8669. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8670. {
  8671. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8672. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8673. }
  8674. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8675. {
  8676. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8677. dic.Add("AirFeeTotal", airFeeTotalStr);
  8678. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8679. dic.Add("FeeTotal", feeTotalStr);
  8680. }
  8681. foreach (var key in dic.Keys)
  8682. {
  8683. builder.MoveToBookmark(key);
  8684. builder.Write(dic[key]);
  8685. }
  8686. //模板文件名
  8687. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8688. strFileName = CommonFun.ValidFileName(strFileName);
  8689. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8690. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8691. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8692. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8693. }
  8694. }
  8695. else if (dto.ExportType == 2) //表格
  8696. {
  8697. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8698. }
  8699. else if (dto.ExportType == 3)
  8700. {
  8701. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8702. }
  8703. return Ok(JsonView(400, "只可导出明细表!", ""));
  8704. }
  8705. catch (Exception ex)
  8706. {
  8707. return Ok(JsonView(400, ex.Message, ""));
  8708. }
  8709. }
  8710. /// <summary>
  8711. /// 获取三公费用标准city
  8712. /// </summary>
  8713. /// <param name="placeData"></param>
  8714. /// <param name="nationalTravelFeeId"></param>
  8715. /// <returns></returns>
  8716. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8717. {
  8718. string _city = string.Empty;
  8719. if (!placeData.Any()) return _city;
  8720. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8721. if (data == null) return _city;
  8722. string country = data.Country;
  8723. string city = data.City;
  8724. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8725. else _city = city;
  8726. return _city;
  8727. }
  8728. /// <summary>
  8729. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8730. /// </summary>
  8731. /// <returns></returns>
  8732. [HttpPost]
  8733. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8735. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8736. {
  8737. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8738. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8739. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8740. if (_view.Code == 0)
  8741. {
  8742. return Ok(JsonView(true, "操作成功"));
  8743. }
  8744. return Ok(JsonView(false, "操作失败"));
  8745. }
  8746. /// <summary>
  8747. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8748. /// </summary>
  8749. /// <returns></returns>
  8750. [HttpPost]
  8751. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8753. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8754. {
  8755. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8756. if (data.Code != 0)
  8757. {
  8758. return Ok(JsonView(false, data.Msg));
  8759. }
  8760. return Ok(JsonView(true, "操作成功!", data.Data));
  8761. }
  8762. /// <summary>
  8763. /// 三公其他费用草稿 删除
  8764. /// </summary>
  8765. /// <param name="dto"></param>
  8766. /// <returns></returns>
  8767. [HttpPost]
  8768. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8769. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8770. {
  8771. var jw = JsonView(false, "删除失败!");
  8772. var data = new Grp_DayOtherPriceDraft()
  8773. {
  8774. Id = dto.Id,
  8775. IsDel = 1,
  8776. DeleteUserId = dto.DeleteUserId,
  8777. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8778. };
  8779. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8780. if (del > 0)
  8781. {
  8782. jw.Code = 200;
  8783. jw.Msg = "删除成功!";
  8784. }
  8785. return Ok(jw);
  8786. }
  8787. /// <summary>
  8788. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8789. /// </summary>
  8790. /// <returns></returns>
  8791. [HttpPost]
  8792. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8793. {
  8794. var jw = JsonView(false);
  8795. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8796. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8797. jw.Code = StatusCodes.Status200OK;
  8798. jw.Msg = "操作成功!";
  8799. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8800. return Ok(jw);
  8801. }
  8802. /// <summary>
  8803. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8804. /// </summary>
  8805. /// <param name="dto"></param>
  8806. /// <returns></returns>
  8807. [HttpPost]
  8808. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8809. {
  8810. int userId = dto.UserId,
  8811. portId = dto.PortType,
  8812. groupId = dto.GroupId,
  8813. draftId = dto.DraftId;
  8814. _portTypeData.Add(1);
  8815. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8816. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8817. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8818. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8819. _sqlSugar.BeginTran();
  8820. try
  8821. {
  8822. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8823. if (draftDatas == null)
  8824. {
  8825. _sqlSugar.RollbackTran();
  8826. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8827. }
  8828. //验证可覆盖已有数据 两边创建人需为同一人;
  8829. int draftCreateUserId = draftDatas.CreateUserId,
  8830. formalCreateUserId = 0;
  8831. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8832. if (formalData != null)
  8833. {
  8834. formalCreateUserId = formalData.CreateUserId;
  8835. if (draftCreateUserId != formalCreateUserId)
  8836. {
  8837. _sqlSugar.RollbackTran();
  8838. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8839. }
  8840. }
  8841. //默认添加查看、编辑权限(创建人、自己)
  8842. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8843. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8844. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8845. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8846. newExterData.DiId = groupId;
  8847. newExterData.CreateUserId = userId;
  8848. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8849. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8850. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8851. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8852. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8853. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8854. //数据如果存在执行删除
  8855. if (enterExitCostInfo != null)
  8856. {
  8857. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8858. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8859. .Where(x => x.Id == enterExitCostInfo.Id)
  8860. .ExecuteCommand();
  8861. _sqlSugar.Updateable<Grp_DayAndCost>()
  8862. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8863. .Where(x => x.DiId == groupId)
  8864. .ExecuteCommand();
  8865. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8866. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8867. .Where(x => x.Diid == groupId)
  8868. .ExecuteCommand();
  8869. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8870. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8871. .Where(x => x.GroupId == groupId)
  8872. .ExecuteCommand();
  8873. }
  8874. //执行insert
  8875. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8876. if (insertId < 1)
  8877. {
  8878. _sqlSugar.RollbackTran();
  8879. return Ok(JsonView(false, "草稿数据导入失败!"));
  8880. }
  8881. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8882. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8883. #region 默认添加权限
  8884. #endregion
  8885. _sqlSugar.CommitTran();
  8886. //执行操作之后
  8887. //生成默认文件pdf并且通知人员
  8888. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8889. {
  8890. DiId = groupId,
  8891. ExportType = 1,
  8892. SubTypeId = 1005
  8893. }, "pdf");
  8894. //发送通知
  8895. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8896. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8897. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8898. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8899. //汇率信息记录
  8900. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8901. return Ok(JsonView(true));
  8902. }
  8903. catch (Exception ex)
  8904. {
  8905. _sqlSugar.RollbackTran();
  8906. return Ok(JsonView(false, ex.Message));
  8907. }
  8908. }
  8909. #endregion
  8910. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8911. /// <summary>
  8912. /// 获取币种基础数据(含逻辑处理)
  8913. /// </summary>
  8914. /// <returns></returns>
  8915. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8916. {
  8917. return await GeneralMethod.EnterExitCostInitRate();
  8918. }
  8919. /// <summary>
  8920. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8921. /// </summary>
  8922. /// <returns></returns>
  8923. [HttpPost]
  8924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8925. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8926. {
  8927. //验证城市归属并给默认值
  8928. int provinceId = dto.ProvinceId;
  8929. if (provinceId < 1) provinceId = 122;
  8930. var dataSource = await _sqlSugar
  8931. .Queryable<Sys_SetData>()
  8932. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8933. .ToListAsync();
  8934. var fileTypes = new List<EecSetDataInfoView>();
  8935. //三公费用-Word明细类型
  8936. var wordTypeData = dataSource
  8937. .Where(it => it.STid == 72)
  8938. .Select(x => new EecSetDataInfoView
  8939. {
  8940. ParentId = 1,
  8941. Id = x.Id,
  8942. Name = x.Name
  8943. })
  8944. .ToArray();
  8945. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8946. var excelTypeData = dataSource
  8947. .Where(it => it.STid == 73)
  8948. .Select(x => new EecSetDataInfoView
  8949. {
  8950. ParentId = 2,
  8951. Id = x.Id,
  8952. Name = x.Name
  8953. })
  8954. .ToArray();
  8955. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8956. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8957. fileTypes.Add(groupNameList);
  8958. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8959. //默认币种显示
  8960. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8961. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8962. return Ok(JsonView(true, "查询成功!", new
  8963. {
  8964. FileTypeData = fileTypes,
  8965. CurrencyInit = _currencyInfos,
  8966. viewPermissionData = viewPermissionData
  8967. }));
  8968. }
  8969. /// <summary>
  8970. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8971. /// </summary>
  8972. /// <returns></returns>
  8973. [HttpPost]
  8974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8975. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8976. {
  8977. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8978. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8979. RefAsync<int> total = 0;
  8980. int diId = 0;
  8981. var status = int.TryParse(dto.GroupName, out diId);
  8982. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8983. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8984. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8985. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8986. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8987. .OrderByDescending(x => x.VisitStartDate)
  8988. .Select(x => new EnterExitCostMobileGroupView()
  8989. {
  8990. Id = x.Id,
  8991. GroupName = x.TeamName,
  8992. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8993. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8994. ProvinceId = x.CityId
  8995. })
  8996. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8997. //处理省份Id
  8998. if (data.Any())
  8999. {
  9000. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9001. if (provCityDatas.Any())
  9002. {
  9003. foreach (var item in data)
  9004. {
  9005. var provinceId = item.ProvinceId;
  9006. var isDefualtVal = true;
  9007. if (provinceId > 0)
  9008. {
  9009. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9010. if (parentId != null)
  9011. {
  9012. isDefualtVal = false;
  9013. item.ProvinceId = (int)parentId;
  9014. }
  9015. }
  9016. if (isDefualtVal)
  9017. {
  9018. item.ProvinceId = 122; //默认四川
  9019. }
  9020. }
  9021. }
  9022. }
  9023. //处理是否显示
  9024. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9025. {
  9026. foreach (var item in data)
  9027. {
  9028. item.IsView = true;
  9029. }
  9030. }
  9031. return Ok(JsonView(true, "查询成功!", data, total));
  9032. }
  9033. /// <summary>
  9034. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9035. /// </summary>
  9036. /// <returns></returns>
  9037. [HttpPost]
  9038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9039. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9040. {
  9041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9042. RefAsync<int> total = 0;
  9043. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9044. .Where(x => x.IsDel == 0 && x.STid == 66)
  9045. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9046. .Select(x => new
  9047. {
  9048. id = x.Id,
  9049. name = x.Name,
  9050. remark = x.Remark,
  9051. })
  9052. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9053. return Ok(JsonView(true, "查询成功!", data, total));
  9054. }
  9055. /// <summary>
  9056. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9057. /// </summary>
  9058. /// <returns></returns>
  9059. [HttpPost]
  9060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9061. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9062. {
  9063. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9064. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9065. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9066. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9067. var groupOtherRateData = groupRateData.TeamRates;
  9068. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9069. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9070. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9071. groupOtherRateData = groupOtherRateData
  9072. .Select(x => new TeamRateDescAddCurrencyIdView
  9073. {
  9074. CurrencyId = x.CurrencyId,
  9075. CurrencyName = x.CurrencyName,
  9076. CurrencyCode = x.CurrencyCode,
  9077. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9078. }).ToList();
  9079. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9080. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9081. }
  9082. /// <summary>
  9083. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9084. /// </summary>
  9085. /// <returns></returns>
  9086. [HttpPost]
  9087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9088. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9089. {
  9090. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9091. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9092. var tipsData = new List<int>() { 1, 2, 3 };
  9093. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9094. if (dto.TipsType == 1)
  9095. {
  9096. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9097. }
  9098. else if (dto.TipsType == 2)
  9099. {
  9100. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9101. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9102. }
  9103. else if (dto.TipsType == 3)
  9104. {
  9105. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  9106. return Ok(JsonView(true, "查询成功!", airData.Data));
  9107. }
  9108. return Ok(JsonView(false));
  9109. }
  9110. /// <summary>
  9111. /// 团组模块 - 出入境国家费用标准-移动端 List
  9112. /// </summary>
  9113. /// <returns></returns>
  9114. [HttpPost]
  9115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9116. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9117. {
  9118. Stopwatch sw = new Stopwatch();
  9119. sw.Start();
  9120. int provinceId = dto.ProvinceId;
  9121. if (provinceId < 1) provinceId = 122; // 默认四川
  9122. RefAsync<int> total = 0;
  9123. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9124. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9125. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9126. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9127. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9128. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9129. .Select((ntf, sd, u, sd1) => new
  9130. {
  9131. Id = ntf.Id,
  9132. Area = $"{ntf.Country}-{ntf.City}",
  9133. Currency = ntf.Currency,
  9134. CurrencyCode = sd.Name,
  9135. CurrencyName = sd.Remark,
  9136. RoomCost = ntf.RoomCost,
  9137. FoodCost = ntf.FoodCost,
  9138. PublicCost = ntf.PublicCost,
  9139. TrainCost = ntf.TrainCost,
  9140. LastUpdateUserId = ntf.LastUpdateUserId,
  9141. LastUpdateUserName = u.CnName,
  9142. LastUpdateTime = ntf.LastUpdateTime
  9143. })
  9144. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9145. sw.Stop();
  9146. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9147. }
  9148. /// <summary>
  9149. /// 团组模块 - 出入境费用-移动端 - Info
  9150. /// </summary>
  9151. /// <returns></returns>
  9152. [HttpPost]
  9153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9154. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9155. {
  9156. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9157. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9158. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9159. return Ok(data);
  9160. }
  9161. /// <summary>
  9162. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9163. /// </summary>
  9164. /// <returns></returns>
  9165. [HttpPost]
  9166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9167. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9168. {
  9169. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9170. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9171. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9172. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9173. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9174. mobileInfo.DiId = dto.DiId;
  9175. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9176. if (eecInfo == null) return Ok(mobileInfo);
  9177. //验证查看权限
  9178. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9179. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9180. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9181. mobileInfo.IsAssignPerm = isSet;
  9182. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9183. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9184. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9185. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9186. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9187. {
  9188. SubId = dac.Id,
  9189. DiId = dac.DiId,
  9190. Type = dac.Type,
  9191. Days = dac.Days,
  9192. NationalTravelFeeId = dac.NationalTravelFeeId,
  9193. Arae = $"{ntf.Country}-{ntf.City}",
  9194. Cost = dac.Cost,
  9195. Currency = dac.Currency,
  9196. CurrencyName = sd.Name,
  9197. SubTotal = dac.SubTotal,
  9198. })
  9199. .ToList();
  9200. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9201. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9202. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9203. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9204. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9205. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9206. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9207. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9208. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9209. //其他款项
  9210. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9211. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9212. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9213. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9214. .OrderBy((dop, sd1, sd2) => dop.Index)
  9215. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9216. {
  9217. SubId = dop.Id,
  9218. DiId = dop.Diid,
  9219. Index = dop.Index,
  9220. SetDataId = dop.SetDataId,
  9221. SetDataName = sd1.Name,
  9222. Cost = dop.Cost,
  9223. Currency = dop.Currency,
  9224. CurrencyName = sd2.Remark,
  9225. SubTotal = dop.SubTotal,
  9226. Remark = dop.Remark,
  9227. })
  9228. .ToArray();
  9229. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9230. return Ok(mobileInfo);
  9231. }
  9232. /// <summary>
  9233. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9234. /// </summary>
  9235. /// <returns></returns>
  9236. [HttpPost]
  9237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9238. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9239. {
  9240. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9241. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9242. //验证查看权限
  9243. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9244. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9245. var userIds = await _sqlSugar
  9246. .Queryable<Grp_EnterExitCostPermission>()
  9247. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9248. .Select(x => x.UserId)
  9249. .ToArrayAsync();
  9250. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9251. var perUsersView = new List<dynamic>();
  9252. foreach (var item in perUsers)
  9253. {
  9254. bool isView1 = false;
  9255. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9256. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9257. }
  9258. return Ok(JsonView(perUsersView));
  9259. }
  9260. /// <summary>
  9261. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9262. /// </summary>
  9263. /// <returns></returns>
  9264. [HttpPost]
  9265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9266. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9267. {
  9268. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9269. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9270. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9271. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9272. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9273. //验证查看权限
  9274. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9275. //if (!isView) return Ok(JsonView(false, msg));
  9276. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9277. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9278. var subType = dto.SubType;
  9279. if (subType == 1) //1:境内费用
  9280. {
  9281. var oneData = new ChoiceOneMobileSubInfoView()
  9282. {
  9283. Id = eecInfo.Id,
  9284. ChoiceOne = eecInfo.ChoiceOne,
  9285. ChoiceOneTotalCost = eecInfo.InsidePay,
  9286. Visa = eecInfo.Visa,
  9287. VisaRemark = eecInfo.VisaRemark,
  9288. YiMiao = eecInfo.YiMiao,
  9289. HeSuan = eecInfo.HeSuan,
  9290. Service = eecInfo.Service,
  9291. Ticket = eecInfo.Ticket,
  9292. Safe = eecInfo.Safe,
  9293. FirstItemRemark = eecInfo.FirstItemRemark
  9294. };
  9295. return Ok(JsonView(oneData));
  9296. }
  9297. else if (subType == 2) //2:国际旅费
  9298. {
  9299. var twoData = new ChoiceTwoMobileSubInfoView()
  9300. {
  9301. Id = eecInfo.Id,
  9302. ChoiceTwoJJ = eecInfo.SumJJC,
  9303. OutsideJJPay = eecInfo.OutsideJJPay,
  9304. ChoiceTwoGW = eecInfo.SumGWC,
  9305. OutsideGWPay = eecInfo.OutsideGWPay,
  9306. ChoiceTwoTD = eecInfo.SumTDC,
  9307. OutsideTDPay = eecInfo.OutsideTDPay,
  9308. AirJJ = eecInfo.AirJJ,
  9309. AirGW = eecInfo.AirGW,
  9310. AirTD = eecInfo.AirTD,
  9311. CityTranffic = eecInfo.CityTranffic,
  9312. TwoItemRemark = eecInfo.TwoItemRemark
  9313. };
  9314. return Ok(JsonView(twoData));
  9315. }
  9316. else if (subType == 3) //3:住宿费
  9317. {
  9318. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9319. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9320. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9321. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9322. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9323. {
  9324. SubId = dac.Id,
  9325. DiId = dac.DiId,
  9326. Type = dac.Type,
  9327. Days = dac.Days,
  9328. NationalTravelFeeId = dac.NationalTravelFeeId,
  9329. Arae = $"{ntf.Country}-{ntf.City}",
  9330. Cost = dac.Cost,
  9331. Currency = dac.Currency,
  9332. CurrencyName = sd.Name,
  9333. SubTotal = dac.SubTotal,
  9334. })
  9335. .ToArray();
  9336. var data = new ChoiceMobileSubInfo3To6View()
  9337. {
  9338. ParentId = eecInfo.Id,
  9339. Choice = eecInfo.ChoiceThree,
  9340. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9341. Details = dayAndCostDatas
  9342. };
  9343. return Ok(JsonView(data));
  9344. }
  9345. else if (subType == 4) //4:伙食费
  9346. {
  9347. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9348. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9349. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9350. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9351. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9352. {
  9353. SubId = dac.Id,
  9354. DiId = dac.DiId,
  9355. Type = dac.Type,
  9356. Days = dac.Days,
  9357. NationalTravelFeeId = dac.NationalTravelFeeId,
  9358. Arae = $"{ntf.Country}-{ntf.City}",
  9359. Cost = dac.Cost,
  9360. Currency = dac.Currency,
  9361. CurrencyName = sd.Name,
  9362. SubTotal = dac.SubTotal,
  9363. })
  9364. .ToArray();
  9365. var data = new ChoiceMobileSubInfo3To6View()
  9366. {
  9367. ParentId = eecInfo.Id,
  9368. Choice = eecInfo.ChoiceFour,
  9369. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9370. Details = dayAndCostDatas
  9371. };
  9372. return Ok(JsonView(data));
  9373. }
  9374. else if (subType == 5) //5:公杂费
  9375. {
  9376. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9377. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9378. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9379. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9380. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9381. {
  9382. SubId = dac.Id,
  9383. DiId = dac.DiId,
  9384. Type = dac.Type,
  9385. Days = dac.Days,
  9386. NationalTravelFeeId = dac.NationalTravelFeeId,
  9387. Arae = $"{ntf.Country}-{ntf.City}",
  9388. Cost = dac.Cost,
  9389. Currency = dac.Currency,
  9390. CurrencyName = sd.Name,
  9391. SubTotal = dac.SubTotal,
  9392. })
  9393. .ToArray();
  9394. var data = new ChoiceMobileSubInfo3To6View()
  9395. {
  9396. ParentId = eecInfo.Id,
  9397. Choice = eecInfo.ChoiceFive,
  9398. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9399. Details = dayAndCostDatas
  9400. };
  9401. return Ok(JsonView(data));
  9402. }
  9403. else if (subType == 6) //6:培训费
  9404. {
  9405. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9406. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9407. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9408. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9409. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9410. {
  9411. SubId = dac.Id,
  9412. DiId = dac.DiId,
  9413. Type = dac.Type,
  9414. Days = dac.Days,
  9415. NationalTravelFeeId = dac.NationalTravelFeeId,
  9416. Arae = $"{ntf.Country}-{ntf.City}",
  9417. Cost = dac.Cost,
  9418. Currency = dac.Currency,
  9419. CurrencyName = sd.Name,
  9420. SubTotal = dac.SubTotal,
  9421. })
  9422. .ToArray();
  9423. var data = new ChoiceMobileSubInfo3To6View()
  9424. {
  9425. ParentId = eecInfo.Id,
  9426. Choice = eecInfo.ChoiceSix,
  9427. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9428. Details = dayAndCostDatas
  9429. };
  9430. return Ok(JsonView(data));
  9431. }
  9432. else if (subType == 7) //7:其他
  9433. {
  9434. //其他款项
  9435. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9436. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9437. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9438. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9439. .OrderBy((dop, sd1, sd2) => dop.Index)
  9440. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9441. {
  9442. SubId = dop.Id,
  9443. DiId = dop.Diid,
  9444. Index = dop.Index,
  9445. SetDataId = dop.SetDataId,
  9446. SetDataName = sd1.Name,
  9447. Cost = dop.Cost,
  9448. Currency = dop.Currency,
  9449. CurrencyName = sd2.Name,
  9450. SubTotal = dop.SubTotal,
  9451. Remark = dop.Remark,
  9452. })
  9453. .ToArray();
  9454. var data = new ChoiceSevenMobileSubInfoView()
  9455. {
  9456. ParentId = eecInfo.Id,
  9457. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9458. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9459. Details = otherData
  9460. };
  9461. return Ok(JsonView(data));
  9462. }
  9463. return Ok(JsonView(false));
  9464. }
  9465. #region op
  9466. /// <summary>
  9467. /// 移动端更新费用消息通知
  9468. /// </summary>
  9469. /// <param name="diid"></param>
  9470. /// <param name="id"></param>
  9471. /// <param name="currUserId"></param>
  9472. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9473. {
  9474. try
  9475. {
  9476. ////生成默认文件pdf并且通知人员
  9477. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9478. //{
  9479. // DiId = diid,
  9480. // ExportType = 1,
  9481. // SubTypeId = 1005
  9482. //}, "pdf");
  9483. ////发送通知
  9484. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9485. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9486. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9487. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9488. ////汇率信息记录
  9489. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9490. }
  9491. catch (Exception ex)
  9492. {
  9493. //记录日志
  9494. throw;
  9495. }
  9496. }
  9497. /// <summary>
  9498. /// 验证出入境费用数据是否存在
  9499. /// 不存在添加
  9500. /// </summary>
  9501. /// <param name="diId"></param>
  9502. /// <param name="currUserId"></param>
  9503. /// <returns></returns>
  9504. /// <exception cref="CustomException"></exception>
  9505. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9506. {
  9507. var parentId = 0;
  9508. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9509. if (info != null)
  9510. {
  9511. parentId = info.Id;
  9512. }
  9513. else
  9514. {
  9515. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9516. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9517. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9518. parentId = addId;
  9519. }
  9520. return parentId;
  9521. }
  9522. /// <summary>
  9523. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9524. /// </summary>
  9525. /// <returns></returns>
  9526. [HttpPost]
  9527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9528. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9529. {
  9530. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9531. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9532. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9533. //验证编辑权限
  9534. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9535. //if (!isEdit) return Ok(JsonView(false, msg));
  9536. var permissions = new List<Grp_EnterExitCostPermission>();
  9537. foreach (var userId in dto.UserIds)
  9538. {
  9539. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9540. }
  9541. if (permissions.Any())
  9542. {
  9543. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9544. {
  9545. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9546. }
  9547. _sqlSugar.BeginTran();
  9548. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9549. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9550. if (result < 1)
  9551. {
  9552. _sqlSugar.RollbackTran();
  9553. return Ok(JsonView(false));
  9554. }
  9555. _sqlSugar.CommitTran();
  9556. return Ok(JsonView(true));
  9557. }
  9558. return Ok(JsonView(false));
  9559. }
  9560. /// <summary>
  9561. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9562. /// </summary>
  9563. /// <returns></returns>
  9564. [HttpPost]
  9565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9566. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9567. {
  9568. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9569. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9570. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9571. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9572. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9573. int id = dto.Id;
  9574. if (id <= 0) //add
  9575. {
  9576. //int provinceId = dto.ProvinceId;
  9577. int groupId = dto.DiId;
  9578. //if (provinceId < 1) provinceId = 122;
  9579. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9580. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9581. if (add < 1) return Ok(JsonView(false));
  9582. id = add;
  9583. }
  9584. else //update
  9585. {
  9586. ////验证编辑权限
  9587. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9588. //if (!isEdit) return Ok(JsonView(false, msg));
  9589. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9590. if (upd < 1) return Ok(JsonView(false));
  9591. }
  9592. #region 汇率变更时更改币种相关费用
  9593. var opDayCosts = new List<Grp_DayAndCost>();
  9594. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9595. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9596. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9597. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9598. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9599. .Select((dac, sd) => new
  9600. {
  9601. dac.Id,
  9602. dac.DiId,
  9603. CurrencyCode = sd.Name,
  9604. dac.Cost
  9605. })
  9606. .ToList();
  9607. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9608. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9609. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9610. .Select((dop, sd) => new
  9611. {
  9612. dop.Id,
  9613. dop.Diid,
  9614. CurrencyCode = sd.Name,
  9615. dop.Cost
  9616. })
  9617. .ToList();
  9618. if (dayCosts.Count > 0)
  9619. {
  9620. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9621. foreach (var dc in new_dayCosts)
  9622. {
  9623. var thisCurrency = dc.Key.ToUpper();
  9624. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9625. if (thisRate == 0.00M) continue;
  9626. foreach (var dcSub in dc)
  9627. {
  9628. opDayCosts.Add(new Grp_DayAndCost()
  9629. {
  9630. Id = dcSub.Id,
  9631. DiId = dcSub.DiId,
  9632. Cost = dcSub.Cost,
  9633. SubTotal = dcSub.Cost * thisRate,
  9634. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9635. });
  9636. }
  9637. }
  9638. if (opDayCosts.Count > 0)
  9639. {
  9640. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9641. }
  9642. }
  9643. if (dayOtherCosts.Count > 0)
  9644. {
  9645. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9646. foreach (var dc in new_dayOtherCosts)
  9647. {
  9648. var thisCurrency = dc.Key.ToUpper();
  9649. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9650. if (thisRate == 0.00M) continue;
  9651. foreach (var dcSub in dc)
  9652. {
  9653. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9654. {
  9655. Id = dcSub.Id,
  9656. Diid = dcSub.Diid,
  9657. Cost = dcSub.Cost,
  9658. SubTotal = dcSub.Cost * thisRate,
  9659. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9660. });
  9661. }
  9662. }
  9663. if (opDayOtherCosts.Count > 0)
  9664. {
  9665. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9666. }
  9667. }
  9668. #endregion
  9669. //消息通知
  9670. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9671. //汇率信息记录
  9672. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9673. return Ok(JsonView(new { parentId = id }));
  9674. }
  9675. /// <summary>
  9676. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9677. /// </summary>
  9678. /// <returns></returns>
  9679. [HttpPost]
  9680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9681. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9682. {
  9683. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9684. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9685. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9686. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9687. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9688. int id = dto.Id;
  9689. if (id <= 0) //add
  9690. {
  9691. checkboxInfo.CreateUserId = dto.CurrUserId;
  9692. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9693. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9694. if (add < 1) return Ok(JsonView(false));
  9695. }
  9696. else //update
  9697. {
  9698. ////验证编辑权限
  9699. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9700. //if (!isEdit) return Ok(JsonView(false, msg));
  9701. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9702. .UpdateColumns(x => new
  9703. {
  9704. x.ChoiceOne,
  9705. x.ChoiceTwo,
  9706. x.SumJJC,
  9707. x.SumGWC,
  9708. x.SumTDC,
  9709. x.ChoiceThree,
  9710. x.ChoiceFour,
  9711. x.ChoiceFive,
  9712. x.ChoiceSix,
  9713. x.OtherExpenses_Checked
  9714. })
  9715. .Where(x => x.Id == id)
  9716. .ExecuteCommandAsync();
  9717. if (upd < 1) return Ok(JsonView(false));
  9718. }
  9719. return Ok(JsonView(new { parentId = id }));
  9720. }
  9721. /// <summary>
  9722. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9723. /// </summary>
  9724. /// <returns></returns>
  9725. [HttpPost]
  9726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9727. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9728. {
  9729. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9730. // if (provinceId < 1) provinceId = 122;
  9731. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9732. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9733. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9734. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9735. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9736. var checkboxInfo = new Grp_EnterExitCost()
  9737. {
  9738. Id = id,
  9739. //ProvinceId = provinceId,
  9740. DiId = diId,
  9741. CreateUserId = currUserId
  9742. };
  9743. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9744. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9745. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9746. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9747. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9748. if (id <= 0) //add
  9749. {
  9750. checkboxInfo.CreateUserId = dto.CurrUserId;
  9751. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9752. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9753. if (add < 1) return Ok(JsonView(false));
  9754. }
  9755. else //update
  9756. {
  9757. ////验证编辑权限
  9758. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9759. //if (!isEdit) return Ok(JsonView(false, msg));
  9760. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9761. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9762. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9763. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9764. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9765. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9766. .Where(x => x.Id == id)
  9767. .ExecuteCommandAsync();
  9768. if (upd < 1) return Ok(JsonView(false));
  9769. }
  9770. return Ok(JsonView(new { parentId = id }));
  9771. }
  9772. /// <summary>
  9773. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9774. /// </summary>
  9775. /// <returns></returns>
  9776. [HttpPost]
  9777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9778. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9779. {
  9780. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9781. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9782. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9783. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9784. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9785. info.FirstItemRemark = dto.FirstItemRemark;
  9786. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9787. int id = dto.Id;
  9788. if (id <= 0) //add
  9789. {
  9790. info.CreateUserId = dto.CurrUserId;
  9791. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9792. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9793. if (add < 1) return Ok(JsonView(false));
  9794. id = add;
  9795. }
  9796. else //update
  9797. {
  9798. ////验证编辑权限
  9799. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9800. //if (!isEdit) return Ok(JsonView(false, msg));
  9801. var upd = await _sqlSugar.Updateable(info)
  9802. .UpdateColumns(x => new
  9803. {
  9804. x.ChoiceOne,
  9805. x.InsidePay,
  9806. x.VisaRemark,
  9807. x.Visa,
  9808. x.Service,
  9809. x.Safe,
  9810. x.Ticket,
  9811. x.HeSuan,
  9812. x.YiMiao,
  9813. x.FirstItemRemark
  9814. })
  9815. .Where(x => x.Id == id)
  9816. .ExecuteCommandAsync();
  9817. if (upd < 1) return Ok(JsonView(false));
  9818. }
  9819. //消息通知
  9820. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9821. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9822. }
  9823. /// <summary>
  9824. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9825. /// </summary>
  9826. /// <returns></returns>
  9827. [HttpPost]
  9828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9829. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9830. {
  9831. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9832. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9833. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9834. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9835. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9836. info.DiId = dto.DiId;
  9837. //info.ProvinceId = dto.ProvinceId;
  9838. info.OutsideJJPay = dto.OutsideJJPay;
  9839. info.OutsideGWPay = dto.OutsideGWPay;
  9840. info.OutsideTDPay = dto.OutsideTDPay;
  9841. info.AirJJ = dto.AirJJ;
  9842. info.AirGW = dto.AirGW;
  9843. info.AirTD = dto.AirTD;
  9844. info.CityTranffic = dto.CityTranffic;
  9845. info.TwoItemRemark = dto.TwoItemRemark;
  9846. info.SumJJC = dto.ChoiceTwoJJ;
  9847. info.SumGWC = dto.ChoiceTwoGW;
  9848. info.SumTDC = dto.ChoiceTwoTD;
  9849. int id = dto.Id;
  9850. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9851. if (id <= 0) //add
  9852. {
  9853. info.CreateUserId = dto.CurrUserId;
  9854. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9855. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9856. if (addId <= 0) return Ok(JsonView(false));
  9857. id = addId;
  9858. }
  9859. else //update
  9860. {
  9861. ////验证编辑权限
  9862. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9863. //if (!isEdit) return Ok(JsonView(false, msg));
  9864. var upd = await _sqlSugar.Updateable(info)
  9865. .UpdateColumns(x => new
  9866. {
  9867. x.SumJJC,
  9868. x.OutsideJJPay,
  9869. x.SumGWC,
  9870. x.OutsideGWPay,
  9871. x.SumTDC,
  9872. x.OutsideTDPay,
  9873. x.AirJJ,
  9874. x.AirGW,
  9875. x.AirTD,
  9876. x.CityTranffic,
  9877. x.TwoItemRemark
  9878. })
  9879. .Where(x => x.Id == id)
  9880. .ExecuteCommandAsync();
  9881. if (upd < 1) return Ok(JsonView(false));
  9882. }
  9883. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9884. gwcItemTotal = info.AirGW + info.CityTranffic;
  9885. tdcItemTotal = info.AirTD + info.CityTranffic;
  9886. //消息通知
  9887. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9888. return Ok(JsonView(new
  9889. {
  9890. parentId = id,
  9891. choiceTwoJJ = dto.ChoiceTwoJJ,
  9892. jjcItemTotal = jjcItemTotal,
  9893. choiceTwoGW = dto.ChoiceTwoGW,
  9894. gwcItemTotal = gwcItemTotal,
  9895. choiceTwoTD = dto.ChoiceTwoTD,
  9896. tdcItemTotal = tdcItemTotal
  9897. }));
  9898. }
  9899. /// <summary>
  9900. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9901. /// </summary>
  9902. /// <returns></returns>
  9903. [HttpPost]
  9904. [ApiExplorerSettings(IgnoreApi = true)]
  9905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9906. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9907. {
  9908. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9909. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9910. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9911. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9912. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9913. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9914. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9915. var infos = infos1.Select(x => new Grp_DayAndCost
  9916. {
  9917. Id = x.Id,
  9918. DiId = dto.DiId,
  9919. Type = dto.FeeType,
  9920. Days = x.Days,
  9921. NationalTravelFeeId = x.NationalTravelFeeId,
  9922. Cost = x.Cost,
  9923. Currency = x.Currency,
  9924. SubTotal = x.SubTotal,
  9925. CreateUserId = dto.CurrUserId
  9926. })
  9927. .ToList();
  9928. var adds = infos.Where(x => x.Id <= 0).ToList();
  9929. var upds = infos.Where(x => x.Id > 0).ToList();
  9930. if (adds.Count > 0)
  9931. {
  9932. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9933. if (add < 1) return Ok(JsonView(false));
  9934. }
  9935. if (upds.Count > 0)
  9936. {
  9937. var upd = await _sqlSugar.Updateable(adds)
  9938. .UpdateColumns(x => new
  9939. {
  9940. x.Days,
  9941. x.NationalTravelFeeId,
  9942. x.Cost,
  9943. x.Currency,
  9944. x.SubTotal
  9945. })
  9946. .WhereColumns(x => new { x.Id })
  9947. .ExecuteCommandAsync();
  9948. if (upd < 1) return Ok(JsonView(false));
  9949. }
  9950. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9951. //消息通知
  9952. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9953. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9954. return Ok(JsonView(new { itemTotal = itemTotal }));
  9955. }
  9956. /// <summary>
  9957. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9958. /// </summary>
  9959. /// <returns></returns>
  9960. [HttpPost]
  9961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9962. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9963. {
  9964. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9965. int subId = dto.SubId, feeType = dto.FeeType;
  9966. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9967. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9969. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9970. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9971. subInfo.Id = subId;
  9972. subInfo.DiId = dto.DiId;
  9973. if (feeType == 3) subInfo.Type = 1;
  9974. else if (feeType == 4) subInfo.Type = 2;
  9975. else if (feeType == 5) subInfo.Type = 3;
  9976. else if (feeType == 6) subInfo.Type = 4;
  9977. subInfo.CreateUserId = dto.CurrUserId;
  9978. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9979. if (parentId < 1) return Ok(JsonView(false));
  9980. //子表op
  9981. if (subId < 1)
  9982. {
  9983. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9984. if (subAdd < 1) return Ok(JsonView(false));
  9985. }
  9986. else
  9987. {
  9988. ////验证编辑权限
  9989. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9990. //if (!isEdit) return Ok(JsonView(false, msg));
  9991. var subUpd = await _sqlSugar.Updateable(subInfo)
  9992. .UpdateColumns(x => new
  9993. {
  9994. x.Days,
  9995. x.NationalTravelFeeId,
  9996. x.Cost,
  9997. x.Currency,
  9998. x.SubTotal
  9999. })
  10000. .WhereColumns(x => new { x.Id })
  10001. .ExecuteCommandAsync();
  10002. if (subUpd < 1) return Ok(JsonView(false));
  10003. }
  10004. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10005. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10006. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10007. }
  10008. /// <summary>
  10009. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10010. /// </summary>
  10011. /// <returns></returns>
  10012. [HttpPost]
  10013. [ApiExplorerSettings(IgnoreApi = true)]
  10014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10015. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10016. {
  10017. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10018. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10019. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10020. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10021. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10022. {
  10023. Id = x.Id,
  10024. Diid = dto.DiId,
  10025. SetDataId = x.SetDataId,
  10026. Index = x.Index,
  10027. Cost = x.Cost,
  10028. Currency = x.Currency,
  10029. SubTotal = x.SubTotal,
  10030. CreateUserId = dto.CurrUserId,
  10031. Remark = x.Remark
  10032. }).ToList();
  10033. var adds = infos.Where(x => x.Id <= 0).ToList();
  10034. var upds = infos.Where(x => x.Id > 0).ToList();
  10035. if (adds.Count > 0)
  10036. {
  10037. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10038. if (add < 1) return Ok(JsonView(false));
  10039. }
  10040. if (upds.Count > 0)
  10041. {
  10042. var upd = await _sqlSugar.Updateable(adds)
  10043. .UpdateColumns(x => new
  10044. {
  10045. x.Index,
  10046. x.SetDataId,
  10047. x.Cost,
  10048. x.Currency,
  10049. x.SubTotal,
  10050. x.Remark
  10051. })
  10052. .WhereColumns(x => new { x.Id })
  10053. .ExecuteCommandAsync();
  10054. if (upd < 1) return Ok(JsonView(false));
  10055. }
  10056. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10057. //消息通知
  10058. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10059. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10060. return Ok(JsonView(new { itemTotal = itemTotal }));
  10061. }
  10062. /// <summary>
  10063. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10064. /// </summary>
  10065. /// <returns></returns>
  10066. [HttpPost]
  10067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10068. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10069. {
  10070. int subId = dto.SubId;
  10071. int diId = dto.Diid;
  10072. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10073. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10074. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10075. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10076. subInfo.Id = subId;
  10077. subInfo.Diid = dto.Diid;
  10078. subInfo.CreateUserId = dto.CurrUserId;
  10079. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10080. if (parentId < 1) return Ok(JsonView(false));
  10081. #region 子表op
  10082. if (subId < 1)//add
  10083. {
  10084. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10085. if (subAdd < 1) return Ok(JsonView(false));
  10086. }
  10087. else //upd
  10088. {
  10089. ////验证编辑权限
  10090. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10091. //if (!isEdit) return Ok(JsonView(false, msg));
  10092. var subUpd = await _sqlSugar.Updateable(subInfo)
  10093. .UpdateColumns(x => new
  10094. {
  10095. x.Index,
  10096. x.SetDataId,
  10097. x.Cost,
  10098. x.Currency,
  10099. x.SubTotal,
  10100. x.Remark
  10101. })
  10102. .WhereColumns(x => new { x.Id })
  10103. .ExecuteCommandAsync();
  10104. if (subUpd < 1) return Ok(JsonView(false));
  10105. }
  10106. #endregion
  10107. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10108. //消息通知
  10109. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10110. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10111. }
  10112. /// <summary>
  10113. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10114. /// </summary>
  10115. /// <returns></returns>
  10116. [HttpPost]
  10117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10118. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10119. {
  10120. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10121. if (data.Code != 0)
  10122. {
  10123. return Ok(JsonView(false, data.Msg));
  10124. }
  10125. return Ok(JsonView(true, "操作成功!", data.Data));
  10126. }
  10127. /// <summary>
  10128. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10129. /// </summary>
  10130. /// <param name="dto"></param>
  10131. /// <returns></returns>
  10132. [HttpPost]
  10133. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10134. {
  10135. var data = new Grp_DayOtherPrice()
  10136. {
  10137. Id = dto.Id,
  10138. IsDel = 1,
  10139. DeleteUserId = dto.DeleteUserId,
  10140. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10141. };
  10142. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10143. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10144. return Ok(JsonView(false, "删除失败!"));
  10145. }
  10146. #endregion
  10147. #endregion
  10148. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10149. /// <summary>
  10150. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10151. /// </summary>
  10152. /// <returns></returns>
  10153. [HttpGet]
  10154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10155. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10156. {
  10157. var provData = await _groupRepository.ProvinceBasicSource();
  10158. return Ok(JsonView(true, "查询成功!", provData));
  10159. }
  10160. /// <summary>
  10161. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10162. /// </summary>
  10163. /// <returns></returns>
  10164. [HttpPost]
  10165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10166. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10167. {
  10168. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10169. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10170. RefAsync<int> total = 0;
  10171. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10172. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10173. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10174. .Select(x => new
  10175. {
  10176. Id = x.Id,
  10177. DraftName = x.DraftName,
  10178. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10179. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10180. .Any()
  10181. })
  10182. .OrderByDescending(x => x.Id)
  10183. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10184. return Ok(JsonView(true, "查询成功!", data, total));
  10185. }
  10186. /// <summary>
  10187. /// 出入境费用-草稿 移动端
  10188. /// 获取币种基础数据(含逻辑处理)
  10189. /// </summary>
  10190. /// <returns></returns>
  10191. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10192. {
  10193. return await GeneralMethod.EnterExitCostInitRate();
  10194. }
  10195. /// <summary>
  10196. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10197. /// </summary>
  10198. /// <returns></returns>
  10199. [HttpPost]
  10200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10201. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10202. {
  10203. //验证城市归属并给默认值
  10204. int provinceId = dto.ProvinceId;
  10205. if (provinceId < 1) provinceId = 122;
  10206. var dataSource = await _sqlSugar
  10207. .Queryable<Sys_SetData>()
  10208. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10209. .ToListAsync();
  10210. //三公费用-Word明细类型
  10211. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10212. .Select(x => new SetDataInfoView
  10213. {
  10214. Id = x.Id,
  10215. Name = x.Name,
  10216. Remark = x.Remark
  10217. })
  10218. .ToList();
  10219. //三公费用-Excel明细类型
  10220. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10221. .Select(x => new SetDataInfoView
  10222. {
  10223. Id = x.Id,
  10224. Name = x.Name,
  10225. Remark = x.Remark
  10226. })
  10227. .ToList();
  10228. //默认币种显示
  10229. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10230. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10231. return Ok(JsonView(true, "查询成功!", new
  10232. {
  10233. WordTypeData = wordTypeData,
  10234. ExcelTypeData = excelTypeData,
  10235. CurrencyInit = _currencyInfos,
  10236. viewPermissionData = viewPermissionData
  10237. }));
  10238. }
  10239. /// <summary>
  10240. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10241. /// </summary>
  10242. /// <returns></returns>
  10243. [HttpPost]
  10244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10245. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10246. {
  10247. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10248. RefAsync<int> total = 0;
  10249. int diId = 0;
  10250. var status = int.TryParse(dto.GroupName, out diId);
  10251. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10252. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10253. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10254. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10255. .OrderByDescending(x => x.VisitStartDate)
  10256. .Select(x => new
  10257. {
  10258. Id = x.Id,
  10259. GroupName = x.TeamName
  10260. })
  10261. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10262. return Ok(JsonView(true, "查询成功!", data, total));
  10263. }
  10264. /// <summary>
  10265. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10266. /// </summary>
  10267. /// <returns></returns>
  10268. [HttpPost]
  10269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10270. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10271. {
  10272. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10273. RefAsync<int> total = 0;
  10274. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10275. .Where(x => x.IsDel == 0 && x.STid == 66)
  10276. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10277. .Select(x => new
  10278. {
  10279. id = x.Id,
  10280. name = x.Name,
  10281. remark = x.Remark,
  10282. })
  10283. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10284. return Ok(JsonView(true, "查询成功!", data, total));
  10285. }
  10286. /// <summary>
  10287. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10288. /// </summary>
  10289. /// <returns></returns>
  10290. [HttpPost]
  10291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10292. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10293. {
  10294. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10295. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10296. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10297. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10298. var groupOtherRateData = groupRateData.TeamRates;
  10299. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10300. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10301. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10302. groupOtherRateData = groupOtherRateData
  10303. .Select(x => new TeamRateDescAddCurrencyIdView
  10304. {
  10305. CurrencyId = x.CurrencyId,
  10306. CurrencyName = x.CurrencyName,
  10307. CurrencyCode = x.CurrencyCode,
  10308. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10309. }).ToList();
  10310. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10311. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10312. }
  10313. /// <summary>
  10314. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10315. /// </summary>
  10316. /// <returns></returns>
  10317. [HttpPost]
  10318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10319. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10320. {
  10321. int portType = dto.PortType;
  10322. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10323. var tipsData = new List<int>() { 1, 2, 3 };
  10324. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10325. if (dto.TipsType == 1)
  10326. {
  10327. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10328. }
  10329. else if (dto.TipsType == 2)
  10330. {
  10331. if (portType == 2)
  10332. {
  10333. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10334. }
  10335. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10336. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10337. .Select(x => x.NationalTravelFeeId)
  10338. .Distinct()
  10339. .ToListAsync();
  10340. if (portType == 2)
  10341. {
  10342. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10343. }
  10344. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10345. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10346. .Select(x => x.Country)
  10347. .Distinct()
  10348. .ToArrayAsync();
  10349. if (portType == 2)
  10350. {
  10351. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10352. }
  10353. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10354. return Ok(JsonView(true, "查询成功!", new
  10355. {
  10356. totalAmt = totalAmt,
  10357. remark = remark
  10358. }));
  10359. }
  10360. else if (dto.TipsType == 3)
  10361. {
  10362. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10363. }
  10364. return Ok(JsonView(false));
  10365. }
  10366. /// <summary>
  10367. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10368. /// </summary>
  10369. /// <returns></returns>
  10370. [HttpPost]
  10371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10372. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10373. {
  10374. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10376. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10377. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10378. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10379. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10380. var info = new Grp_EnterExitCostDraft()
  10381. {
  10382. ProvinceId = dto.ProvinceId,
  10383. DraftName = dto.DraftName,
  10384. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10385. CreateUserId = dto.CurrUserId
  10386. };
  10387. _sqlSugar.BeginTran();
  10388. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10389. if (draftId < 1)
  10390. {
  10391. _sqlSugar.RollbackTran();
  10392. return Ok(JsonView(false, "草稿创建失败!"));
  10393. }
  10394. //添加默认权限
  10395. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10396. _sqlSugar.CommitTran();
  10397. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10398. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10399. mobileInfo.Id = draftId;
  10400. mobileInfo.DraftName = dto.DraftName;
  10401. mobileInfo.Currencys = rateInfos;
  10402. mobileInfo.IsAssignPerm = assignPerm;
  10403. return Ok(JsonView(mobileInfo));
  10404. }
  10405. /// <summary>
  10406. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10407. /// </summary>
  10408. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10409. /// <summary>
  10410. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10411. /// </summary>
  10412. /// <returns></returns>
  10413. [HttpPost]
  10414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10415. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10416. {
  10417. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10418. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10419. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10420. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10421. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10422. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10423. //验证查看编辑权限
  10424. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10425. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10426. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10427. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10428. mobileInfo.IsAssignPerm = assignPerm;
  10429. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10430. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10431. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10432. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10433. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10434. {
  10435. ParentId = dac.ParentId,
  10436. SubId = dac.Id,
  10437. Type = dac.Type,
  10438. Days = dac.Days,
  10439. NationalTravelFeeId = dac.NationalTravelFeeId,
  10440. Arae = $"{ntf.Country}-{ntf.City}",
  10441. Cost = dac.Cost,
  10442. Currency = dac.Currency,
  10443. CurrencyName = sd.Name,
  10444. SubTotal = dac.SubTotal,
  10445. })
  10446. .ToList();
  10447. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10448. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10449. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10450. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10451. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10452. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10453. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10454. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10455. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10456. //其他款项
  10457. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10458. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10459. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10460. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10461. .OrderBy((dop, sd1, sd2) => dop.Index)
  10462. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10463. {
  10464. ParentId = dop.ParentId,
  10465. SubId = dop.Id,
  10466. Index = dop.Index,
  10467. SetDataId = dop.SetDataId,
  10468. SetDataName = sd1.Name,
  10469. Cost = dop.Cost,
  10470. Currency = dop.Currency,
  10471. CurrencyName = sd2.Remark,
  10472. SubTotal = dop.SubTotal,
  10473. Remark = dop.Remark,
  10474. })
  10475. .ToArray();
  10476. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10477. return Ok(mobileInfo);
  10478. }
  10479. /// <summary>
  10480. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10481. /// </summary>
  10482. /// <returns></returns>
  10483. [HttpPost]
  10484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10485. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10486. {
  10487. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10488. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10489. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10490. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10491. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10492. //验证查看编辑权限
  10493. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10494. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10495. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10496. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10497. var subType = dto.SubType;
  10498. if (subType == 1) //1:境内费用
  10499. {
  10500. var oneData = new ChoiceOneMobileSubInfoView()
  10501. {
  10502. Id = eecInfo.Id,
  10503. ChoiceOne = eecInfo.ChoiceOne,
  10504. ChoiceOneTotalCost = eecInfo.InsidePay,
  10505. Visa = eecInfo.Visa,
  10506. VisaRemark = eecInfo.VisaRemark,
  10507. YiMiao = eecInfo.YiMiao,
  10508. HeSuan = eecInfo.HeSuan,
  10509. Service = eecInfo.Service,
  10510. Ticket = eecInfo.Ticket,
  10511. Safe = eecInfo.Safe,
  10512. FirstItemRemark = eecInfo.FirstItemRemark
  10513. };
  10514. return Ok(JsonView(oneData));
  10515. }
  10516. else if (subType == 2) //2:国际旅费
  10517. {
  10518. var twoData = new ChoiceTwoMobileSubInfoView()
  10519. {
  10520. Id = eecInfo.Id,
  10521. ChoiceTwoJJ = eecInfo.SumJJC,
  10522. OutsideJJPay = eecInfo.OutsideJJPay,
  10523. ChoiceTwoGW = eecInfo.SumGWC,
  10524. OutsideGWPay = eecInfo.OutsideGWPay,
  10525. ChoiceTwoTD = eecInfo.SumTDC,
  10526. OutsideTDPay = eecInfo.OutsideTDPay,
  10527. AirJJ = eecInfo.AirJJ,
  10528. AirGW = eecInfo.AirGW,
  10529. AirTD = eecInfo.AirTD,
  10530. CityTranffic = eecInfo.CityTranffic,
  10531. TwoItemRemark = eecInfo.TwoItemRemark
  10532. };
  10533. return Ok(JsonView(twoData));
  10534. }
  10535. else if (subType == 3) //3:住宿费
  10536. {
  10537. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10538. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10539. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10540. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10541. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10542. {
  10543. ParentId = dac.ParentId,
  10544. SubId = dac.Id,
  10545. Type = dac.Type,
  10546. Days = dac.Days,
  10547. NationalTravelFeeId = dac.NationalTravelFeeId,
  10548. Arae = $"{ntf.Country}-{ntf.City}",
  10549. Cost = dac.Cost,
  10550. Currency = dac.Currency,
  10551. CurrencyName = sd.Name,
  10552. SubTotal = dac.SubTotal,
  10553. })
  10554. .ToArray();
  10555. var data = new ChoiceDraftMobileSubInfo3To6View()
  10556. {
  10557. ParentId = eecInfo.Id,
  10558. Choice = eecInfo.ChoiceThree,
  10559. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10560. Details = dayAndCostDatas
  10561. };
  10562. return Ok(JsonView(data));
  10563. }
  10564. else if (subType == 4) //4:伙食费
  10565. {
  10566. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10567. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10568. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10569. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10570. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10571. {
  10572. ParentId = dac.ParentId,
  10573. SubId = dac.Id,
  10574. Type = dac.Type,
  10575. Days = dac.Days,
  10576. NationalTravelFeeId = dac.NationalTravelFeeId,
  10577. Arae = $"{ntf.Country}-{ntf.City}",
  10578. Cost = dac.Cost,
  10579. Currency = dac.Currency,
  10580. CurrencyName = sd.Name,
  10581. SubTotal = dac.SubTotal,
  10582. })
  10583. .ToArray();
  10584. var data = new ChoiceDraftMobileSubInfo3To6View()
  10585. {
  10586. ParentId = eecInfo.Id,
  10587. Choice = eecInfo.ChoiceFour,
  10588. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10589. Details = dayAndCostDatas
  10590. };
  10591. return Ok(JsonView(data));
  10592. }
  10593. else if (subType == 5) //5:公杂费
  10594. {
  10595. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10596. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10597. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10598. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10599. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10600. {
  10601. ParentId = dac.ParentId,
  10602. SubId = dac.Id,
  10603. Type = dac.Type,
  10604. Days = dac.Days,
  10605. NationalTravelFeeId = dac.NationalTravelFeeId,
  10606. Arae = $"{ntf.Country}-{ntf.City}",
  10607. Cost = dac.Cost,
  10608. Currency = dac.Currency,
  10609. CurrencyName = sd.Name,
  10610. SubTotal = dac.SubTotal,
  10611. })
  10612. .ToArray();
  10613. var data = new ChoiceDraftMobileSubInfo3To6View()
  10614. {
  10615. ParentId = eecInfo.Id,
  10616. Choice = eecInfo.ChoiceFive,
  10617. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10618. Details = dayAndCostDatas
  10619. };
  10620. return Ok(JsonView(data));
  10621. }
  10622. else if (subType == 6) //6:培训费
  10623. {
  10624. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10625. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10626. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10627. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10628. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10629. {
  10630. ParentId = dac.ParentId,
  10631. SubId = dac.Id,
  10632. Type = dac.Type,
  10633. Days = dac.Days,
  10634. NationalTravelFeeId = dac.NationalTravelFeeId,
  10635. Arae = $"{ntf.Country}-{ntf.City}",
  10636. Cost = dac.Cost,
  10637. Currency = dac.Currency,
  10638. CurrencyName = sd.Name,
  10639. SubTotal = dac.SubTotal,
  10640. })
  10641. .ToArray();
  10642. var data = new ChoiceDraftMobileSubInfo3To6View()
  10643. {
  10644. ParentId = eecInfo.Id,
  10645. Choice = eecInfo.ChoiceSix,
  10646. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10647. Details = dayAndCostDatas
  10648. };
  10649. return Ok(JsonView(data));
  10650. }
  10651. else if (subType == 7) //7:其他
  10652. {
  10653. //其他款项
  10654. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10655. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10656. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10657. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10658. .OrderBy((dop, sd1, sd2) => dop.Index)
  10659. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10660. {
  10661. ParentId = dop.ParentId,
  10662. SubId = dop.Id,
  10663. Index = dop.Index,
  10664. SetDataId = dop.SetDataId,
  10665. SetDataName = sd1.Name,
  10666. Cost = dop.Cost,
  10667. Currency = dop.Currency,
  10668. CurrencyName = sd2.Name,
  10669. SubTotal = dop.SubTotal,
  10670. Remark = dop.Remark,
  10671. })
  10672. .ToArray();
  10673. var data = new ChoiceSevenDraftMobileSubInfoView()
  10674. {
  10675. ParentId = eecInfo.Id,
  10676. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10677. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10678. Details = otherData
  10679. };
  10680. return Ok(JsonView(data));
  10681. }
  10682. return Ok(JsonView(false));
  10683. }
  10684. #region op
  10685. /// <summary>
  10686. /// 移动端更新费用消息通知
  10687. /// </summary>
  10688. /// <param name="draftId"></param>
  10689. /// <param name="id"></param>
  10690. /// <param name="currUserId"></param>
  10691. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10692. {
  10693. try
  10694. {
  10695. ////生成默认文件pdf并且通知人员
  10696. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10697. //{
  10698. // DiId = draftId,
  10699. // ExportType = 1,
  10700. // SubTypeId = 1005
  10701. //}, "pdf");
  10702. ////发送通知
  10703. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10704. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10705. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10706. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10707. ////汇率信息记录
  10708. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10709. }
  10710. catch (Exception ex)
  10711. {
  10712. //记录日志
  10713. throw;
  10714. }
  10715. }
  10716. /// <summary>
  10717. /// 验证出入境费用数据是否存在
  10718. /// 不存在添加
  10719. /// </summary>
  10720. /// <param name="draftId"></param>
  10721. /// <param name="currUserId"></param>
  10722. /// <returns></returns>
  10723. /// <exception cref="CustomException"></exception>
  10724. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10725. {
  10726. var parentId = 0;
  10727. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10728. if (info != null) parentId = info.Id;
  10729. else
  10730. {
  10731. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10732. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10733. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10734. parentId = addId;
  10735. }
  10736. return parentId;
  10737. }
  10738. /// <summary>
  10739. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10740. /// </summary>
  10741. /// <returns></returns>
  10742. [HttpPost]
  10743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10744. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10745. {
  10746. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10747. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10748. //验证查看权限
  10749. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10750. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10751. var userIds = await _sqlSugar
  10752. .Queryable<Grp_EnterExitCostDraftPermission>()
  10753. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10754. .Select(x => x.UserId)
  10755. .ToArrayAsync();
  10756. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10757. var perUsersView = new List<dynamic>();
  10758. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10759. var viewPermissionData = new List<PermissionViewUserview>();
  10760. if (feeBasePerm.Any())
  10761. {
  10762. foreach (var item in feeBasePerm)
  10763. {
  10764. if (item.Users.Any())
  10765. {
  10766. viewPermissionData.AddRange(item.Users);
  10767. }
  10768. }
  10769. }
  10770. foreach (var item in perUsers)
  10771. {
  10772. bool isView1 = false;
  10773. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10774. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10775. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10776. }
  10777. return Ok(JsonView(perUsersView));
  10778. }
  10779. /// <summary>
  10780. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10781. /// </summary>
  10782. /// <returns></returns>
  10783. [HttpPost]
  10784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10785. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10786. {
  10787. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10788. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10789. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10790. //验证查看编辑权限
  10791. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10792. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10793. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10794. foreach (var userId in dto.UserIds)
  10795. {
  10796. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10797. }
  10798. if (permissions.Any())
  10799. {
  10800. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10801. {
  10802. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10803. }
  10804. _sqlSugar.BeginTran();
  10805. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10806. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10807. if (result < 1)
  10808. {
  10809. _sqlSugar.RollbackTran();
  10810. return Ok(JsonView(false));
  10811. }
  10812. _sqlSugar.CommitTran();
  10813. return Ok(JsonView(true));
  10814. }
  10815. return Ok(JsonView(false));
  10816. }
  10817. /// <summary>
  10818. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10819. /// </summary>
  10820. /// <returns></returns>
  10821. [HttpPost]
  10822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10823. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10824. {
  10825. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10826. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10827. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10828. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10829. int id = dto.DraftId;
  10830. if (id <= 0) //add
  10831. {
  10832. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10833. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10834. if (add < 1) return Ok(JsonView(false));
  10835. id = add;
  10836. }
  10837. else //update
  10838. {
  10839. //验证查看编辑权限
  10840. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10841. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10842. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10843. if (upd < 1) return Ok(JsonView(false));
  10844. }
  10845. return Ok(JsonView(new { parentId = id }));
  10846. }
  10847. /// <summary>
  10848. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10849. /// </summary>
  10850. /// <returns></returns>
  10851. [HttpPost]
  10852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10853. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10854. {
  10855. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10856. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10857. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10858. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10859. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10860. int id = dto.DraftId;
  10861. if (id <= 0) //add
  10862. {
  10863. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10864. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10865. if (add < 1) return Ok(JsonView(false));
  10866. id = add;
  10867. }
  10868. else //update
  10869. {
  10870. //验证查看编辑权限
  10871. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10872. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10873. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10874. if (upd < 1) return Ok(JsonView(false));
  10875. }
  10876. #region 汇率变更时更改币种相关费用
  10877. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10878. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10879. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10880. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10881. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10882. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10883. .Select((dac, sd) => new
  10884. {
  10885. dac.Id,
  10886. dac.ParentId,
  10887. CurrencyCode = sd.Name,
  10888. dac.Cost
  10889. })
  10890. .ToList();
  10891. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10892. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10893. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10894. .Select((dop, sd) => new
  10895. {
  10896. dop.Id,
  10897. dop.ParentId,
  10898. CurrencyCode = sd.Name,
  10899. dop.Cost
  10900. })
  10901. .ToList();
  10902. if (dayCosts.Count > 0)
  10903. {
  10904. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10905. foreach (var dc in new_dayCosts)
  10906. {
  10907. var thisCurrency = dc.Key.ToUpper();
  10908. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10909. if (thisRate == 0.00M) continue;
  10910. foreach (var dcSub in dc)
  10911. {
  10912. opDayCosts.Add(new Grp_DayAndCostDraft()
  10913. {
  10914. Id = dcSub.Id,
  10915. ParentId = dcSub.ParentId,
  10916. Cost = dcSub.Cost,
  10917. SubTotal = dcSub.Cost * thisRate,
  10918. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10919. });
  10920. }
  10921. }
  10922. if (opDayCosts.Count > 0)
  10923. {
  10924. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10925. }
  10926. }
  10927. if (dayOtherCosts.Count > 0)
  10928. {
  10929. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10930. foreach (var dc in new_dayOtherCosts)
  10931. {
  10932. var thisCurrency = dc.Key.ToUpper();
  10933. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10934. if (thisRate == 0.00M) continue;
  10935. foreach (var dcSub in dc)
  10936. {
  10937. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10938. {
  10939. Id = dcSub.Id,
  10940. ParentId = dcSub.ParentId,
  10941. Cost = dcSub.Cost,
  10942. SubTotal = dcSub.Cost * thisRate,
  10943. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10944. });
  10945. }
  10946. }
  10947. if (opDayOtherCosts.Count > 0)
  10948. {
  10949. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10950. }
  10951. }
  10952. #endregion
  10953. ////消息通知
  10954. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10955. ////汇率信息记录
  10956. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10957. return Ok(JsonView(new { parentId = id }));
  10958. }
  10959. /// <summary>
  10960. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10961. /// </summary>
  10962. /// <returns></returns>
  10963. [HttpPost]
  10964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10965. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10966. {
  10967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10968. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10970. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10971. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10972. int id = dto.DraftId;
  10973. if (id <= 0) //add
  10974. {
  10975. checkboxInfo.ProvinceId = dto.ProvinceId;
  10976. checkboxInfo.CreateUserId = dto.CurrUserId;
  10977. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10978. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10979. if (add < 1) return Ok(JsonView(false));
  10980. }
  10981. else //update
  10982. {
  10983. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10984. .UpdateColumns(x => new
  10985. {
  10986. x.ChoiceOne,
  10987. x.ChoiceTwo,
  10988. x.SumJJC,
  10989. x.SumGWC,
  10990. x.SumTDC,
  10991. x.ChoiceThree,
  10992. x.ChoiceFour,
  10993. x.ChoiceFive,
  10994. x.ChoiceSix,
  10995. x.OtherExpenses_Checked
  10996. })
  10997. .Where(x => x.Id == id)
  10998. .ExecuteCommandAsync();
  10999. if (upd < 1) return Ok(JsonView(false));
  11000. }
  11001. return Ok(JsonView(new { parentId = id }));
  11002. }
  11003. /// <summary>
  11004. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11005. /// </summary>
  11006. /// <returns></returns>
  11007. [HttpPost]
  11008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11009. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11010. {
  11011. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11012. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11013. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11014. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11015. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11016. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11017. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11018. var checkboxInfo = new Grp_EnterExitCostDraft()
  11019. {
  11020. Id = draftId,
  11021. ProvinceId = dto.ProvinceId,
  11022. CreateUserId = currUserId
  11023. };
  11024. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11025. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11026. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11027. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11028. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11029. if (draftId <= 0) //add
  11030. {
  11031. checkboxInfo.CreateUserId = dto.CurrUserId;
  11032. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11033. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11034. if (add < 1) return Ok(JsonView(false));
  11035. }
  11036. else //update
  11037. {
  11038. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11039. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11040. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11041. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11042. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11043. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11044. .Where(x => x.Id == draftId)
  11045. .ExecuteCommandAsync();
  11046. if (upd < 1) return Ok(JsonView(false));
  11047. }
  11048. return Ok(JsonView(new { parentId = draftId }));
  11049. }
  11050. /// <summary>
  11051. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11052. /// </summary>
  11053. /// <returns></returns>
  11054. [HttpPost]
  11055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11056. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11057. {
  11058. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11059. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11060. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11061. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11062. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11063. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11064. info.ProvinceId = dto.ProvinceId;
  11065. info.FirstItemRemark = dto.FirstItemRemark;
  11066. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11067. if (id <= 0) //add
  11068. {
  11069. info.CreateUserId = dto.CurrUserId;
  11070. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11071. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11072. if (add < 1) return Ok(JsonView(false));
  11073. id = add;
  11074. }
  11075. else //update
  11076. {
  11077. var upd = await _sqlSugar.Updateable(info)
  11078. .UpdateColumns(x => new
  11079. {
  11080. x.ChoiceOne,
  11081. x.InsidePay,
  11082. x.VisaRemark,
  11083. x.Visa,
  11084. x.Service,
  11085. x.Safe,
  11086. x.Ticket,
  11087. x.HeSuan,
  11088. x.YiMiao,
  11089. x.FirstItemRemark
  11090. })
  11091. .Where(x => x.Id == id)
  11092. .ExecuteCommandAsync();
  11093. if (upd < 1) return Ok(JsonView(false));
  11094. }
  11095. ////消息通知
  11096. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11097. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11098. }
  11099. /// <summary>
  11100. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11101. /// </summary>
  11102. /// <returns></returns>
  11103. [HttpPost]
  11104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11105. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11106. {
  11107. int id = dto.DraftId;
  11108. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11109. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11110. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11111. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11112. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11113. info.ProvinceId = dto.ProvinceId;
  11114. info.OutsideJJPay = dto.OutsideJJPay;
  11115. info.OutsideGWPay = dto.OutsideGWPay;
  11116. info.OutsideTDPay = dto.OutsideTDPay;
  11117. info.AirJJ = dto.AirJJ;
  11118. info.AirGW = dto.AirGW;
  11119. info.AirTD = dto.AirTD;
  11120. info.CityTranffic = dto.CityTranffic;
  11121. info.TwoItemRemark = dto.TwoItemRemark;
  11122. info.SumJJC = dto.ChoiceTwoJJ;
  11123. info.SumGWC = dto.ChoiceTwoGW;
  11124. info.SumTDC = dto.ChoiceTwoTD;
  11125. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11126. if (id <= 0) //add
  11127. {
  11128. info.CreateUserId = dto.CurrUserId;
  11129. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11130. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11131. if (addId <= 0) return Ok(JsonView(false));
  11132. id = addId;
  11133. }
  11134. else //update
  11135. {
  11136. var upd = await _sqlSugar.Updateable(info)
  11137. .UpdateColumns(x => new
  11138. {
  11139. x.SumJJC,
  11140. x.OutsideJJPay,
  11141. x.SumGWC,
  11142. x.OutsideGWPay,
  11143. x.SumTDC,
  11144. x.OutsideTDPay,
  11145. x.AirJJ,
  11146. x.AirGW,
  11147. x.AirTD,
  11148. x.CityTranffic,
  11149. x.TwoItemRemark
  11150. })
  11151. .Where(x => x.Id == id)
  11152. .ExecuteCommandAsync();
  11153. if (upd < 1) return Ok(JsonView(false));
  11154. }
  11155. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11156. gwcItemTotal = info.AirGW + info.CityTranffic;
  11157. tdcItemTotal = info.AirTD + info.CityTranffic;
  11158. ////消息通知
  11159. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11160. return Ok(JsonView(new
  11161. {
  11162. parentId = id,
  11163. choiceTwoJJ = dto.ChoiceTwoJJ,
  11164. jjcItemTotal = jjcItemTotal,
  11165. choiceTwoGW = dto.ChoiceTwoGW,
  11166. gwcItemTotal = gwcItemTotal,
  11167. choiceTwoTD = dto.ChoiceTwoTD,
  11168. tdcItemTotal = tdcItemTotal
  11169. }));
  11170. }
  11171. /// <summary>
  11172. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11173. /// </summary>
  11174. /// <returns></returns>
  11175. [HttpPost]
  11176. [ApiExplorerSettings(IgnoreApi = true)]
  11177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11178. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11179. {
  11180. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11181. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11182. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11183. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11184. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11185. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11186. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11187. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11188. {
  11189. Id = x.Id,
  11190. ParentId = dto.DraftId,
  11191. Type = dto.FeeType,
  11192. Days = x.Days,
  11193. NationalTravelFeeId = x.NationalTravelFeeId,
  11194. Cost = x.Cost,
  11195. Currency = x.Currency,
  11196. SubTotal = x.SubTotal,
  11197. CreateUserId = dto.CurrUserId
  11198. })
  11199. .ToList();
  11200. var adds = infos.Where(x => x.Id <= 0).ToList();
  11201. var upds = infos.Where(x => x.Id > 0).ToList();
  11202. if (adds.Count > 0)
  11203. {
  11204. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11205. if (add < 1) return Ok(JsonView(false));
  11206. }
  11207. if (upds.Count > 0)
  11208. {
  11209. var upd = await _sqlSugar.Updateable(adds)
  11210. .UpdateColumns(x => new
  11211. {
  11212. x.Days,
  11213. x.NationalTravelFeeId,
  11214. x.Cost,
  11215. x.Currency,
  11216. x.SubTotal
  11217. })
  11218. .WhereColumns(x => new { x.Id })
  11219. .ExecuteCommandAsync();
  11220. if (upd < 1) return Ok(JsonView(false));
  11221. }
  11222. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11223. ////消息通知
  11224. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11225. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11226. return Ok(JsonView(new { itemTotal = itemTotal }));
  11227. }
  11228. /// <summary>
  11229. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11230. /// </summary>
  11231. /// <returns></returns>
  11232. [HttpPost]
  11233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11234. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11235. {
  11236. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11237. int subId = dto.SubId, feeType = dto.FeeType;
  11238. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11239. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11240. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11241. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11242. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11243. subInfo.Id = subId;
  11244. subInfo.ParentId = dto.DraftId;
  11245. if (feeType == 3) subInfo.Type = 1;
  11246. else if (feeType == 4) subInfo.Type = 2;
  11247. else if (feeType == 5) subInfo.Type = 3;
  11248. else if (feeType == 6) subInfo.Type = 4;
  11249. subInfo.CreateUserId = dto.CurrUserId;
  11250. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11251. if (parentId < 1) return Ok(JsonView(false));
  11252. //子表op
  11253. if (subId < 1)
  11254. {
  11255. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11256. if (subAdd < 1) return Ok(JsonView(false));
  11257. }
  11258. else
  11259. {
  11260. var subUpd = await _sqlSugar.Updateable(subInfo)
  11261. .UpdateColumns(x => new
  11262. {
  11263. x.Days,
  11264. x.NationalTravelFeeId,
  11265. x.Cost,
  11266. x.Currency,
  11267. x.SubTotal
  11268. })
  11269. .WhereColumns(x => new { x.Id })
  11270. .ExecuteCommandAsync();
  11271. if (subUpd < 1) return Ok(JsonView(false));
  11272. }
  11273. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11274. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11275. }
  11276. /// <summary>
  11277. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11278. /// </summary>
  11279. /// <returns></returns>
  11280. [HttpPost]
  11281. [ApiExplorerSettings(IgnoreApi = true)]
  11282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11283. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11284. {
  11285. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11286. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11287. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11288. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11289. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11290. {
  11291. Id = x.Id,
  11292. ParentId = dto.DraftId,
  11293. SetDataId = x.SetDataId,
  11294. Index = x.Index,
  11295. Cost = x.Cost,
  11296. Currency = x.Currency,
  11297. SubTotal = x.SubTotal,
  11298. CreateUserId = dto.CurrUserId,
  11299. Remark = x.Remark
  11300. }).ToList();
  11301. var adds = infos.Where(x => x.Id <= 0).ToList();
  11302. var upds = infos.Where(x => x.Id > 0).ToList();
  11303. if (adds.Count > 0)
  11304. {
  11305. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11306. if (add < 1) return Ok(JsonView(false));
  11307. }
  11308. if (upds.Count > 0)
  11309. {
  11310. var upd = await _sqlSugar.Updateable(adds)
  11311. .UpdateColumns(x => new
  11312. {
  11313. x.Index,
  11314. x.SetDataId,
  11315. x.Cost,
  11316. x.Currency,
  11317. x.SubTotal,
  11318. x.Remark
  11319. })
  11320. .WhereColumns(x => new { x.Id })
  11321. .ExecuteCommandAsync();
  11322. if (upd < 1) return Ok(JsonView(false));
  11323. }
  11324. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11325. //消息通知
  11326. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11327. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11328. return Ok(JsonView(new { itemTotal = itemTotal }));
  11329. }
  11330. /// <summary>
  11331. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11332. /// </summary>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11337. {
  11338. int subId = dto.SubId, id = dto.DraftId;
  11339. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11340. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11341. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11342. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11343. subInfo.Id = subId;
  11344. subInfo.ParentId = id;
  11345. subInfo.CreateUserId = dto.CurrUserId;
  11346. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11347. if (parentId < 1) return Ok(JsonView(false));
  11348. #region 子表op
  11349. if (subId < 1)//add
  11350. {
  11351. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11352. if (subAdd < 1) return Ok(JsonView(false));
  11353. }
  11354. else //upd
  11355. {
  11356. var subUpd = await _sqlSugar.Updateable(subInfo)
  11357. .UpdateColumns(x => new
  11358. {
  11359. x.Index,
  11360. x.SetDataId,
  11361. x.Cost,
  11362. x.Currency,
  11363. x.SubTotal,
  11364. x.Remark
  11365. })
  11366. .WhereColumns(x => new { x.Id })
  11367. .ExecuteCommandAsync();
  11368. if (subUpd < 1) return Ok(JsonView(false));
  11369. }
  11370. #endregion
  11371. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11372. ////消息通知
  11373. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11374. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11375. }
  11376. /// <summary>
  11377. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11378. /// </summary>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11383. {
  11384. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11385. if (data.Code != 0)
  11386. {
  11387. return Ok(JsonView(false, data.Msg));
  11388. }
  11389. return Ok(JsonView(true, "操作成功!", data.Data));
  11390. }
  11391. /// <summary>
  11392. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11393. /// </summary>
  11394. /// <param name="dto"></param>
  11395. /// <returns></returns>
  11396. [HttpPost]
  11397. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11398. {
  11399. var data = new Grp_DayOtherPriceDraft()
  11400. {
  11401. Id = dto.Id,
  11402. IsDel = 1,
  11403. DeleteUserId = dto.DeleteUserId,
  11404. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11405. };
  11406. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11407. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11408. return Ok(JsonView(false, "删除失败!"));
  11409. }
  11410. #endregion
  11411. #endregion
  11412. #region 团组经理模块 出入境费用报价表
  11413. /// <summary>
  11414. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11415. /// </summary>
  11416. /// <returns></returns>
  11417. [HttpPost]
  11418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11419. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11420. {
  11421. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11422. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11423. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11424. initRates.Insert(0, cnyInfo);
  11425. liveRates.Insert(0, cnyInfo);
  11426. return Ok(JsonView(true, "查询成功!", new
  11427. {
  11428. InitRates = initRates,
  11429. LiveRates = liveRates
  11430. }));
  11431. }
  11432. /// <summary>
  11433. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11434. /// </summary>
  11435. /// <returns></returns>
  11436. [HttpPost]
  11437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11438. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  11439. {
  11440. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11441. }
  11442. /// <summary>
  11443. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11444. /// </summary>
  11445. /// <returns></returns>
  11446. [HttpPost]
  11447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11448. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  11449. {
  11450. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11451. }
  11452. /// <summary>
  11453. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11454. /// </summary>
  11455. /// <returns></returns>
  11456. [HttpPost]
  11457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11458. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11459. {
  11460. int groupId = dto.DiId,
  11461. currUserId = dto.CurrUserId;
  11462. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11463. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11464. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11465. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  11466. var infoView = info.Data as EnterExitCostInfoView;
  11467. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11468. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11469. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11470. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11471. var eecRates = infoView.Currencys;
  11472. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11473. int pplNum = 1;
  11474. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11475. var views = new List<QuoteSubItemInfo>();
  11476. #region 数据填充
  11477. var intTravelCosts = new List<QuoteSubItemInfo>();
  11478. #region 机票费用 1354
  11479. int intTravelIndex = 1;
  11480. if (infoView.SumJJC == 1)
  11481. {
  11482. intTravelCosts.Add(new QuoteSubItemInfo
  11483. {
  11484. ItemId = 1354,
  11485. Index = intTravelIndex,
  11486. FeeName = "经济舱",
  11487. UnitPrice = infoView.AirJJ,
  11488. Currency = "CNY",
  11489. Quantity = 1,
  11490. PplNum = 1,
  11491. TotalAmt = infoView.AirJJ,
  11492. Remark = "",
  11493. });
  11494. intTravelIndex++;
  11495. }
  11496. if (infoView.SumGWC == 1)
  11497. {
  11498. intTravelCosts.Add(new QuoteSubItemInfo
  11499. {
  11500. ItemId = 1354,
  11501. Index = intTravelIndex,
  11502. FeeName = "公务舱",
  11503. UnitPrice = infoView.AirGW,
  11504. Currency = "CNY",
  11505. Quantity = 1,
  11506. PplNum = 1,
  11507. TotalAmt = infoView.AirGW,
  11508. Remark = "",
  11509. });
  11510. intTravelIndex++;
  11511. }
  11512. if (infoView.SumTDC == 1)
  11513. {
  11514. intTravelCosts.Add(new QuoteSubItemInfo
  11515. {
  11516. ItemId = 1354,
  11517. Index = intTravelIndex,
  11518. FeeName = "头等舱",
  11519. UnitPrice = infoView.AirTD,
  11520. Currency = "CNY",
  11521. Quantity = 1,
  11522. PplNum = 1,
  11523. TotalAmt = infoView.AirTD,
  11524. Remark = "",
  11525. });
  11526. intTravelIndex++;
  11527. }
  11528. intTravelCosts.Add(new QuoteSubItemInfo
  11529. {
  11530. ItemId = 1354,
  11531. Index = intTravelIndex,
  11532. FeeName = "城市间交通费用",
  11533. UnitPrice = infoView.CityTranffic,
  11534. Currency = "CNY",
  11535. Quantity = 1,
  11536. PplNum = pplNum,
  11537. TotalAmt = infoView.CityTranffic * pplNum,
  11538. Remark = "",
  11539. });
  11540. views.AddRange(intTravelCosts);
  11541. #endregion
  11542. var accomCosts = new List<QuoteSubItemInfo>();
  11543. #region 住宿费 1355
  11544. if (infoView.QuarterageData.Any())
  11545. {
  11546. int accomIndex = 1;
  11547. int accomItemTypeId = 1355;
  11548. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11549. foreach (var item in groupData)
  11550. {
  11551. string feeName = string.Empty;
  11552. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11553. if (countryInfo != null)
  11554. {
  11555. feeName = countryInfo.Country;
  11556. var city = countryInfo.City;
  11557. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11558. {
  11559. feeName += $"-{city}";
  11560. }
  11561. }
  11562. var hotelInfo = item.FirstOrDefault();
  11563. if (hotelInfo == null) continue;
  11564. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11565. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11566. int quantity = item.ToList().Count;
  11567. accomCosts.Add(new QuoteSubItemInfo
  11568. {
  11569. ItemId = accomItemTypeId,
  11570. Index = accomIndex,
  11571. FeeName = feeName,
  11572. UnitPrice = hotelInfo.Cost,
  11573. Currency = thisCurrency,
  11574. Quantity = quantity,
  11575. PplNum = pplNum,
  11576. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11577. Remark = "",
  11578. });
  11579. accomIndex++;
  11580. }
  11581. views.AddRange(accomCosts);
  11582. }
  11583. #endregion
  11584. var mealCosts = new List<QuoteSubItemInfo>();
  11585. #region 餐饮费 1356
  11586. if (infoView.BoardWagesData.Any())
  11587. {
  11588. var mealIndex = 1;
  11589. int mealItemTypeId = 1356;
  11590. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11591. foreach (var item in groupData)
  11592. {
  11593. string feeName = string.Empty;
  11594. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11595. if (countryInfo != null)
  11596. {
  11597. feeName = countryInfo.Country;
  11598. var city = countryInfo.City;
  11599. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11600. {
  11601. feeName += $"-{city}";
  11602. }
  11603. }
  11604. var mealInfo = item.FirstOrDefault();
  11605. if (mealInfo == null) continue;
  11606. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11607. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11608. int quantity = item.ToList().Count;
  11609. mealCosts.Add(new QuoteSubItemInfo
  11610. {
  11611. ItemId = mealItemTypeId,
  11612. Index = mealIndex,
  11613. FeeName = feeName,
  11614. UnitPrice = mealInfo.Cost,
  11615. Currency = thisCurrency,
  11616. Quantity = quantity,
  11617. PplNum = pplNum,
  11618. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11619. Remark = "",
  11620. });
  11621. mealIndex++;
  11622. }
  11623. views.AddRange(mealCosts);
  11624. }
  11625. #endregion
  11626. var miscCosts = new List<QuoteSubItemInfo>();
  11627. #region 公杂费 1364
  11628. if (infoView.MiscellaneousFeeData.Any())
  11629. {
  11630. var miscIndex = 1;
  11631. int miscItemTypeId = 1364;
  11632. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11633. foreach (var item in groupData)
  11634. {
  11635. string feeName = string.Empty;
  11636. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11637. if (countryInfo != null)
  11638. {
  11639. feeName = countryInfo.Country;
  11640. var city = countryInfo.City;
  11641. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11642. {
  11643. feeName += $"-{city}";
  11644. }
  11645. }
  11646. var miscInfo = item.FirstOrDefault();
  11647. if (miscInfo == null) continue;
  11648. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11649. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11650. int quantity = item.ToList().Count;
  11651. mealCosts.Add(new QuoteSubItemInfo
  11652. {
  11653. ItemId = miscItemTypeId,
  11654. Index = miscIndex,
  11655. FeeName = feeName,
  11656. UnitPrice = miscInfo.Cost,
  11657. Currency = thisCurrency,
  11658. Quantity = quantity,
  11659. PplNum = pplNum,
  11660. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11661. Remark = "",
  11662. });
  11663. miscIndex++;
  11664. }
  11665. views.AddRange(mealCosts);
  11666. }
  11667. #endregion
  11668. #region 签证+保险 1362
  11669. int visaInsIndex = 1;
  11670. int visaInsItemTypeId = 1362;
  11671. if (infoView.Visa > 0)
  11672. {
  11673. views.Add(new QuoteSubItemInfo()
  11674. {
  11675. ItemId = visaInsItemTypeId,
  11676. Index = visaInsIndex,
  11677. FeeName = $"签证",
  11678. UnitPrice = infoView.Visa,
  11679. Currency = $"CNY",
  11680. Quantity = 1,
  11681. PplNum = pplNum,
  11682. TotalAmt = infoView.Visa * pplNum,
  11683. Remark = "",
  11684. });
  11685. visaInsIndex++;
  11686. }
  11687. if (infoView.Safe > 0)
  11688. {
  11689. views.Add(new QuoteSubItemInfo()
  11690. {
  11691. ItemId = visaInsItemTypeId,
  11692. Index = visaInsIndex,
  11693. FeeName = $"保险",
  11694. UnitPrice = infoView.Safe,
  11695. Currency = $"CNY",
  11696. Quantity = 1,
  11697. PplNum = pplNum,
  11698. TotalAmt = infoView.Safe * pplNum,
  11699. Remark = "",
  11700. });
  11701. }
  11702. #endregion
  11703. #region 服务费 1363
  11704. int serviceFeeIndex = 1;
  11705. int serviceFeeItemTypeId = 1363;
  11706. if (infoView.Service > 0)
  11707. {
  11708. views.Add(new QuoteSubItemInfo()
  11709. {
  11710. ItemId = serviceFeeItemTypeId,
  11711. Index = serviceFeeIndex,
  11712. FeeName = $"服务费",
  11713. UnitPrice = infoView.Service,
  11714. Currency = $"CNY",
  11715. Quantity = 1,
  11716. PplNum = pplNum,
  11717. TotalAmt = infoView.Service * pplNum,
  11718. Remark = "",
  11719. });
  11720. }
  11721. #endregion
  11722. #endregion
  11723. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11724. result.Rates = eecRates.ToArray();
  11725. if (result.FeeItems.Any())
  11726. {
  11727. result.FeeItems.Select(x =>
  11728. {
  11729. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11730. if (feeInfos.Any()) x.Infos = feeInfos;
  11731. return x;
  11732. }
  11733. )
  11734. .OrderBy(x => x.Index)
  11735. .ToList();
  11736. }
  11737. return Ok(JsonView(result));
  11738. }
  11739. /// <summary>
  11740. /// 团组模块 - 出入境费用报价表 - Info
  11741. /// </summary>
  11742. /// <returns></returns>
  11743. [HttpPost]
  11744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11745. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11746. {
  11747. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11748. if (!info.Rates.Any())
  11749. {
  11750. var rates = await GeneralMethod.EnterExitCostInitRate();
  11751. info.Rates = rates.ToArray();
  11752. }
  11753. return Ok(JsonView(info));
  11754. }
  11755. /// <summary>
  11756. /// 团组模块 - 出入境费用报价表 - OP
  11757. /// </summary>
  11758. /// <returns></returns>
  11759. [HttpPost]
  11760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11761. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11762. {
  11763. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11764. }
  11765. /// <summary>
  11766. /// 团组模块 - 出入境费用报价表 - 删除 项
  11767. /// </summary>
  11768. /// <returns></returns>
  11769. [HttpPost]
  11770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11771. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11772. {
  11773. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11774. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11775. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11776. }
  11777. /// <summary>
  11778. /// 团组模块 - 出入境费用报价表 - 导出
  11779. /// </summary>
  11780. /// <returns></returns>
  11781. [HttpPost]
  11782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11783. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11784. {
  11785. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11786. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11787. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11788. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11789. var rates = info.Rates;
  11790. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11791. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11792. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11793. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11794. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11795. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11796. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11797. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11798. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11799. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11800. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11801. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11802. //获取模板
  11803. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11804. var designer = new WorkbookDesigner();
  11805. designer.Workbook = new Workbook(tempPath);
  11806. designer.SetDataSource("QuoteName", info.Name);
  11807. designer.SetDataSource("CompanyTitle", "公司名称");
  11808. designer.SetDataSource("CompanyLabel", "");
  11809. #region 国际旅费
  11810. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  11811. if (intTravelCosts.Infos.Any())
  11812. {
  11813. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11814. StringBuilder label = new StringBuilder();
  11815. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11816. if (infos.Any())
  11817. {
  11818. label.Append(infos.Sum(x => x.PplNum));
  11819. label.Append("人全程机票:");
  11820. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11821. label.AppendLine("元");
  11822. }
  11823. foreach (var item in intTravelCosts.Infos)
  11824. {
  11825. label.Append(item.FeeName);
  11826. label.Append(":");
  11827. label.Append(item.UnitPrice.TruncDecimals(2));
  11828. label.Append("元/人*");
  11829. label.Append(item.PplNum);
  11830. label.AppendLine("人");
  11831. }
  11832. if (label.HasValue())
  11833. {
  11834. label.Append("\r\n以上小计:");
  11835. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11836. label.Append("元");
  11837. }
  11838. designer.SetDataSource("IntTravelLabel", label.ToString());
  11839. }
  11840. #endregion
  11841. #region 住宿费
  11842. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  11843. if (accomCosts.Infos.Any())
  11844. {
  11845. string currencyName = string.Empty;
  11846. decimal rate = 1.0000M;
  11847. StringBuilder label = new StringBuilder();
  11848. label.AppendLine("全程五星酒店,每人1间房");
  11849. foreach (var item in accomCosts.Infos)
  11850. {
  11851. string hotelName = string.Empty;
  11852. if (item.FeeName.Contains("-"))
  11853. {
  11854. var feeName = item.FeeName.Split('-');
  11855. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11856. }
  11857. else hotelName = $"\r\n{item.FeeName}:";
  11858. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11859. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11860. rate = rateInfo?.Rate ?? 1.0000M;
  11861. label.Append(hotelName);
  11862. label.Append(item.UnitPrice.TruncDecimals(2));
  11863. label.Append(currencyName);
  11864. label.Append("/间/晚*");
  11865. label.Append(item.Quantity.ToString("#0"));
  11866. label.AppendLine("人");
  11867. }
  11868. if (label.HasValue())
  11869. {
  11870. label.Append("\r\n以上小计:");
  11871. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11872. label.Append("元(");
  11873. label.Append(currencyName);
  11874. label.Append("汇率:");
  11875. label.Append(rate.TruncDecimals(4));
  11876. label.Append(")");
  11877. }
  11878. designer.SetDataSource("AccomLabel", label.ToString());
  11879. }
  11880. #endregion
  11881. #region 餐饮费
  11882. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11883. if (mealCosts.Infos.Any())
  11884. {
  11885. string currencyName = string.Empty;
  11886. decimal rate = 1.0000M;
  11887. StringBuilder label = new StringBuilder();
  11888. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11889. foreach (var item in mealCosts.Infos)
  11890. {
  11891. string name = string.Empty;
  11892. if (item.FeeName.Contains("-"))
  11893. {
  11894. var feeName = item.FeeName.Split('-');
  11895. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11896. }
  11897. else name = $"\r\n{item.FeeName}:";
  11898. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11899. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11900. rate = rateInfo?.Rate ?? 1.0000M;
  11901. label.Append(name);
  11902. label.Append(item.UnitPrice.TruncDecimals(2));
  11903. label.Append(currencyName);
  11904. label.Append("/天*");
  11905. label.Append(item.Quantity.ToString("#0"));
  11906. label.Append("*");
  11907. label.Append(item.PplNum);
  11908. label.Append("人\r\n");
  11909. }
  11910. if (label.HasValue())
  11911. {
  11912. label.Append("\r\n以上小计:");
  11913. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11914. label.Append("元\r\n(");
  11915. label.Append("汇率:");
  11916. label.Append(rate.TruncDecimals(4));
  11917. label.Append(")");
  11918. }
  11919. designer.SetDataSource("MealLabel", label.ToString());
  11920. }
  11921. #endregion
  11922. #region 车辆安排
  11923. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11924. if (vehArranges.Infos.Any())
  11925. {
  11926. string currencyName = string.Empty;
  11927. //decimal rate = 1.0000M;
  11928. StringBuilder label = new StringBuilder();
  11929. foreach (var item in vehArranges.Infos)
  11930. {
  11931. label.Append(item.Remark);
  11932. label.AppendLine();
  11933. label.AppendLine();
  11934. label.Append(item.FeeName);
  11935. label.Append("\r\n\r\n费用:");
  11936. label.Append(item.FeeName);
  11937. label.Append(item.TotalAmt.TruncDecimals(2));
  11938. }
  11939. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11940. }
  11941. #endregion
  11942. #region 邀请函发放对象
  11943. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11944. #endregion
  11945. designer.Process();
  11946. //文件名
  11947. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11948. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11949. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11950. return Ok(JsonView(true, "成功", url));
  11951. }
  11952. #endregion
  11953. #region 签证费用录入
  11954. /// <summary>
  11955. /// 根据diid查询签证费用列表
  11956. /// </summary>
  11957. /// <param name="dto"></param>
  11958. /// <returns></returns>
  11959. [HttpPost]
  11960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11961. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11962. {
  11963. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11964. if (groupData.Code != 0)
  11965. {
  11966. return Ok(JsonView(false, groupData.Msg));
  11967. }
  11968. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11969. }
  11970. /// <summary>
  11971. /// 根据签证费用Id查询单条数据及c表数据
  11972. /// </summary>
  11973. /// <param name="dto"></param>
  11974. /// <returns></returns>
  11975. [HttpPost]
  11976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11977. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11978. {
  11979. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11980. if (groupData.Code != 0)
  11981. {
  11982. return Ok(JsonView(false, groupData.Msg));
  11983. }
  11984. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11985. }
  11986. /// <summary>
  11987. /// 签证费用删除
  11988. /// </summary>
  11989. /// <param name="dto"></param>
  11990. /// <returns></returns>
  11991. [HttpPost]
  11992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11993. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11994. {
  11995. _sqlSugar.BeginTran();
  11996. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11997. if (!res)
  11998. {
  11999. _sqlSugar.RollbackTran();
  12000. return Ok(JsonView(false, "删除失败"));
  12001. }
  12002. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12003. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12004. .SetColumns(a => new Grp_CreditCardPayment()
  12005. {
  12006. IsDel = 1,
  12007. DeleteUserId = dto.DeleteUserId,
  12008. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12009. })
  12010. .ExecuteCommand();
  12011. if (resSub < 1)
  12012. {
  12013. _sqlSugar.RollbackTran();
  12014. return Ok(JsonView(false, "删除失败"));
  12015. }
  12016. _sqlSugar.CommitTran();
  12017. return Ok(JsonView(true, "删除成功!"));
  12018. }
  12019. /// <summary>
  12020. /// 签证费用录入下拉框初始化
  12021. /// </summary>
  12022. /// <returns></returns>
  12023. [HttpPost]
  12024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12025. public async Task<IActionResult> VisaPriceAddSelect()
  12026. {
  12027. //支付方式
  12028. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12029. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12030. //币种
  12031. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12032. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12033. //乘客类型
  12034. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12035. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12036. //卡类型
  12037. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12038. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12039. //代办费类型
  12040. var agencyFeeTypeData = new List<dynamic>() {
  12041. new { id = 0 , Text = "未选择" },
  12042. new { id = 1 , Text = "小公务" },
  12043. new { id = 2 , Text = "大公务" },
  12044. };
  12045. //签证费用标准国家Data
  12046. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12047. var data = new
  12048. {
  12049. Payment = _Payment,
  12050. CurrencyList = _CurrencyList,
  12051. PassengerType = _PassengerType,
  12052. BankCard = _BankCard,
  12053. AgencyFeeType = agencyFeeTypeData,
  12054. CountryFeeData = visaCountryFeeData
  12055. };
  12056. return Ok(JsonView(true, "查询成功!", data));
  12057. }
  12058. /// <summary>
  12059. /// 签证费用录入操作(Status:1.新增,2.修改)
  12060. /// </summary>
  12061. /// <param name="dto"></param>
  12062. /// <returns></returns>
  12063. [HttpPost]
  12064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12065. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12066. {
  12067. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12068. if (groupData.Code != 0)
  12069. {
  12070. return Ok(JsonView(false, groupData.Msg));
  12071. }
  12072. #region 应用推送
  12073. try
  12074. {
  12075. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12076. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12077. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12078. //2024-10-21 新增LZ UID
  12079. var userIds = new List<int>() { 21 };
  12080. string title = $"系统通知";
  12081. string content = "";
  12082. var diId = dto.DiId;
  12083. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12084. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12085. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12086. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12087. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12088. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12089. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12090. }
  12091. catch (Exception ex)
  12092. {
  12093. }
  12094. #endregion
  12095. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12096. }
  12097. #endregion
  12098. #region 签证提成录入
  12099. /// <summary>
  12100. /// 签证提成录入
  12101. /// 基础数据
  12102. /// </summary>
  12103. /// <returns></returns>
  12104. [HttpGet]
  12105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12106. public async Task<IActionResult> VisaCommissionInit()
  12107. {
  12108. return Ok(await _visaCommissionRep.Init());
  12109. }
  12110. /// <summary>
  12111. /// 签证提成录入
  12112. /// Item
  12113. /// </summary>
  12114. /// <param name="_dto"></param>
  12115. /// <returns></returns>
  12116. [HttpPost]
  12117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12118. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12119. {
  12120. var validator = new VisaCommissionItemDtoValidator();
  12121. var validatorRes = await validator.ValidateAsync(_dto);
  12122. if (!validatorRes.IsValid)
  12123. {
  12124. StringBuilder sb = new StringBuilder();
  12125. foreach (var item in validatorRes.Errors)
  12126. {
  12127. sb.AppendLine(item.ErrorMessage);
  12128. }
  12129. return Ok(JsonView(false, sb.ToString()));
  12130. }
  12131. return Ok(await _visaCommissionRep.Item(_dto));
  12132. }
  12133. /// <summary>
  12134. /// 签证提成录入
  12135. /// Save
  12136. /// </summary>
  12137. /// <param name="_dto"></param>
  12138. /// <returns></returns>
  12139. [HttpPost]
  12140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12141. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12142. {
  12143. //参数验证
  12144. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12145. foreach (var item in _dto.Items)
  12146. {
  12147. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12148. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12149. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12150. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12151. }
  12152. return Ok(await _visaCommissionRep.Save(_dto));
  12153. }
  12154. /// <summary>
  12155. /// 签证提成录入
  12156. /// Create
  12157. /// </summary>
  12158. /// <param name="_dto"></param>
  12159. /// <returns></returns>
  12160. [HttpPost]
  12161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12162. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12163. {
  12164. var validator = new VisaCommissionCreateDtoValidator();
  12165. var validatorRes = await validator.ValidateAsync(_dto);
  12166. if (!validatorRes.IsValid)
  12167. {
  12168. StringBuilder sb = new StringBuilder();
  12169. foreach (var item in validatorRes.Errors)
  12170. {
  12171. sb.AppendLine(item.ErrorMessage);
  12172. }
  12173. return Ok(JsonView(false, sb.ToString()));
  12174. }
  12175. return Ok(await _visaCommissionRep.Create(_dto));
  12176. }
  12177. /// <summary>
  12178. /// 签证提成录入
  12179. /// Put(编辑)
  12180. /// </summary>
  12181. /// <param name="id"></param>
  12182. /// <param name="_dto"></param>
  12183. /// <returns></returns>
  12184. [HttpPut]
  12185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12186. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12187. {
  12188. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12189. var validator = new VisaCommissionCreateDtoValidator();
  12190. var validatorRes = await validator.ValidateAsync(_dto);
  12191. if (!validatorRes.IsValid)
  12192. {
  12193. StringBuilder sb = new StringBuilder();
  12194. foreach (var item in validatorRes.Errors)
  12195. {
  12196. sb.AppendLine(item.ErrorMessage);
  12197. }
  12198. return Ok(JsonView(false, sb.ToString()));
  12199. }
  12200. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12201. }
  12202. /// <summary>
  12203. /// 签证提成录入
  12204. /// Del
  12205. /// </summary>
  12206. /// <param name="id"></param>
  12207. /// <param name="currUserId"></param>
  12208. /// <returns></returns>
  12209. [HttpPost]
  12210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12211. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12212. {
  12213. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12214. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12215. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12216. }
  12217. #endregion
  12218. #region op费用录入
  12219. /// <summary>
  12220. /// 根据diid查询op费用列表
  12221. /// </summary>
  12222. /// <param name="dto"></param>
  12223. /// <returns></returns>
  12224. [HttpPost]
  12225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12226. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12227. {
  12228. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12229. if (groupData.Code != 0)
  12230. {
  12231. return Ok(JsonView(false, groupData.Msg));
  12232. }
  12233. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12234. }
  12235. /// <summary>
  12236. /// 根据op费用Id查询单条数据及c表数据
  12237. /// </summary>
  12238. /// <param name="dto"></param>
  12239. /// <returns></returns>
  12240. [HttpPost]
  12241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12242. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12243. {
  12244. try
  12245. {
  12246. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12247. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12248. var data = new
  12249. {
  12250. CarTouristGuideGround = _groupData,
  12251. CreditCardPayment = _creditCardPayment
  12252. };
  12253. return Ok(JsonView(true, "查询成功!", data));
  12254. }
  12255. catch (Exception ex)
  12256. {
  12257. return Ok(JsonView(false, "程序错误!"));
  12258. }
  12259. }
  12260. /// <summary>
  12261. /// op费用删除
  12262. /// </summary>
  12263. /// <param name="dto"></param>
  12264. /// <returns></returns>
  12265. [HttpPost]
  12266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12267. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12268. {
  12269. try
  12270. {
  12271. _sqlSugar.BeginTran();
  12272. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12273. if (!res)
  12274. {
  12275. return Ok(JsonView(false, "删除失败"));
  12276. }
  12277. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12278. {
  12279. IsDel = 1,
  12280. DeleteUserId = dto.DeleteUserId,
  12281. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12282. }).ExecuteCommandAsync();
  12283. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12284. {
  12285. IsDel = 1,
  12286. DeleteUserId = dto.DeleteUserId,
  12287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12288. }).ExecuteCommandAsync();
  12289. #region 删除超支相关数据
  12290. //删除导入的超支数据
  12291. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12292. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12293. {
  12294. IsDel = 1,
  12295. DeleteUserId = dto.DeleteUserId,
  12296. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12297. }).ExecuteCommand();
  12298. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12299. {
  12300. IsDel = 1,
  12301. DeleteUserId = dto.DeleteUserId,
  12302. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12303. }).ExecuteCommand();
  12304. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12305. {
  12306. IsDel = 1,
  12307. DeleteUserId = dto.DeleteUserId,
  12308. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12309. }).ExecuteCommand();
  12310. #endregion
  12311. _sqlSugar.CommitTran();
  12312. return Ok(JsonView(true, "删除成功!"));
  12313. }
  12314. catch (Exception ex)
  12315. {
  12316. _sqlSugar.RollbackTran();
  12317. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12318. }
  12319. }
  12320. /// <summary>
  12321. /// op费用录入操作(Status:1.新增,2.修改)
  12322. /// </summary>
  12323. /// <param name="dto"></param>
  12324. /// <returns></returns>
  12325. [HttpPost]
  12326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12327. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12328. {
  12329. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12330. if (groupData.Code != 0)
  12331. {
  12332. return Ok(JsonView(false, groupData.Msg));
  12333. }
  12334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12335. }
  12336. /// <summary>
  12337. /// 填写费用详细页面初始化绑定
  12338. /// </summary>
  12339. /// <param name="dto"></param>
  12340. /// <returns></returns>
  12341. [HttpPost]
  12342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12343. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12344. {
  12345. try
  12346. {
  12347. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12348. if (groupData.Code != 0)
  12349. {
  12350. return Ok(JsonView(false, groupData.Msg));
  12351. }
  12352. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12353. }
  12354. catch (Exception ex)
  12355. {
  12356. return Ok(JsonView(false, ex.Message));
  12357. }
  12358. }
  12359. /// <summary>
  12360. /// 根据op费用Id查询详细数据
  12361. /// </summary>
  12362. /// <param name="dto"></param>
  12363. /// <returns></returns>
  12364. [HttpPost]
  12365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12366. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12367. {
  12368. try
  12369. {
  12370. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12371. if (groupData.Code != 0)
  12372. {
  12373. return Ok(JsonView(false, groupData.Msg));
  12374. }
  12375. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12376. }
  12377. catch (Exception ex)
  12378. {
  12379. return Ok(JsonView(false, ex.Message));
  12380. }
  12381. }
  12382. /// <summary>
  12383. /// OP费用录入填写详情
  12384. /// </summary>
  12385. /// <param name="dto"></param>
  12386. /// <returns></returns>
  12387. [HttpPost]
  12388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12389. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12390. {
  12391. try
  12392. {
  12393. #region 参数校验
  12394. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12395. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12396. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12397. #endregion
  12398. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12399. if (groupData.Code != 0)
  12400. {
  12401. return Ok(JsonView(false, groupData.Msg));
  12402. }
  12403. //自动审核
  12404. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12405. #region 应用推送
  12406. try
  12407. {
  12408. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12409. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12410. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12411. //2024-10-21 新增LZ UID
  12412. var userIds = new List<int>() { 21 };
  12413. string title = $"系统通知";
  12414. var diId = dto.DiId;
  12415. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12416. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12417. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12418. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12419. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12420. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12421. }
  12422. catch (Exception ex)
  12423. {
  12424. }
  12425. #endregion
  12426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12427. }
  12428. catch (Exception ex)
  12429. {
  12430. return Ok(JsonView(false, ex.Message));
  12431. }
  12432. }
  12433. /// <summary>
  12434. /// 获取三公详细所有城市
  12435. /// </summary>
  12436. /// <returns></returns>
  12437. [HttpGet]
  12438. public IActionResult OpCarCityResult()
  12439. {
  12440. var jw = JsonView(false);
  12441. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12442. {
  12443. x.Id,
  12444. x.Country,
  12445. x.City,
  12446. }).ToList();
  12447. if (data.Count > 0)
  12448. {
  12449. jw = JsonView(true, "获取成功!", data);
  12450. }
  12451. else
  12452. {
  12453. jw.Msg = "城市数据为空!";
  12454. jw.Data = new string[0];
  12455. }
  12456. return Ok(jw);
  12457. }
  12458. /// <summary>
  12459. /// 导出地接费用明细
  12460. /// </summary>
  12461. /// <param name="dto"></param>
  12462. /// <returns></returns>
  12463. [HttpPost]
  12464. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12465. {
  12466. var jw = JsonView(false);
  12467. if (dto.Diid < 1)
  12468. {
  12469. jw.Msg = "请输入正确的diid!";
  12470. return Ok(jw);
  12471. }
  12472. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12473. if (group == null)
  12474. {
  12475. jw.Msg = "未找到团组信息!";
  12476. return Ok(jw);
  12477. }
  12478. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12479. if (localGuideArr.Count == 0)
  12480. {
  12481. jw.Msg = "该团组暂无地接信息!";
  12482. return Ok(jw);
  12483. }
  12484. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12485. var overspendSoure = new Dictionary<int, int>
  12486. {
  12487. { 91, 982 }, //车
  12488. { 92 , 1059} ,//导游
  12489. { 994 , 1073}, //翻译
  12490. { 988 , 1074 }, //早餐
  12491. { 93 , 1075 }, //午餐
  12492. { 989 , 1076 }, //晚餐
  12493. };
  12494. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12495. foreach (var groupArr in localGroup)
  12496. {
  12497. var keyValue = groupArr.Key;
  12498. if (int.TryParse(keyValue, out int cityid))
  12499. {
  12500. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12501. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12502. }
  12503. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12504. foreach (var item in groupArr)
  12505. {
  12506. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12507. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12508. new Grp_CarTouristGuideGroundReservationsContentExtend
  12509. {
  12510. Count = a.Count,
  12511. CreateTime = a.CreateTime,
  12512. CreateUserId = a.CreateUserId,
  12513. CTGGRId = a.CTGGRId,
  12514. Currency = a.Currency,
  12515. DatePrice = a.DatePrice,
  12516. DeleteTime = a.DeleteTime,
  12517. DeleteUserId = a.DeleteUserId,
  12518. DiId = a.DiId,
  12519. Id = a.Id,
  12520. IsDel = a.IsDel,
  12521. Price = a.Price,
  12522. PriceContent = a.PriceContent,
  12523. Remark = a.Remark,
  12524. SId = a.SId,
  12525. SidName = b.Name,
  12526. Units = a.Units,
  12527. }
  12528. ).ToList();
  12529. if (content.Count > 0)
  12530. {
  12531. contentArr.Add(content);
  12532. }
  12533. }
  12534. //open excel
  12535. //set excel
  12536. //save excel
  12537. try
  12538. {
  12539. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12540. IWorkbook workbook;
  12541. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12542. {
  12543. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12544. }
  12545. else
  12546. {
  12547. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12548. }
  12549. ISheet sheet = workbook.GetSheetAt(0);
  12550. var rowStartIndex = 2;
  12551. var clounmCount = 10;
  12552. var initStyleRow = sheet.GetRow(2);
  12553. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12554. //var overspendArrDetail =
  12555. var existsId = new List<CarCompare>();
  12556. var lastElem = arr.Last();
  12557. var thisSid = -1;
  12558. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12559. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12560. {
  12561. Name = "未知币种!",
  12562. Remark = "未知币种!",
  12563. };
  12564. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12565. Action cloneRowFn = () =>
  12566. {
  12567. rowStartIndex++;
  12568. var cloneRow = sheet.CreateRow(rowStartIndex);
  12569. // 复制样式
  12570. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12571. {
  12572. ICell sourceCell = initStyleRow.GetCell(i);
  12573. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12574. // 确保单元格存在样式
  12575. if (sourceCell.CellStyle != null)
  12576. {
  12577. targetCell.CellStyle = sourceCell.CellStyle;
  12578. }
  12579. }
  12580. };
  12581. var mergeRow = () =>
  12582. {
  12583. for (int i = 2; i < sheet.LastRowNum; i++)
  12584. {
  12585. var row = sheet.GetRow(i);
  12586. var cellFirst = row.GetCell(0);
  12587. var thisIndex = i + 1;
  12588. while (thisIndex < sheet.LastRowNum)
  12589. {
  12590. var nextRow = sheet.GetRow(thisIndex);
  12591. var nextCellFirst = nextRow.GetCell(0);
  12592. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12593. {
  12594. thisIndex++;
  12595. }
  12596. else
  12597. {
  12598. break;
  12599. }
  12600. }
  12601. thisIndex--;
  12602. if (thisIndex != i)
  12603. {
  12604. //合并row
  12605. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12606. i, // 起始行索引(0-based)
  12607. thisIndex, // 结束行索引(0-based)
  12608. 0, // 起始列索引(0-based)
  12609. 0 // 结束列索引(0-based)
  12610. );
  12611. sheet.AddMergedRegion(cellRangeAddress);
  12612. i = thisIndex;
  12613. }
  12614. }
  12615. };
  12616. var chaoshiNumber = 0;
  12617. var totalNumber = 0.00M;
  12618. string lastStr = "";
  12619. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12620. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12621. {
  12622. b.IsAuditGM,
  12623. x.Id,
  12624. x.Area,
  12625. b.PayPercentage,
  12626. b.PayMoney,
  12627. }).ToList();
  12628. string yesPayment = "", noPayment = "";
  12629. foreach (var item in queryCarArrByCityAndDiid)
  12630. {
  12631. if (item.IsAuditGM == 1)
  12632. {
  12633. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12634. }
  12635. else
  12636. {
  12637. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12638. }
  12639. }
  12640. lastStr = yesPayment + noPayment;
  12641. foreach (var item in arr)
  12642. {
  12643. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12644. {
  12645. if (thisSid != item.SId)
  12646. {
  12647. if (thisSid == -1)
  12648. {
  12649. thisSid = item.SId;
  12650. }
  12651. else
  12652. {
  12653. //合并小计行
  12654. //创建合并区域的实例
  12655. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12656. rowStartIndex, // 起始行索引(0-based)
  12657. rowStartIndex, // 结束行索引(0-based)
  12658. 0, // 起始列索引(0-based)
  12659. 3 // 结束列索引(0-based)
  12660. );
  12661. sheet.AddMergedRegion(cellRangeAddress);
  12662. var CellStyle = workbook.CreateCellStyle();
  12663. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12664. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12665. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12666. for (int i = 0; i <= clounmCount; i++)
  12667. {
  12668. if (i > 6)
  12669. {
  12670. var CellStyle1 = workbook.CreateCellStyle();
  12671. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12672. IFont Font = workbook.CreateFont(); // 创建字体
  12673. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12674. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12675. CellStyle1.SetFont(Font);
  12676. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12677. }
  12678. else
  12679. {
  12680. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12681. }
  12682. }
  12683. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12684. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12685. //超时合计
  12686. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12687. //超时数
  12688. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12689. //超时合计费用
  12690. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12691. thisSid = item.SId;
  12692. cloneRowFn();
  12693. chaoshiNumber = 0;
  12694. totalNumber = 0;
  12695. }
  12696. }
  12697. IRow row = sheet.GetRow(rowStartIndex);
  12698. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12699. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12700. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12701. if (isOpenOverspendSoure)
  12702. {
  12703. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12704. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12705. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12706. }
  12707. for (int i = 0; i <= clounmCount; i++)
  12708. {
  12709. var cell = row.GetCell(i);
  12710. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12711. if (cell == null)
  12712. {
  12713. cell = row.CreateCell(i);
  12714. }
  12715. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12716. fontRed.CloneStyleFrom(cell.CellStyle);
  12717. IFont Font = workbook.CreateFont(); // 创建字体
  12718. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12719. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12720. fontRed.SetFont(Font);
  12721. byte[] rgb = new byte[3] { 255, 242, 204 };
  12722. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12723. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12724. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12725. if (workbook is XSSFWorkbook)
  12726. {
  12727. BackgroundColor255_242_204.FillForegroundColor = 0;
  12728. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12729. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12730. }
  12731. else
  12732. {
  12733. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12734. }
  12735. if (i == 1 || i > 6)
  12736. {
  12737. if (i > 6)
  12738. {
  12739. fontRed.FillForegroundColor = 0;
  12740. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12741. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12742. }
  12743. cell.CellStyle = fontRed;
  12744. }
  12745. if (i > 2 && i < 7)
  12746. {
  12747. cell.CellStyle = BackgroundColor255_242_204;
  12748. }
  12749. cell.SetCellValue(setCellValue); //写入单元格
  12750. }
  12751. if (overspendSoure.ContainsKey(thisSid))
  12752. {
  12753. var overspendId = overspendSoure[thisSid];
  12754. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12755. }
  12756. cloneRowFn();
  12757. existsId.Add(new CarCompare
  12758. {
  12759. DataPrice = item.DatePrice.ObjToDate(),
  12760. Sid = item.SId
  12761. });
  12762. }
  12763. if (item.Equals(lastElem))
  12764. {
  12765. //合并小计行
  12766. //创建合并区域的实例
  12767. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12768. rowStartIndex, // 起始行索引(0-based)
  12769. rowStartIndex, // 结束行索引(0-based)
  12770. 0, // 起始列索引(0-based)
  12771. 3 // 结束列索引(0-based)
  12772. );
  12773. sheet.AddMergedRegion(cellRangeAddress);
  12774. var CellStyle = workbook.CreateCellStyle();
  12775. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12776. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12777. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12778. for (int i = 0; i <= clounmCount; i++)
  12779. {
  12780. if (i > 6)
  12781. {
  12782. var CellStyle1 = workbook.CreateCellStyle();
  12783. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12784. IFont Font = workbook.CreateFont(); // 创建字体
  12785. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12786. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12787. CellStyle1.SetFont(Font);
  12788. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12789. }
  12790. else
  12791. {
  12792. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12793. }
  12794. }
  12795. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12796. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12797. //超时合计
  12798. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12799. //超时数
  12800. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12801. //超时合计费用
  12802. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12803. cloneRowFn();
  12804. // 创建合并区域的实例
  12805. cellRangeAddress = new CellRangeAddress(
  12806. rowStartIndex, // 起始行索引(0-based)
  12807. rowStartIndex, // 结束行索引(0-based)
  12808. 0, // 起始列索引(0-based)
  12809. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12810. );
  12811. // 添加合并区域
  12812. sheet.AddMergedRegion(cellRangeAddress);
  12813. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12814. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12815. }
  12816. }
  12817. mergeRow();
  12818. // 保存修改后的Excel文件到新文件
  12819. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12820. // new FileStream(newFilePath, FileMode.CreateNew)
  12821. using (var stream = new MemoryStream())
  12822. {
  12823. workbook.Write(stream, true);
  12824. stream.Flush();
  12825. stream.Seek(0, SeekOrigin.Begin);
  12826. MemoryStream memoryStream = new MemoryStream();
  12827. stream.CopyTo(memoryStream);
  12828. memoryStream.Seek(0, SeekOrigin.Begin);
  12829. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12830. }
  12831. workbook.Close();
  12832. workbook.Dispose();
  12833. }
  12834. catch (Exception ex)
  12835. {
  12836. jw.Msg = "出现异常!" + ex.Message;
  12837. return Ok(jw);
  12838. }
  12839. }
  12840. if (Zips.Count > 0)
  12841. {
  12842. IOOperatorHelper io = new IOOperatorHelper();
  12843. var byts = io.ConvertZipStream(Zips);
  12844. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12845. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12846. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12847. }
  12848. else
  12849. {
  12850. jw.Msg = "暂无生成文件!";
  12851. }
  12852. return Ok(jw);
  12853. }
  12854. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12855. {
  12856. string outStr = string.Empty;
  12857. switch (i)
  12858. {
  12859. case 0:
  12860. outStr = arr[0].SidName;
  12861. break;
  12862. case 1:
  12863. outStr = arr[0].DataPriceStr;
  12864. break;
  12865. case 2:
  12866. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  12867. break;
  12868. case 4:
  12869. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  12870. break;
  12871. case 7:
  12872. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12873. {
  12874. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  12875. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  12876. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  12877. }
  12878. break;
  12879. case 8:
  12880. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12881. {
  12882. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12883. }
  12884. break;
  12885. case 9:
  12886. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12887. {
  12888. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12889. }
  12890. break;
  12891. case 10:
  12892. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12893. {
  12894. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12895. }
  12896. break;
  12897. }
  12898. return outStr;
  12899. }
  12900. #region OP行程单
  12901. /// <summary>
  12902. /// OP行程单初始化
  12903. /// </summary>
  12904. /// <param name="dto"></param>
  12905. /// <returns></returns>
  12906. [HttpPost]
  12907. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12908. {
  12909. var jw = JsonView(false);
  12910. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12911. var group = groupList.First();
  12912. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12913. if (group == null)
  12914. {
  12915. jw.Msg = "暂无团组!";
  12916. return Ok(jw);
  12917. }
  12918. group = groupList.Find(x => x.Id == diid);
  12919. if (group == null)
  12920. {
  12921. jw.Msg = "请输入正确的团组ID!";
  12922. return Ok(jw);
  12923. }
  12924. string city = string.Empty;
  12925. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12926. if (blackCode.Count > 0)
  12927. {
  12928. var black = blackCode.First();
  12929. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12930. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12931. if (blackSp.Length > 0)
  12932. {
  12933. try
  12934. {
  12935. var cityArrCode = new List<string>(20);
  12936. foreach (var item in blackSp)
  12937. {
  12938. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12939. var IndexSelect = itemSp[2];
  12940. var cityArrCodeLength = cityArrCode.Count - 1;
  12941. var startCity = IndexSelect.Substring(0, 3);
  12942. if (cityArrCodeLength > 0)
  12943. {
  12944. var arrEndCity = cityArrCode[cityArrCodeLength];
  12945. if (arrEndCity != startCity)
  12946. {
  12947. cityArrCode.Add(startCity.ToUpper());
  12948. }
  12949. }
  12950. else
  12951. {
  12952. cityArrCode.Add(startCity.ToUpper());
  12953. }
  12954. var endCity = IndexSelect.Substring(3, 3);
  12955. cityArrCode.Add(endCity.ToUpper());
  12956. }
  12957. var cityThree = string.Empty;
  12958. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12959. cityThree = cityThree.TrimEnd(',');
  12960. if (string.IsNullOrWhiteSpace(cityThree))
  12961. {
  12962. throw new
  12963. Exception("error");
  12964. }
  12965. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12966. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12967. foreach (var item in cityArrCode)
  12968. {
  12969. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12970. if (find != null)
  12971. {
  12972. city += find.City + "/";
  12973. }
  12974. else
  12975. {
  12976. city += item + "三字码未收入/";
  12977. }
  12978. }
  12979. city = city.TrimEnd('/');
  12980. }
  12981. catch (Exception e)
  12982. {
  12983. city = "黑屏代码格式不正确!";
  12984. }
  12985. }
  12986. }
  12987. else
  12988. {
  12989. city = "未录入黑屏代码";
  12990. }
  12991. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12992. {
  12993. Date = x.Date,
  12994. Days = x.Days,
  12995. Diffgroup = x.Diffgroup,
  12996. Diid = x.Diid,
  12997. Traffic_First = x.Traffic_First,
  12998. Traffic_Second = x.Traffic_Second,
  12999. Trip = x.Trip,
  13000. WeekDay = x.WeekDay,
  13001. Id = x.Id
  13002. }).ToList();
  13003. jw.Data = new
  13004. {
  13005. groupList = groupList.Select(x => new
  13006. {
  13007. x.Id,
  13008. x.TeamName,
  13009. x.TourCode
  13010. }).ToList(),
  13011. groupInfo = new
  13012. {
  13013. group.VisitDays,
  13014. group.TourCode,
  13015. group.VisitPNumber,
  13016. group.TeamName,
  13017. city
  13018. },
  13019. OpTravelList
  13020. };
  13021. jw.Code = 200;
  13022. jw.Msg = "操作成功!";
  13023. return Ok(jw);
  13024. }
  13025. /// <summary>
  13026. /// 删除团组行程单
  13027. /// </summary>
  13028. /// <returns></returns>
  13029. [HttpPost]
  13030. public IActionResult DelTravel(DelOpTravelDto dto)
  13031. {
  13032. var jw = JsonView(false);
  13033. if (dto.UserId <= 0 || dto.Diid <= 0)
  13034. {
  13035. jw.Msg = "请输入正确的参数!";
  13036. return Ok(jw);
  13037. }
  13038. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13039. .SetColumns(x => new Grp_TravelList
  13040. {
  13041. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13042. DeleteUserId = dto.UserId,
  13043. IsDel = 1,
  13044. }).ExecuteCommand();
  13045. jw = JsonView(true);
  13046. return Ok(jw);
  13047. }
  13048. /// <summary>
  13049. /// 行程单保存
  13050. /// </summary>
  13051. /// <returns></returns>
  13052. [HttpPost]
  13053. public IActionResult TravelSave(TravelSaveDto dto)
  13054. {
  13055. var jw = JsonView(false);
  13056. if (dto.Arr.Count > 0)
  13057. {
  13058. try
  13059. {
  13060. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13061. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13062. .ToList();
  13063. _sqlSugar.BeginTran();
  13064. foreach (var item in dto.Arr)
  13065. {
  13066. if (item.Id == 0)
  13067. {
  13068. throw new Exception("请传入正确的Id");
  13069. }
  13070. //比较上一次的差异
  13071. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13072. if (findTravel != null)
  13073. {
  13074. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13075. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13076. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13077. }
  13078. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13079. .SetColumns(x => new Grp_TravelList
  13080. {
  13081. Trip = item.Trip
  13082. }).ExecuteCommand();
  13083. }
  13084. _sqlSugar.CommitTran();
  13085. jw = JsonView(true);
  13086. }
  13087. catch (Exception ex)
  13088. {
  13089. _sqlSugar.RollbackTran();
  13090. jw.Msg = "程序异常!" + ex.Message;
  13091. }
  13092. }
  13093. else
  13094. {
  13095. jw.Msg = "请传入正确的参数!";
  13096. }
  13097. return Ok(jw);
  13098. }
  13099. private string CheckStr(string original, string changed)
  13100. {
  13101. // 创建diff_match_patch对象
  13102. var dmp = new diff_match_patch();
  13103. // 计算差异
  13104. List<Diff> diffs = dmp.diff_main(original, changed);
  13105. // 清理和合并差异
  13106. dmp.diff_cleanupSemantic(diffs);
  13107. // 使用StringBuilder构建最终的字符串
  13108. StringBuilder finalString = new StringBuilder();
  13109. // 输出差异结果,并构建变动后的字符串
  13110. foreach (Diff diff in diffs)
  13111. {
  13112. switch (diff.operation)
  13113. {
  13114. case Operation.EQUAL:
  13115. // 相等的部分,直接添加到最终字符串
  13116. finalString.Append(diff.text);
  13117. break;
  13118. case Operation.INSERT:
  13119. // 插入的部分,添加标记并添加到最终字符串
  13120. finalString.Append("[++]" + diff.text + "[++]");
  13121. break;
  13122. case Operation.DELETE:
  13123. // 删除的部分,不添加到最终字符串
  13124. //finalString.Append("[++]" + diff.text + "[++]");
  13125. break;
  13126. }
  13127. }
  13128. // 输出变动后的字符串
  13129. return finalString.ToString();
  13130. }
  13131. private class tagContent
  13132. {
  13133. public DateTime Date { get; set; }
  13134. public string StartTag { get; set; }
  13135. public string EndTag { get; set; }
  13136. public string Content { get; set; }
  13137. public static int tagLength { get { return 3; } }
  13138. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13139. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13140. public bool IsFinally { get; set; }
  13141. }
  13142. private List<string> ExtractContentBetweenTags(string input, string tag)
  13143. {
  13144. List<string> results = new List<string>();
  13145. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13146. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13147. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13148. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13149. string[] strValueArr = new string[1];
  13150. foreach (System.Text.RegularExpressions.Match match in matches)
  13151. {
  13152. var strValue = match.Groups[1].Value;
  13153. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13154. }
  13155. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13156. return results;
  13157. }
  13158. /// <summary>
  13159. /// 导出行程单
  13160. /// </summary>
  13161. /// <param name="dto"></param>
  13162. /// <returns></returns>
  13163. [HttpPost]
  13164. public IActionResult ExportTravel(ExportTravelDto dto)
  13165. {
  13166. var jw = JsonView(false);
  13167. jw.Data = "";
  13168. int diid = 0;
  13169. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13170. if (Find == null)
  13171. {
  13172. jw.Msg = "请选择正确的团组!";
  13173. return Ok(jw);
  13174. }
  13175. else
  13176. {
  13177. diid = Find.Id;
  13178. }
  13179. //数据源
  13180. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13181. DataTable dtBlack = null;
  13182. try
  13183. {
  13184. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13185. }
  13186. catch (Exception)
  13187. {
  13188. jw.Msg = "机票黑屏代码有误!";
  13189. return Ok(jw);
  13190. }
  13191. string CityStr = string.Empty;
  13192. if (dtBlack.Rows.Count == 0)
  13193. {
  13194. jw.Msg = "机票黑屏代码有误!";
  13195. return Ok(jw);
  13196. }
  13197. else
  13198. {
  13199. foreach (DataRow row in dtBlack.Rows)
  13200. {
  13201. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13202. {
  13203. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13204. return Ok(jw);
  13205. }
  13206. }
  13207. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13208. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13209. }
  13210. // 指定的文字
  13211. var targetTextDic = new Dictionary<string, List<string>>();
  13212. //创建数据源Table
  13213. DataTable dtSource = new DataTable();
  13214. dtSource.Columns.Add("Days", typeof(string));
  13215. dtSource.Columns.Add("Date", typeof(string));
  13216. dtSource.Columns.Add("Week", typeof(string));
  13217. dtSource.Columns.Add("Traffic", typeof(string));
  13218. dtSource.Columns.Add("Trip", typeof(string));
  13219. //获取数据,放到datatable
  13220. foreach (var item in _travelList)
  13221. {
  13222. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13223. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13224. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13225. .Replace("[++]", string.Empty);
  13226. DataRow dr = dtSource.NewRow();
  13227. dr["Days"] = item.Days;
  13228. dr["Date"] = item.Date;
  13229. dr["Week"] = item.WeekDay;
  13230. dr["Traffic"] = item.Traffic_First
  13231. + "\r\n"
  13232. + item.Traffic_Second;
  13233. dr["Trip"] = item.Trip;
  13234. dtSource.Rows.Add(dr);
  13235. }
  13236. Dictionary<string, string> dic = new Dictionary<string, string>();
  13237. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13238. dic.Add("City", CityStr);
  13239. dic.Add("Days", Find.VisitDays.ToString());
  13240. dic.Add("DeleCode", Find.TourCode);
  13241. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13242. //模板路径
  13243. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13244. //载入模板
  13245. Document doc = null;
  13246. DocumentBuilder builder = null;
  13247. try
  13248. {
  13249. //载入模板
  13250. doc = new Document(tempPath);
  13251. builder = new DocumentBuilder(doc);
  13252. }
  13253. catch (Exception)
  13254. {
  13255. jw.Msg = "模板位置不存在!";
  13256. return Ok(jw);
  13257. }
  13258. foreach (var key in dic.Keys)
  13259. {
  13260. Bookmark bookmark = doc.Range.Bookmarks[key];
  13261. if (bookmark != null)
  13262. {
  13263. builder.MoveToBookmark(key);
  13264. builder.Write(dic[key]);
  13265. }
  13266. }
  13267. //获取word里所有表格
  13268. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13269. //获取所填表格的序数
  13270. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13271. try
  13272. {
  13273. //循环赋值
  13274. for (int i = 0; i < dtSource.Rows.Count; i++)
  13275. {
  13276. builder.MoveToCell(0, i + 1, 0, 0);
  13277. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13278. builder.MoveToCell(0, i + 1, 1, 0);
  13279. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13280. builder.MoveToCell(0, i + 1, 2, 0);
  13281. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13282. var trip = dtSource.Rows[i]["Trip"].ToString();
  13283. builder.MoveToCell(0, i + 1, 3, 0);
  13284. builder.Write(trip);
  13285. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13286. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13287. // 获取特定索引的段落
  13288. Paragraph paragraph = (Paragraph)paragraphs[0];
  13289. Run run = paragraph.Runs[0];
  13290. Aspose.Words.Font font = run.Font;
  13291. font.Name = "黑体";
  13292. //设置双休红色
  13293. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13294. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13295. paragraph = (Paragraph)paragraphs[1];
  13296. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13297. {
  13298. run = paragraph.Runs[0];
  13299. font = run.Font;
  13300. font.Color = Color.Red;
  13301. }
  13302. }
  13303. }
  13304. catch (Exception ex)
  13305. {
  13306. }
  13307. //删除多余行
  13308. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13309. {
  13310. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13311. }
  13312. var targetTextList = new List<string>();
  13313. // 遍历文档中的表格
  13314. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13315. {
  13316. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13317. {
  13318. var cellIndex = 0;
  13319. foreach (Cell cell in row.Cells)
  13320. {
  13321. if (cellIndex == 1 && row.Cells.Count == 4)
  13322. {
  13323. foreach (var target in targetTextDic.Keys)
  13324. {
  13325. if (cell.GetText().Contains(target))
  13326. {
  13327. targetTextList = targetTextDic[target];
  13328. break;
  13329. }
  13330. }
  13331. }
  13332. // 遍历单元格中的所有段落
  13333. foreach (Paragraph paragraph in cell.Paragraphs)
  13334. {
  13335. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13336. List<Run> runs = new List<Run>();
  13337. foreach (Run run in paragraph.Runs)
  13338. {
  13339. runs.Add(run);
  13340. }
  13341. foreach (Run run in runs)
  13342. {
  13343. foreach (var targetText in targetTextList)
  13344. {
  13345. // 检查文字是否包含指定文字
  13346. if (run.Text.Contains(targetText))
  13347. {
  13348. // 将包含的部分设置为红色
  13349. HighlightText(run, targetText, Color.Red);
  13350. }
  13351. }
  13352. }
  13353. }
  13354. cellIndex++;
  13355. }
  13356. }
  13357. }
  13358. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13359. if (!Directory.Exists(savePath))
  13360. {
  13361. try
  13362. {
  13363. Directory.CreateDirectory(savePath);
  13364. }
  13365. catch
  13366. {
  13367. }
  13368. }
  13369. string path = savePath + Find.TeamName + "出访日程";
  13370. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13371. try
  13372. {
  13373. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13374. string postfix = ".docx";
  13375. if (dto.IsPDF == 1)
  13376. {
  13377. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13378. postfix = ".pdf";
  13379. }
  13380. doc.Save(path + postfix, saveFormat);
  13381. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13382. }
  13383. catch (Exception)
  13384. {
  13385. jw = JsonView(false);
  13386. }
  13387. return Ok(jw);
  13388. }
  13389. /// <summary>
  13390. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13391. /// </summary>
  13392. /// <param name="num"></param>
  13393. /// <returns></returns>
  13394. string GetNum(string num)
  13395. {
  13396. string str = "";
  13397. switch (num)
  13398. {
  13399. case "1":
  13400. str = "一";
  13401. break;
  13402. case "2":
  13403. str = "二";
  13404. break;
  13405. case "3":
  13406. str = "三";
  13407. break;
  13408. case "4":
  13409. str = "四";
  13410. break;
  13411. case "5":
  13412. str = "五";
  13413. break;
  13414. case "6":
  13415. str = "六";
  13416. break;
  13417. case "7":
  13418. str = "七";
  13419. break;
  13420. case "8":
  13421. str = "八";
  13422. break;
  13423. case "9":
  13424. str = "九";
  13425. break;
  13426. case "10":
  13427. str = "十";
  13428. break;
  13429. case "11":
  13430. str = "十一";
  13431. break;
  13432. case "12":
  13433. str = "十二";
  13434. break;
  13435. case "一":
  13436. str = "1";
  13437. break;
  13438. case "二":
  13439. str = "2";
  13440. break;
  13441. case "三":
  13442. str = "3";
  13443. break;
  13444. case "四":
  13445. str = "4";
  13446. break;
  13447. case "五":
  13448. str = "5";
  13449. break;
  13450. case "六":
  13451. str = "6";
  13452. break;
  13453. case "七":
  13454. str = "7";
  13455. break;
  13456. case "八":
  13457. str = "8";
  13458. break;
  13459. case "九":
  13460. str = "9";
  13461. break;
  13462. case "十":
  13463. str = "10";
  13464. break;
  13465. case "十一":
  13466. str = "11";
  13467. break;
  13468. case "十二":
  13469. str = "12";
  13470. break;
  13471. }
  13472. return str;
  13473. }
  13474. // 高亮包含指定文字的部分
  13475. void HighlightText(Run run, string targetText, Color color)
  13476. {
  13477. string text = run.Text;
  13478. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13479. if (startIndex >= 0)
  13480. {
  13481. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13482. // 前部分
  13483. if (startIndex > 0)
  13484. {
  13485. Run beforeRun = (Run)run.Clone(true);
  13486. beforeRun.Text = text.Substring(0, startIndex);
  13487. parentParagraph.InsertBefore(beforeRun, run);
  13488. }
  13489. // 匹配部分
  13490. Run matchRun = (Run)run.Clone(true);
  13491. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13492. matchRun.Font.Color = color;
  13493. parentParagraph.InsertBefore(matchRun, run);
  13494. // 后部分
  13495. if (startIndex + targetText.Length < text.Length)
  13496. {
  13497. Run afterRun = (Run)run.Clone(true);
  13498. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13499. parentParagraph.InsertBefore(afterRun, run);
  13500. }
  13501. // 删除原始Run
  13502. run.Remove();
  13503. }
  13504. }
  13505. #endregion
  13506. #endregion
  13507. #region 团组成本
  13508. /// <summary>
  13509. /// 团组成本数据初始化
  13510. /// </summary>
  13511. /// <param name="dto"></param>
  13512. /// <returns></returns>
  13513. [HttpPost]
  13514. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13515. {
  13516. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13517. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13518. WHEN COUNT(*) >= 0 THEN 'True'
  13519. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13520. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13521. ").ToList(); //团组列表
  13522. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13523. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13524. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13525. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13526. if (groupinfoValue != null)
  13527. {
  13528. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13529. var spArr = new string[1] { countryArr };
  13530. if (countryArr.Contains("|"))
  13531. {
  13532. spArr = countryArr.Split("|");
  13533. }
  13534. else if (countryArr.Contains("、"))
  13535. {
  13536. spArr = countryArr.Split("、");
  13537. }
  13538. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13539. {
  13540. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13541. if (dbQueryCountry != null)
  13542. {
  13543. visaCountryInfoArr.Add(dbQueryCountry);
  13544. }
  13545. }
  13546. }
  13547. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13548. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13549. #region 屏蔽黑屏代码生成
  13550. //var create = _GroupCostRepository.
  13551. // CreateGroupCostByBlackCode(dto.Diid);
  13552. //if (groupCost.Count == 0 && create.Code == 0)
  13553. //{
  13554. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13555. //}
  13556. #endregion
  13557. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13558. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13559. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13560. groupCostMap = groupCostMap.Select(x =>
  13561. {
  13562. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13563. {
  13564. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13565. }
  13566. return x;
  13567. }).ToList();
  13568. //GroupCostParameter.Add(new
  13569. // Grp_GroupCostParameter());
  13570. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13571. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13572. return Ok(JsonView(new
  13573. {
  13574. groupList,
  13575. groupInfo,
  13576. groupChecks,
  13577. groupCost = groupCostMap,
  13578. hotelNumber,
  13579. GroupCostParameter = GroupCostParameterMap,
  13580. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13581. {
  13582. x.VisaCountry,
  13583. x.VisaPrice,
  13584. x.Id,
  13585. }).ToList(),
  13586. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13587. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13588. hotelIsTrue = hotelIsTrue,
  13589. }));
  13590. }
  13591. /// <summary>
  13592. /// 团组成本信息保存
  13593. /// </summary>
  13594. /// <param name="dto"></param>
  13595. /// <returns></returns>
  13596. [HttpPost]
  13597. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13598. {
  13599. if (dto.Diid <= 0 || dto.Userid <= 0)
  13600. {
  13601. return Ok(JsonView(false));
  13602. }
  13603. JsonView jw = null;
  13604. bool isTrue = false;
  13605. #region 复制团组成本
  13606. //if (dto.Diid == 2581)
  13607. //{
  13608. // dto.Diid = 2599;
  13609. // dto.CheckBoxs.ForEach(x =>
  13610. // {
  13611. // x.Diid = 2599;
  13612. // });
  13613. // dto.GroupCosts.ForEach(x =>
  13614. // {
  13615. // x.Diid = 2599;
  13616. // });
  13617. // dto.CostTypeHotelNumbers.ForEach(x =>
  13618. // {
  13619. // x.Diid = 2599;
  13620. // });
  13621. // dto.GroupCostParameters.ForEach(x =>
  13622. // {
  13623. // x.DiId = 2599;
  13624. // });
  13625. //}
  13626. #endregion
  13627. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13628. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13629. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13630. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13631. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13632. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13633. try
  13634. {
  13635. _sqlSugar.BeginTran();
  13636. isTrue = await _GroupCostRepository.
  13637. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13638. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13639. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13640. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13641. _sqlSugar.CommitTran();
  13642. jw = JsonView(true, "保存成功!", isTrue);
  13643. }
  13644. catch (Exception)
  13645. {
  13646. _sqlSugar.RollbackTran();
  13647. jw = JsonView(false);
  13648. }
  13649. return Ok(jw);
  13650. }
  13651. /// <summary>
  13652. /// 司兼导数据
  13653. /// </summary>
  13654. /// <param name="dto"></param>
  13655. /// <returns></returns>
  13656. [HttpPost]
  13657. public IActionResult GetCarGuides(CarGuidesDto dto)
  13658. {
  13659. JsonView jw = null;
  13660. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13661. jw = JsonView(true, "获取成功!", Data);
  13662. return Ok(jw);
  13663. }
  13664. /// <summary>
  13665. /// 导游数据
  13666. /// </summary>
  13667. /// <param name="dto"></param>
  13668. /// <returns></returns>
  13669. [HttpPost]
  13670. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13671. {
  13672. JsonView jw = null;
  13673. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13674. // 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
  13675. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13676. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13677. jw = JsonView(true, "获取成功!", Data);
  13678. return Ok(jw);
  13679. }
  13680. /// <summary>
  13681. /// 成本车数据
  13682. /// </summary>
  13683. /// <param name="dto"></param>
  13684. /// <returns></returns>
  13685. [HttpPost]
  13686. public IActionResult GetCarInfo(CarGuidesDto dto)
  13687. {
  13688. JsonView jw = null;
  13689. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13690. jw = JsonView(true, "获取成功!", Data);
  13691. return Ok(jw);
  13692. }
  13693. /// <summary>
  13694. /// 景点数据
  13695. /// </summary>
  13696. /// <param name="dto"></param>
  13697. /// <returns></returns>
  13698. [HttpPost]
  13699. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13700. {
  13701. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13702. return Ok(JsonView(true, "获取成功!", Data));
  13703. }
  13704. /// <summary>
  13705. /// 成本通知
  13706. /// </summary>
  13707. /// <param name="dto"></param>
  13708. /// <returns></returns>
  13709. [HttpPost]
  13710. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13711. {
  13712. if (dto.Diid < 0)
  13713. {
  13714. return Ok(JsonView(false));
  13715. }
  13716. JsonView jw = null;
  13717. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13718. if (GroupCostParameter != null)
  13719. {
  13720. int IsShare = 0;
  13721. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13722. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13723. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13724. string msg = string.Empty;
  13725. if (isTrue)
  13726. {
  13727. if (IsShare == 0)
  13728. {
  13729. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13730. }
  13731. else
  13732. {
  13733. #region 企微通知对应岗位用户
  13734. try
  13735. {
  13736. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13737. }
  13738. catch (Exception ex)
  13739. {
  13740. }
  13741. #endregion
  13742. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13743. }
  13744. jw = JsonView(isTrue, msg, new { IsShare });
  13745. }
  13746. else
  13747. {
  13748. msg = "修改失败!";
  13749. jw = JsonView(isTrue, msg);
  13750. }
  13751. }
  13752. else
  13753. {
  13754. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13755. }
  13756. return Ok(jw);
  13757. }
  13758. /// <summary>
  13759. /// 导出报价单
  13760. /// </summary>
  13761. /// <param name="dto"></param>
  13762. /// <returns></returns>
  13763. [HttpPost]
  13764. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13765. {
  13766. if (dto.Diid == 0)
  13767. {
  13768. return Ok(JsonView(false, "请传递团组id"));
  13769. }
  13770. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13771. if (deleInfo.Code != 0)
  13772. {
  13773. return Ok(JsonView(false, "团组信息查询失败!"));
  13774. }
  13775. var di = deleInfo.Data as DelegationInfoWebView;
  13776. if (di != null)
  13777. {
  13778. di.TeamName = di.TeamName.Replace("|", "、");
  13779. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13780. //文件名
  13781. string strFileName = di.TeamName + "-收款账单.doc";
  13782. //获取模板
  13783. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13784. //载入模板
  13785. Document doc = new Document(tmppath);
  13786. decimal TotalPrice = 0.00M;
  13787. string itemStr = string.Empty;
  13788. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13789. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13790. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13791. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13792. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13793. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13794. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13795. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13796. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13797. foreach (var cost in groupCostType)
  13798. {
  13799. var List = cost.ToList();
  13800. if (cost.Key == "A")
  13801. {
  13802. foreach (var ListItem in List)
  13803. {
  13804. if (ListItem.number > 0)
  13805. {
  13806. if (ListItem.code.Contains("TBR"))
  13807. {
  13808. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13809. }
  13810. else
  13811. {
  13812. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13813. }
  13814. TotalPrice += (ListItem.number * ListItem.price);
  13815. }
  13816. }
  13817. }
  13818. else
  13819. {
  13820. itemStr = itemStr.Insert(0, "A段\r\n");
  13821. itemStr += "B段\r\n";
  13822. foreach (var ListItem in List)
  13823. {
  13824. if (ListItem.number > 0)
  13825. {
  13826. if (ListItem.code.Contains("TBR"))
  13827. {
  13828. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13829. }
  13830. else
  13831. {
  13832. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13833. }
  13834. TotalPrice += (ListItem.number * ListItem.price);
  13835. }
  13836. }
  13837. }
  13838. }
  13839. #region 替换Word模板书签内容
  13840. Dictionary<string, string> marks = new Dictionary<string, string>();
  13841. marks.Add("To", di.ClientUnit);//付款方
  13842. marks.Add("ToTel", di.TellPhone);//付款方电话
  13843. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13844. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13845. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13846. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13847. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13848. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13849. marks.Add("PayItemContent", itemStr);//详细信息
  13850. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13851. #endregion
  13852. ////注
  13853. //if (doc.Range.Bookmarks["Attention"] != null)
  13854. //{
  13855. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13856. // mark.Text = frList[0].Attention;
  13857. //}
  13858. foreach (var item in marks.Keys)
  13859. {
  13860. if (doc.Range.Bookmarks[item] != null)
  13861. {
  13862. Bookmark mark = doc.Range.Bookmarks[item];
  13863. mark.Text = marks[item];
  13864. }
  13865. }
  13866. byte[] bytes = null;
  13867. using (MemoryStream stream = new MemoryStream())
  13868. {
  13869. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13870. bytes = stream.ToArray();
  13871. }
  13872. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  13873. return Ok(JsonView(true, "", new
  13874. {
  13875. Data = bytes,
  13876. strFileName,
  13877. }));
  13878. }
  13879. else
  13880. {
  13881. return Ok(JsonView(false, "团组信息不存在!"));
  13882. }
  13883. }
  13884. /// <summary>
  13885. /// 导出团组成本
  13886. /// </summary>
  13887. /// <param name="dto"></param>
  13888. /// <returns></returns>
  13889. [HttpPost]
  13890. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13891. {
  13892. var jw = JsonView(false);
  13893. if (dto.Diid == 0)
  13894. {
  13895. return Ok(JsonView(false, "请传递团组id"));
  13896. }
  13897. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13898. if (deleInfo.Code != 0)
  13899. {
  13900. return Ok(JsonView(false, "团组信息查询失败!"));
  13901. }
  13902. var di = deleInfo.Data as DelegationInfoWebView;
  13903. if (di == null)
  13904. {
  13905. return Ok(JsonView(false, "团组信息查询失败!"));
  13906. }
  13907. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13908. WorkbookDesigner designer = new WorkbookDesigner();
  13909. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13910. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13911. for (int i = 0; i < List_GC.Count; i++)
  13912. {
  13913. GroupCost_Excel gc = new GroupCost_Excel();
  13914. gc.Id = List_GC[i].Id;
  13915. gc.Diid = List_GC[i].Diid.ToString();
  13916. gc.DAY = List_GC[i].DAY;
  13917. string week = "";
  13918. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13919. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13920. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13921. gc.ITIN = List_GC[i].ITIN;
  13922. gc.CarType = List_GC[i].CarType;
  13923. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13924. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13925. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13926. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13927. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13928. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13929. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13930. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13931. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13932. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13933. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13934. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13935. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13936. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13937. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13938. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13939. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13940. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13941. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13942. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13943. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13944. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13945. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13946. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13947. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13948. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13949. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13950. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13951. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13952. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13953. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13954. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13955. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13956. List_GC1.Add(gc);
  13957. }
  13958. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13959. dt.TableName = "TB";
  13960. //报表标题等不用dt的值
  13961. designer.SetDataSource("TeamName", dto.title.TeamName);
  13962. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13963. designer.SetDataSource("Tax", dto.title.Tax);
  13964. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13965. designer.SetDataSource("Currency", dto.title.Currency);
  13966. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13967. designer.SetDataSource("Rate", dto.title.Rate);
  13968. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13969. var Aparams = hotels.Find(x => x.Type == "Default");
  13970. if (Aparams == null)
  13971. {
  13972. return Ok(jw);
  13973. }
  13974. //酒店数量
  13975. var txtSGRNumber = Aparams.SGR.ToString();
  13976. var txtTBRNumber = Aparams.TBR.ToString();
  13977. var txtJSESNumber = Aparams.JSES.ToString();
  13978. var txtSUITENumbe = Aparams.SUITE.ToString();
  13979. if (dto.costType == "B")
  13980. {
  13981. Aparams = hotels.Find(x => x.Type == "A");
  13982. var Bparams = hotels.Find(x => x.Type == "B");
  13983. if (Aparams == null || Bparams == null)
  13984. {
  13985. return Ok(jw);
  13986. }
  13987. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13988. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13989. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13990. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13991. }
  13992. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13993. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13994. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13995. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13996. var ws = designer.Workbook.Worksheets[0];
  13997. int Row = List_GC.Count;
  13998. int startIndex = 11;
  13999. int HideRows = 0;
  14000. List<int> hideRowsList = new List<int>();
  14001. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14002. #region A段left数据
  14003. var left = dto.leftInfo.Find(x => x.Type == "A");
  14004. if (left == null)
  14005. {
  14006. return Ok(jw);
  14007. }
  14008. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14009. if (leftBindData != null)
  14010. {
  14011. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14012. designer.SetDataSource("VisaRS", leftBindData.rs);
  14013. designer.SetDataSource("VisaXS", leftBindData.xs);
  14014. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14015. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14016. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14017. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14018. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14019. }
  14020. else
  14021. {
  14022. hideRowsList.Add(Row + startIndex + HideRows);
  14023. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14024. }
  14025. HideRows += 2;
  14026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14027. if (leftBindData != null)
  14028. {
  14029. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14030. designer.SetDataSource("BXRS", leftBindData.rs);
  14031. designer.SetDataSource("BXXS", leftBindData.xs);
  14032. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14033. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14034. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14035. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14036. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14037. }
  14038. else
  14039. {
  14040. hideRowsList.Add(Row + startIndex + HideRows);
  14041. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14042. }
  14043. HideRows += 2;
  14044. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14045. if (leftBindData != null)
  14046. {
  14047. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14048. designer.SetDataSource("HSRS", leftBindData.rs);
  14049. designer.SetDataSource("HSXS", leftBindData.xs);
  14050. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14051. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14052. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14053. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14054. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14055. }
  14056. else
  14057. {
  14058. hideRowsList.Add(Row + startIndex + HideRows);
  14059. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14060. }
  14061. HideRows += 2;
  14062. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14063. if (leftBindData != null)
  14064. {
  14065. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14066. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14067. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14068. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14069. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14070. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14071. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14072. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14073. }
  14074. else
  14075. {
  14076. hideRowsList.Add(Row + startIndex + HideRows);
  14077. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14078. }
  14079. HideRows += 2;
  14080. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14081. if (leftBindData != null)
  14082. {
  14083. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14084. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14085. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14086. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14087. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14088. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14089. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14090. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14091. }
  14092. else
  14093. {
  14094. hideRowsList.Add(Row + startIndex + HideRows);
  14095. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14096. }
  14097. HideRows += 2;
  14098. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14099. if (leftBindData != null)
  14100. {
  14101. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14102. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14103. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14104. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14105. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14106. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14107. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14108. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14109. }
  14110. else
  14111. {
  14112. hideRowsList.Add(Row + startIndex + HideRows);
  14113. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14114. }
  14115. HideRows += 2;
  14116. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14117. if (leftBindData != null)
  14118. {
  14119. ////TBR
  14120. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14121. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14122. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14123. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14124. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14125. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14126. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14127. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14128. }
  14129. else
  14130. {
  14131. hideRowsList.Add(Row + startIndex + HideRows);
  14132. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14133. }
  14134. HideRows += 2;
  14135. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14136. if (leftBindData != null)
  14137. {
  14138. ////SGR
  14139. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14140. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14141. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14142. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14143. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14144. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14145. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14146. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14147. }
  14148. else
  14149. {
  14150. hideRowsList.Add(Row + startIndex + HideRows);
  14151. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14152. }
  14153. HideRows += 2;
  14154. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14155. if (leftBindData != null)
  14156. {
  14157. ////JS/ES
  14158. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14159. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14160. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14161. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14162. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14163. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14164. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14165. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14166. }
  14167. else
  14168. {
  14169. hideRowsList.Add(Row + startIndex + HideRows);
  14170. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14171. }
  14172. HideRows += 2;
  14173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14174. if (leftBindData != null)
  14175. {
  14176. ////SUITE
  14177. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14178. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14179. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14180. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14181. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14182. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14183. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14184. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14185. }
  14186. else
  14187. {
  14188. hideRowsList.Add(Row + startIndex + HideRows);
  14189. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14190. }
  14191. HideRows += 2;
  14192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14193. if (leftBindData != null)
  14194. {
  14195. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14196. designer.SetDataSource("DJRS", leftBindData.rs);
  14197. designer.SetDataSource("DJXS", leftBindData.xs);
  14198. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14199. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14200. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14201. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14202. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14203. }
  14204. else
  14205. {
  14206. hideRowsList.Add(Row + startIndex + HideRows);
  14207. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14208. }
  14209. HideRows += 2;
  14210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14211. if (leftBindData != null)
  14212. {
  14213. designer.SetDataSource("HCPCB", leftBindData.cb);
  14214. designer.SetDataSource("HCPRS", leftBindData.rs);
  14215. designer.SetDataSource("HCPXS", leftBindData.xs);
  14216. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14217. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14218. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14219. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14220. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14221. }
  14222. else
  14223. {
  14224. hideRowsList.Add(Row + startIndex + HideRows);
  14225. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14226. }
  14227. HideRows += 2;
  14228. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14229. if (leftBindData != null)
  14230. {
  14231. designer.SetDataSource("CPCB", leftBindData.cb);
  14232. designer.SetDataSource("CPRS", leftBindData.rs);
  14233. designer.SetDataSource("CPXS", leftBindData.xs);
  14234. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14235. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14236. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14237. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14238. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14239. }
  14240. else
  14241. {
  14242. hideRowsList.Add(Row + startIndex + HideRows);
  14243. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14244. }
  14245. HideRows += 2;
  14246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14247. if (leftBindData != null)
  14248. {
  14249. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14250. designer.SetDataSource("GWRS", leftBindData.rs);
  14251. designer.SetDataSource("GWXS", leftBindData.xs);
  14252. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14253. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14254. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14255. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14256. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14257. }
  14258. else
  14259. {
  14260. hideRowsList.Add(Row + startIndex + HideRows);
  14261. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14262. }
  14263. HideRows += 2;
  14264. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14265. if (leftBindData != null)
  14266. {
  14267. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14268. designer.SetDataSource("LYJRS", leftBindData.rs);
  14269. designer.SetDataSource("LYJXS", leftBindData.xs);
  14270. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14271. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14272. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14273. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14274. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14275. }
  14276. else
  14277. {
  14278. hideRowsList.Add(Row + startIndex + HideRows);
  14279. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14280. }
  14281. #endregion
  14282. #region A段Right信息
  14283. var right = dto.rightInfo.Find(x => x.Type == "A");
  14284. if (right == null)
  14285. {
  14286. return Ok(jw);
  14287. }
  14288. HideRows += 4;
  14289. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14290. if (rightBindData != null)
  14291. {
  14292. //经济舱 + 双人间 TBR
  14293. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14294. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14295. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14296. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14297. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14298. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14299. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14300. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14301. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14302. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14303. }
  14304. else
  14305. {
  14306. hideRowsList.Add(Row + startIndex + HideRows);
  14307. }
  14308. HideRows += 2;
  14309. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14310. if (rightBindData != null)
  14311. {
  14312. //经济舱 + 单人间 SGR
  14313. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14314. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14315. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14316. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14317. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14318. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14319. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14320. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14321. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14322. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14323. }
  14324. else
  14325. {
  14326. hideRowsList.Add(Row + startIndex + HideRows);
  14327. }
  14328. HideRows += 2;
  14329. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14330. if (rightBindData != null)
  14331. {
  14332. //公务舱 + 单人间 SGR
  14333. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14334. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14335. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14336. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14337. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14338. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14339. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14340. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14341. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14342. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14343. }
  14344. else
  14345. {
  14346. hideRowsList.Add(Row + startIndex + HideRows);
  14347. }
  14348. HideRows += 2;
  14349. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14350. if (rightBindData != null)
  14351. {
  14352. //公务舱 + 小套房 JSES
  14353. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14354. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14355. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14356. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14357. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14358. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14359. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14360. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14361. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14362. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14363. }
  14364. else
  14365. {
  14366. hideRowsList.Add(Row + startIndex + HideRows);
  14367. }
  14368. HideRows += 2;
  14369. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14370. if (rightBindData != null)
  14371. {
  14372. //公务舱 + 小套房 JSES
  14373. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14374. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14375. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14376. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14377. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14378. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14379. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14380. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14381. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14382. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14383. }
  14384. else
  14385. {
  14386. hideRowsList.Add(Row + startIndex + HideRows);
  14387. }
  14388. HideRows += 2;
  14389. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14390. if (rightBindData != null)
  14391. {
  14392. //经济舱 + 大套房
  14393. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14394. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14395. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14396. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14397. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14398. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14399. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14400. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14401. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14402. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14403. }
  14404. else
  14405. {
  14406. hideRowsList.Add(Row + startIndex + HideRows);
  14407. }
  14408. HideRows += 2;
  14409. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14410. if (rightBindData != null)
  14411. {
  14412. //头等舱 + 小套房 JSES
  14413. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14414. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14415. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14416. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14417. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14418. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14419. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14420. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14421. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14422. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14423. }
  14424. else
  14425. {
  14426. hideRowsList.Add(Row + startIndex + HideRows);
  14427. }
  14428. HideRows += 2;
  14429. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14430. if (rightBindData != null)
  14431. {
  14432. //头等舱 + 大套房
  14433. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14434. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14435. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14436. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14437. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14438. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14439. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14440. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14441. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14442. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14443. }
  14444. else
  14445. {
  14446. hideRowsList.Add(Row + startIndex + HideRows);
  14447. }
  14448. #endregion
  14449. #region B段标题清空
  14450. designer.SetDataSource("CostBDRCB", "");
  14451. designer.SetDataSource("CostBRS", "");
  14452. designer.SetDataSource("CostBXS", "");
  14453. designer.SetDataSource("CostBZCB", "");
  14454. designer.SetDataSource("CostBDRBJ", "");
  14455. designer.SetDataSource("CostBZBJ", "");
  14456. designer.SetDataSource("CostBDRLR", "");
  14457. designer.SetDataSource("CostBZLR", "");
  14458. designer.SetDataSource("CostBDRCBOM", "");
  14459. designer.SetDataSource("CostBRSOM", "");
  14460. designer.SetDataSource("CostBZCBOM", "");
  14461. designer.SetDataSource("CostBDRBJOM", "");
  14462. designer.SetDataSource("CostBZBJOM", "");
  14463. designer.SetDataSource("CostBDRLROM", "");
  14464. designer.SetDataSource("CostBZLROM", "");
  14465. #endregion
  14466. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14467. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14468. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14469. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14470. designer.SetDataSource("DJName", "地接(CNY)");
  14471. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14472. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14473. designer.SetDataSource("GWName", "公务(CNY)");
  14474. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14475. designer.SetDataSource("LYJName", "零用金(CNY)");
  14476. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14477. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14478. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14479. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14480. designer.SetDataSource("BXName", "保险(CNY)");
  14481. designer.SetDataSource("VisaName", "签证(CNY)");
  14482. #region B段基本数据
  14483. if (dto.costType == "B")
  14484. {
  14485. left = dto.leftInfo.Find(x => x.Type == "B");
  14486. if (left == null)
  14487. {
  14488. return Ok(jw);
  14489. }
  14490. #region B段left数据
  14491. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14492. if (leftBindData != null)
  14493. {
  14494. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14495. designer.SetDataSource("BHSRS", leftBindData.rs);
  14496. designer.SetDataSource("BHSXS", leftBindData.xs);
  14497. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14498. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14499. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14500. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14501. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14502. }
  14503. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14504. if (leftBindData != null)
  14505. {
  14506. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14507. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14508. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14509. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14510. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14511. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14512. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14513. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14514. }
  14515. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14516. if (leftBindData != null)
  14517. {
  14518. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14519. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14520. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14521. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14522. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14523. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14524. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14525. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14526. }
  14527. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14528. if (leftBindData != null)
  14529. {
  14530. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14531. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14532. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14533. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14534. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14535. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14536. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14537. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14538. }
  14539. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14540. if (leftBindData != null)
  14541. {
  14542. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14543. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14544. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14545. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14546. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14547. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14548. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14549. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14550. }
  14551. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14552. if (leftBindData != null)
  14553. {
  14554. designer.SetDataSource("BCPCB", leftBindData.cb);
  14555. designer.SetDataSource("BCPRS", leftBindData.rs);
  14556. designer.SetDataSource("BCPXS", leftBindData.xs);
  14557. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14558. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14559. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14560. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14561. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14562. }
  14563. //TBR
  14564. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14565. if (leftBindData != null)
  14566. {
  14567. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14568. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14569. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14570. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14571. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14572. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14573. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14574. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14575. }
  14576. //SGR
  14577. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14578. if (leftBindData != null)
  14579. {
  14580. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14581. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14582. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14583. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14584. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14585. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14586. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14587. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14588. }
  14589. //JS/ES
  14590. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14591. if (leftBindData != null)
  14592. {
  14593. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14594. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14595. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14596. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14597. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14598. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14599. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14600. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14601. }
  14602. //SUITE
  14603. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14604. if (leftBindData != null)
  14605. {
  14606. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14607. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14608. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14609. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14610. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14611. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14612. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14613. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14614. }
  14615. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14616. if (leftBindData != null)
  14617. {
  14618. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14619. designer.SetDataSource("BDJRS", leftBindData.rs);
  14620. designer.SetDataSource("BDJXS", leftBindData.xs);
  14621. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14622. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14623. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14624. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14625. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14626. }
  14627. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14628. if (leftBindData != null)
  14629. {
  14630. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14631. designer.SetDataSource("BGWRS", leftBindData.rs);
  14632. designer.SetDataSource("BGWXS", leftBindData.xs);
  14633. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14634. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14635. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14636. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14637. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14638. }
  14639. #region 优化方案
  14640. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14641. //excelBind.Add("零用金", new {
  14642. //cb="",
  14643. //rs="",
  14644. //xs ="",
  14645. //zcb = "",
  14646. //});
  14647. #endregion
  14648. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14649. if (leftBindData != null)
  14650. {
  14651. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14652. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14653. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14654. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14655. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14656. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14657. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14658. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14659. }
  14660. #endregion
  14661. #region B段Right信息
  14662. right = dto.rightInfo.Find(x => x.Type == "B");
  14663. if (right == null)
  14664. {
  14665. return Ok(jw);
  14666. }
  14667. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14668. if (rightBindData != null)
  14669. {
  14670. //经济舱 + 双人间 TBR
  14671. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14672. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14673. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14674. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14675. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14676. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14677. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14678. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14679. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14680. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14681. }
  14682. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14683. if (rightBindData != null)
  14684. {
  14685. //经济舱 + 单人间 SGR
  14686. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14687. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14688. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14689. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14690. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14691. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14692. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14693. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14694. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14695. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14696. }
  14697. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14698. if (rightBindData != null)
  14699. {
  14700. //公务舱 + 单人间 SGR
  14701. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14702. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14703. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14704. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14705. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14706. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14707. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14708. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14709. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14710. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14711. }
  14712. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14713. if (rightBindData != null)
  14714. {
  14715. //公务舱 + 小套房 JSES
  14716. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14717. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14718. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14719. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14720. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14721. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14722. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14723. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14724. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14725. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14726. }
  14727. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14728. if (rightBindData != null)
  14729. {
  14730. //公务舱 + 小套房 JSES
  14731. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14732. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14733. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14734. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14735. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14736. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14737. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14738. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14739. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14740. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14741. }
  14742. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14743. if (rightBindData != null)
  14744. {
  14745. //经济舱 + 大套房
  14746. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14747. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14748. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14749. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14750. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14751. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14752. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14753. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14754. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14755. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14756. }
  14757. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14758. if (rightBindData != null)
  14759. {
  14760. //头等舱 + 小套房 JSES
  14761. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14762. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14763. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14764. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14765. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14766. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14767. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14768. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14769. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14770. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14771. }
  14772. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14773. if (rightBindData != null)
  14774. {
  14775. //头等舱 + 大套房
  14776. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  14777. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14778. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14779. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14780. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14781. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14782. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14783. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14784. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14785. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14786. }
  14787. #endregion
  14788. #region 标题
  14789. designer.SetDataSource("CostBDRCB", "单人成本");
  14790. designer.SetDataSource("CostBRS", "人数");
  14791. designer.SetDataSource("CostBXS", "系数");
  14792. designer.SetDataSource("CostBZCB", "总成本");
  14793. designer.SetDataSource("CostBDRBJ", "单人报价");
  14794. designer.SetDataSource("CostBZBJ", "总报价");
  14795. designer.SetDataSource("CostBDRLR", "单人利润");
  14796. designer.SetDataSource("CostBZLR", "总利润");
  14797. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14798. designer.SetDataSource("CostBRSOM", "人数");
  14799. designer.SetDataSource("CostBZCBOM", "总成本");
  14800. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14801. designer.SetDataSource("CostBZBJOM", "总报价");
  14802. designer.SetDataSource("CostBDRLROM", "单人利润");
  14803. designer.SetDataSource("CostBZLROM", "总利润");
  14804. #endregion
  14805. }
  14806. #endregion
  14807. designer.SetDataSource("TzZCB2", TzZCB2);
  14808. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14809. designer.SetDataSource("TzZLR2", TzZLR2);
  14810. string[] dataSourceKeys = new string[]
  14811. {
  14812. "VF",
  14813. "TGS",
  14814. "TGOF",
  14815. "TGM",
  14816. "TGA",
  14817. "TGTF",
  14818. "TGEF",
  14819. "CFM",
  14820. "CFOF",
  14821. "B",
  14822. "L",
  14823. "D",
  14824. "TBR",
  14825. "SGR",
  14826. "JSES",
  14827. "Suite",
  14828. "TV",
  14829. "1L",
  14830. "IF",
  14831. "EF",
  14832. "BRF",
  14833. "TE",
  14834. "TGT",
  14835. "DRVT",
  14836. "PC",
  14837. "TLF",
  14838. "ECT"
  14839. };
  14840. foreach (var item in dataSourceKeys)
  14841. {
  14842. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14843. if (find != null)
  14844. {
  14845. designer.SetDataSource(item, find.text);
  14846. }
  14847. else
  14848. {
  14849. designer.SetDataSource(item, 0);
  14850. }
  14851. }
  14852. designer.SetDataSource(dt);
  14853. //根据数据源处理生成报表内容
  14854. designer.Process();
  14855. designer.Workbook.Worksheets[0].Name = "清单";
  14856. Worksheet sheet = designer.Workbook.Worksheets[0];
  14857. foreach (var Rowindex in hideRowsList)
  14858. {
  14859. ws.Cells.HideRows(Rowindex, 2);
  14860. }
  14861. byte[] bytes = null;
  14862. string strFileName = di.TeamName + "-团组-成本.xls";
  14863. using (MemoryStream stream = new MemoryStream())
  14864. {
  14865. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  14866. bytes = stream.ToArray();
  14867. }
  14868. return Ok(JsonView(true, "", new
  14869. {
  14870. Data = bytes,
  14871. strFileName,
  14872. }));
  14873. }
  14874. /// <summary>
  14875. /// 导出客户报表
  14876. /// </summary>
  14877. /// <returns></returns>
  14878. [HttpPost]
  14879. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14880. {
  14881. var jw = JsonView(false);
  14882. if (dto.Diid == 0)
  14883. {
  14884. return Ok(JsonView(false, "请传递团组id"));
  14885. }
  14886. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14887. if (deleInfo.Code != 0)
  14888. {
  14889. return Ok(JsonView(false, "团组信息查询失败!"));
  14890. }
  14891. var di = deleInfo.Data as DelegationInfoWebView;
  14892. if (di == null)
  14893. {
  14894. return Ok(JsonView(false, "团组信息查询失败!"));
  14895. }
  14896. //文件名
  14897. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14898. //获取模板
  14899. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14900. //载入模板
  14901. Document doc = new Document(tmppath);
  14902. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14903. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14904. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14905. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14906. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14907. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14908. if (AParameter == null)
  14909. {
  14910. return Ok(JsonView(false, "系数不存在!"));
  14911. }
  14912. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14913. , TzAirDesc, TzZCost;
  14914. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14915. = TzAirDesc = TzZCost = string.Empty;
  14916. TzNumber = AParameter.CostTypenumber.ToString();
  14917. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14918. CarGuides1 = dto.CarGuides1;
  14919. Meal = dto.Meal;
  14920. SubsidizedMeals = dto.SubsidizedMeals;
  14921. NightRepair = dto.NightRepair;
  14922. AttractionsTickets = dto.AttractionsTickets;
  14923. MiscellaneousFees = dto.MiscellaneousFees;
  14924. ATip = dto.ATip;
  14925. TzHotelDesc = "";
  14926. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14927. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14928. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14929. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14930. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14931. TzAirDesc = "";
  14932. TzZCost = dto.TzZCost;
  14933. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14934. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14935. var index = 1;
  14936. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14937. foreach (var item in TzHotelDescArr)
  14938. {
  14939. if (AinfoArr != null)
  14940. {
  14941. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14942. if (Ainfo != null)
  14943. {
  14944. if (int.Parse(Ainfo.rs) <= 0)
  14945. {
  14946. continue;
  14947. }
  14948. var hotelText = string.Empty;
  14949. switch (item)
  14950. {
  14951. case "SGR":
  14952. hotelText = "单人间";
  14953. break;
  14954. case "JSES":
  14955. hotelText = "小套房";
  14956. break;
  14957. case "SUITE":
  14958. hotelText = "套房";
  14959. break;
  14960. case "TBR":
  14961. hotelText = "双人间";
  14962. break;
  14963. }
  14964. if (item != "TBR")
  14965. {
  14966. 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";
  14967. }
  14968. else
  14969. {
  14970. 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";
  14971. }
  14972. index++;
  14973. }
  14974. }
  14975. }
  14976. index = 1;
  14977. foreach (var item in TzAirDescArr)
  14978. {
  14979. if (AinfoArr != null)
  14980. {
  14981. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14982. if (Ainfo != null)
  14983. {
  14984. if (int.Parse(Ainfo.rs) <= 0)
  14985. {
  14986. continue;
  14987. }
  14988. 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";
  14989. index++;
  14990. }
  14991. }
  14992. }
  14993. if (dto.costType == "B")
  14994. {
  14995. if (BParameter == null)
  14996. {
  14997. return Ok(JsonView(false, "B段系数不存在!"));
  14998. }
  14999. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15000. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15001. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15002. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15003. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15004. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15005. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15006. foreach (var item in TzHotelDescArr)
  15007. {
  15008. if (AinfoArr != null)
  15009. {
  15010. TzHotelDesc += "B段信息 \r\n";
  15011. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15012. if (Ainfo != null)
  15013. {
  15014. if (int.Parse(Ainfo.rs) <= 0)
  15015. {
  15016. continue;
  15017. }
  15018. var hotelText = string.Empty;
  15019. switch (item)
  15020. {
  15021. case "SGR":
  15022. hotelText = "单人间";
  15023. break;
  15024. case "JSES":
  15025. hotelText = "小套房";
  15026. break;
  15027. case "SUITE":
  15028. hotelText = "套房";
  15029. break;
  15030. case "TBR":
  15031. hotelText = "双人间";
  15032. break;
  15033. }
  15034. if (item != "TBR")
  15035. {
  15036. 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";
  15037. }
  15038. else
  15039. {
  15040. 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";
  15041. }
  15042. index++;
  15043. }
  15044. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15045. }
  15046. }
  15047. index = 1;
  15048. foreach (var item in TzAirDescArr)
  15049. {
  15050. if (AinfoArr != null)
  15051. {
  15052. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15053. if (Ainfo != null)
  15054. {
  15055. if (int.Parse(Ainfo.rs) <= 0)
  15056. {
  15057. continue;
  15058. }
  15059. 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";
  15060. index++;
  15061. }
  15062. }
  15063. }
  15064. }
  15065. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15066. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15067. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15068. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15069. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15070. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15071. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15072. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15073. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15074. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15075. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15076. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15077. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15078. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15079. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15080. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15081. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15082. DickeyValue.Add("TzZCost", TzZCost);
  15083. foreach (var key in DickeyValue.Keys)
  15084. {
  15085. if (doc.Range.Bookmarks[key] != null)
  15086. {
  15087. Bookmark mark = doc.Range.Bookmarks[key];
  15088. mark.Text = DickeyValue[key];
  15089. }
  15090. }
  15091. byte[] bytes = null;
  15092. string strFileName = di.TeamName + "-客户报价.doc";
  15093. using (MemoryStream stream = new MemoryStream())
  15094. {
  15095. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15096. bytes = stream.ToArray();
  15097. }
  15098. return Ok(JsonView(true, "", new
  15099. {
  15100. Data = bytes,
  15101. strFileName,
  15102. }));
  15103. }
  15104. /// <summary>
  15105. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15106. /// </summary>
  15107. /// <param name="dto"></param>
  15108. /// <returns></returns>
  15109. [HttpPost]
  15110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15111. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15112. {
  15113. try
  15114. {
  15115. #region 参数验证
  15116. if (dto.DiId < 0)
  15117. {
  15118. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15119. }
  15120. List<int> cTableIds = new List<int>() {
  15121. 76 ,//酒店预订
  15122. 77 ,//行程
  15123. 79 ,//车/导游地接
  15124. 80 ,//签证
  15125. 81 ,//邀请/公务活
  15126. 82 ,//团组客户保险
  15127. 85 ,//机票预订
  15128. 98 ,//其他款项
  15129. 285 ,//收款退还
  15130. 751 ,//酒店早餐
  15131. 1015 // 超支费用
  15132. };
  15133. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15134. {
  15135. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15136. }
  15137. #endregion
  15138. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15139. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15140. if (_GroupCostParameters.Count <= 0)
  15141. {
  15142. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15143. }
  15144. if (_GroupCostParameters[0].IsShare == 0)
  15145. {
  15146. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15147. }
  15148. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15149. //处理date为空问题
  15150. if (_GroupCosts.Count > 0)
  15151. {
  15152. for (int i = 0; i < _GroupCosts.Count; i++)
  15153. {
  15154. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15155. {
  15156. if (i > 0)
  15157. {
  15158. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15159. }
  15160. }
  15161. }
  15162. }
  15163. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15164. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15165. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15166. string currCode = "";
  15167. #region currCode 验证
  15168. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15169. if (isInt)
  15170. {
  15171. var currData = currDatas.Find(it => it.Id == intCurrency);
  15172. if (currData != null)
  15173. {
  15174. currCode = currData.Name;
  15175. }
  15176. }
  15177. else
  15178. {
  15179. currCode = _GroupCostParameters[0].Currency.Trim();
  15180. }
  15181. #endregion
  15182. //op,酒店单段模式存储
  15183. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15184. {
  15185. CurrencyCode = currCode,
  15186. Rate = _GroupCostParameters[0].Rate,
  15187. CostType = _GroupCostParameters[0].CostType,
  15188. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15189. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15190. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15191. };
  15192. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15193. if (_GroupCostParameters.Count == 2)
  15194. {
  15195. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15196. }
  15197. foreach (var item in _GroupCostParameters)
  15198. {
  15199. decimal _rate = 1;
  15200. decimal _rate1 = item.Rate;
  15201. decimal _scale = 1;
  15202. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15203. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15204. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15205. //if (userInfo != null)
  15206. //{
  15207. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15208. // {
  15209. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15210. // {
  15211. // _scale = 1.00M;
  15212. // }
  15213. // }
  15214. //}
  15215. #endregion
  15216. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15217. {
  15218. CurrencyCode = currCode,
  15219. Rate = _rate1,
  15220. CostType = item.CostType,
  15221. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15222. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15223. CostTypeNumber = item.CostTypenumber
  15224. };
  15225. if (_GroupCostParameters.Count > 1)
  15226. {
  15227. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15228. }
  15229. else
  15230. {
  15231. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15232. }
  15233. if (dto.CTable == 79)//
  15234. {
  15235. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15236. modulePromptInfo.TotalCost = item.DJCB;
  15237. }
  15238. List<string> costTypes = new List<string>() { "A", "B" };
  15239. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15240. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15241. if (_GroupCostsDuplicates.Count() == 1)
  15242. {
  15243. _GroupCostsTypeData = _GroupCosts;
  15244. }
  15245. else
  15246. {
  15247. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15248. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15249. }
  15250. /*
  15251. * 76 酒店预订
  15252. * 77 行程
  15253. * 79 车/导游地接
  15254. * 80 签证
  15255. * 81 邀请/公务活动
  15256. * 82 团组客户保险
  15257. * 85 机票预订
  15258. * 98 其他款项
  15259. * 285 收款退还
  15260. * 751 酒店早餐
  15261. * 1015 超支费用
  15262. */
  15263. switch (dto.CTable)
  15264. {
  15265. case 76: // 酒店预订
  15266. _ModuleSubPromptInfo.AddRange(
  15267. _GroupCostsTypeData.Select(it => new
  15268. {
  15269. it.DAY,
  15270. it.Date,
  15271. it.ACCON,
  15272. it.ITIN,
  15273. it.SGR,
  15274. it.TBR,
  15275. it.JS_ES,
  15276. it.Suite
  15277. })
  15278. );
  15279. break;
  15280. case 79: // 车/导游地接
  15281. _ModuleSubPromptInfo.AddRange(
  15282. _GroupCostsTypeData.Select(it => new
  15283. {
  15284. Date = it.Date, //日期
  15285. CarFee = it.CarCost * _rate * _scale, //车费用
  15286. CarType = it.CarType, //车型
  15287. DriverFee = it.CFS * _rate * _scale, //司机工资
  15288. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15289. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15290. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15291. GuideFee = it.TGS * _rate * _scale, //导游费用
  15292. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15293. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15294. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15295. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15296. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15297. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15298. Breakfast = it.B * _rate * _scale, //早餐费
  15299. Lunch = it.L * _rate * _scale, //午餐费
  15300. Dinner = it.D * _rate * _scale, //晚餐费
  15301. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15302. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15303. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15304. TicketFee = it.EF * _rate * _scale, //门票费
  15305. TicketRemark = it.EFR, //门票费描述
  15306. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15307. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15308. SpentCash = it.PC * _rate * _scale, //零用金
  15309. LeadersFee = it.TLF * _rate * _scale, //领队费
  15310. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15311. })
  15312. );
  15313. break;
  15314. case 85: // 机票
  15315. List<dynamic> datas = new List<dynamic>();
  15316. datas.Add(
  15317. new
  15318. {
  15319. AirType = "经济舱",
  15320. AirNum = item.JJCRS,
  15321. AirDRCB = item.JJCCB,
  15322. AirZCB = (item.JJCRS * item.JJCCB)
  15323. }
  15324. );
  15325. datas.Add(
  15326. new
  15327. {
  15328. AirType = "公务舱",
  15329. AirNum = item.GWCRS,
  15330. AirDRCB = item.GWCCB,
  15331. AirZCB = (item.GWCRS * item.GWCCB)
  15332. }
  15333. );
  15334. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15335. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15336. modulePromptInfo.Data = new
  15337. {
  15338. airFeeData = datas,
  15339. airInitData = initDatas
  15340. };
  15341. _ModulePromptInfos.Add(modulePromptInfo);
  15342. break;
  15343. default:
  15344. break;
  15345. }
  15346. }
  15347. if (dto.CTable != 85)
  15348. {
  15349. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15350. _ModulePromptInfos.Add(_ModulePromptInfo);
  15351. }
  15352. _view.ModulePromptInfos = _ModulePromptInfos;
  15353. return Ok(JsonView(true, "操作成功!", _view));
  15354. }
  15355. catch (Exception ex)
  15356. {
  15357. return Ok(JsonView(false, ex.Message));
  15358. }
  15359. }
  15360. /// <summary>
  15361. /// 根据黑屏代码重新生成行程
  15362. /// </summary>
  15363. /// <param name="dto"></param>
  15364. /// <returns></returns>
  15365. [HttpPost]
  15366. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15367. {
  15368. var jw = JsonView(false,"Error");
  15369. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15370. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15371. .Select(x=> new
  15372. {
  15373. x.Id,
  15374. x.Title
  15375. })
  15376. .ToList();
  15377. if (Create.Any())
  15378. {
  15379. jw.Msg = "获取成功!";
  15380. jw.Code = 200;
  15381. jw.Data = new
  15382. {
  15383. BlackCodeListSelect = Create,
  15384. blackCodeIsTrue = true
  15385. };
  15386. }
  15387. else
  15388. {
  15389. jw.Code = 400;
  15390. jw.Data = new
  15391. {
  15392. BlackCodeListSelect = Create,
  15393. blackCodeIsTrue = false,
  15394. };
  15395. }
  15396. return Ok(jw);
  15397. }
  15398. /// <summary>
  15399. /// 根据黑屏代码Id重新生成行程
  15400. /// </summary>
  15401. /// <param name="dto"></param>
  15402. /// <returns></returns>
  15403. [HttpPost]
  15404. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15405. {
  15406. var jw = JsonView(false, "Error");
  15407. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15408. if (result.Code == 0)
  15409. {
  15410. jw.Msg = "获取成功!";
  15411. jw.Code = 200;
  15412. jw.Data = new
  15413. {
  15414. groupCost = result.Data,
  15415. blackCodeIsTrue = true
  15416. };
  15417. }
  15418. else
  15419. {
  15420. jw.Code = 400;
  15421. jw.Data = new
  15422. {
  15423. groupCost = result.Data,
  15424. blackCodeIsTrue = false,
  15425. };
  15426. }
  15427. return Ok(jw);
  15428. }
  15429. /// <summary>
  15430. /// 成本获取OP历史车费用
  15431. /// </summary>
  15432. /// <param name="dto"></param>
  15433. /// <returns></returns>
  15434. [HttpPost]
  15435. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15436. {
  15437. var jw = JsonView(false);
  15438. try
  15439. {
  15440. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15441. //获取现有所有车的数据
  15442. if (!dto.Param.IsNullOrWhiteSpace())
  15443. {
  15444. string sql = $@"
  15445. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15446. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15447. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15448. 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
  15449. AND gctggr.ServiceEndTime is not NULL
  15450. ORDER by gctggrc.id DESC
  15451. ";
  15452. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15453. var numeberResult = await Task.Run(() =>
  15454. {
  15455. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15456. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15457. return numberArr;
  15458. });
  15459. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15460. foreach (var item in numeberResult)
  15461. {
  15462. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15463. {
  15464. Country = "数据异常!",
  15465. City = string.Empty,
  15466. };
  15467. item.Area = find.Country + " " + find.City;
  15468. }
  15469. dbResult.AddRange(numeberResult);
  15470. if (dto.Param.Contains("、"))
  15471. {
  15472. var sp = dto.Param.Split("、");
  15473. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15474. .Where(x =>
  15475. {
  15476. return System.Array.Exists(sp, e =>
  15477. {
  15478. bool where = false;
  15479. if (x.Area != null)
  15480. {
  15481. where = x.Area.Contains(e);
  15482. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15483. {
  15484. return false;
  15485. }
  15486. }
  15487. if (x.PriceName != null && !where)
  15488. {
  15489. where = x.PriceName.Contains(e);
  15490. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15491. {
  15492. return false;
  15493. }
  15494. }
  15495. return where;
  15496. });
  15497. }).ToList();
  15498. }
  15499. else
  15500. {
  15501. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15502. .Where(x =>
  15503. {
  15504. bool where = false;
  15505. if (x.Area != null)
  15506. {
  15507. where = x.Area.Contains(dto.Param);
  15508. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15509. {
  15510. return false;
  15511. }
  15512. }
  15513. if (x.PriceName != null && !where)
  15514. {
  15515. where = x.PriceName.Contains(dto.Param);
  15516. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15517. {
  15518. return false;
  15519. }
  15520. }
  15521. return where;
  15522. }
  15523. )
  15524. .ToList();
  15525. }
  15526. }
  15527. var view = dbResult.Select(x =>
  15528. {
  15529. decimal dp = 0.00M;
  15530. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15531. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15532. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15533. {
  15534. if (startB && endB)
  15535. {
  15536. var timesp = endD.Subtract(startD);
  15537. if ((timesp.Days + 1) != 0)
  15538. {
  15539. dp = x.Price / (timesp.Days + 1);
  15540. }
  15541. }
  15542. }
  15543. else
  15544. {
  15545. dp = x.Price;
  15546. }
  15547. return new
  15548. {
  15549. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15550. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15551. x.Area,
  15552. x.id,
  15553. price = x.Price.ToString("F2"),
  15554. x.PriceName,
  15555. x.PriceContent,
  15556. x.TeamName,
  15557. x.DatePrice,
  15558. dayPrice = dp.ToString("F2"),
  15559. };
  15560. }).OrderByDescending(x => x.id).ToList();
  15561. jw = JsonView(true, "获取成功!", view);
  15562. }
  15563. catch (Exception e)
  15564. {
  15565. jw = JsonView(false, e.Message);
  15566. }
  15567. return Ok(jw);
  15568. }
  15569. [HttpPost]
  15570. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15571. {
  15572. var jw = JsonView(true);
  15573. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15574. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15575. {
  15576. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15577. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15578. WHEN COUNT(*) >= 0 THEN 'True'
  15579. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15580. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15581. ")
  15582. .ToList();
  15583. }
  15584. else
  15585. {
  15586. string likeKey = string.Empty;
  15587. foreach (var item in dto.Keyword)
  15588. {
  15589. likeKey += "%" + item;
  15590. }
  15591. likeKey += "%";
  15592. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15593. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15594. WHEN COUNT(*) >= 0 THEN 'True'
  15595. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15596. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15597. ")
  15598. .ToList();
  15599. }
  15600. if (matches.Any())
  15601. {
  15602. jw.Data = matches;
  15603. }
  15604. else
  15605. {
  15606. jw.Code = 201;
  15607. jw.Msg = "empty list";
  15608. jw.Data = new List<string>(1);
  15609. }
  15610. return Ok(jw);
  15611. }
  15612. #endregion
  15613. #region 酒店预订 新 雷怡 2023-12-28 17:45
  15614. /// <summary>
  15615. /// 酒店预订
  15616. /// 酒店费用列表 根据团组Id查询
  15617. /// </summary>
  15618. /// <param name="_dto"></param>
  15619. /// <returns></returns>
  15620. [HttpPost]
  15621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15622. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  15623. {
  15624. #region 参数验证
  15625. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15626. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15627. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15628. #region 团组操作权限验证 76 酒店预定模块
  15629. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15630. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15631. #endregion
  15632. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15633. #region 页面操作权限验证
  15634. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15635. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15636. #endregion
  15637. #endregion
  15638. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  15639. }
  15640. /// <summary>
  15641. /// 酒店预订
  15642. /// 基础数据
  15643. /// </summary>
  15644. /// <param name="_dto"></param>
  15645. /// <returns></returns>
  15646. [HttpPost]
  15647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15648. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  15649. {
  15650. #region 参数验证
  15651. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15652. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15653. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15654. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15655. #region 页面操作权限验证
  15656. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15657. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15658. #endregion
  15659. #region 团组操作权限验证 76 酒店预定模块
  15660. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15661. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15662. #endregion
  15663. #endregion
  15664. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  15665. }
  15666. /// <summary>
  15667. /// 酒店预订
  15668. /// 创建 入住卷号码
  15669. /// </summary>
  15670. /// <param name="_dto"></param>
  15671. /// <returns></returns>
  15672. [HttpPost]
  15673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15674. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  15675. {
  15676. #region 参数验证
  15677. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15678. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15679. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15680. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15681. #region 页面操作权限验证
  15682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15683. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15684. #endregion
  15685. #region 团组操作权限验证 76 酒店预定模块
  15686. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15687. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15688. #endregion
  15689. #endregion
  15690. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  15691. if (data.Code != 0)
  15692. {
  15693. return Ok(JsonView(false, data.Msg));
  15694. }
  15695. return Ok(JsonView(true, data.Msg, data.Data));
  15696. }
  15697. /// <summary>
  15698. /// 酒店预订
  15699. /// 详情
  15700. /// </summary>
  15701. /// <param name="_dto"></param>
  15702. /// <returns></returns>
  15703. [HttpPost]
  15704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15705. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  15706. {
  15707. #region 参数验证
  15708. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  15709. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15710. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  15711. #region 团组操作权限验证 76 酒店预定模块
  15712. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15713. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15714. #endregion
  15715. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15716. #region 页面操作权限验证
  15717. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15718. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15719. #endregion
  15720. #endregion
  15721. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  15722. }
  15723. /// <summary>
  15724. /// 酒店预订
  15725. /// Add Or Edit
  15726. /// </summary>
  15727. /// <param name="_dto"></param>
  15728. /// <returns></returns>
  15729. [HttpPost]
  15730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15731. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  15732. {
  15733. #region 参数验证
  15734. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15735. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15736. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15737. #region 团组操作权限验证 76 酒店预定模块
  15738. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15739. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15740. #endregion
  15741. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15742. #region 页面操作权限验证
  15743. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15744. if (_dto.Id == 0) // Add
  15745. {
  15746. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  15747. }
  15748. else if (_dto.Id > 1) // Edit
  15749. {
  15750. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  15751. }
  15752. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  15753. #endregion
  15754. #endregion
  15755. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  15756. if (_view.Code != 200)
  15757. {
  15758. return Ok(_view);
  15759. }
  15760. #region 成本无酒店价格数据进入超支
  15761. _sqlSugar.BeginTran();
  15762. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  15763. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  15764. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  15765. for (int i = 0; i < groupCost.Count; i++)
  15766. {
  15767. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  15768. {
  15769. groupCost[i].Date = groupCost[i - 1].Date;
  15770. }
  15771. }
  15772. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  15773. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  15774. List<Fin_GroupExtraCostDto_OP>();
  15775. if (start_Bool && end_Bool)
  15776. {
  15777. while (start_Time < end_Time)
  15778. {
  15779. foreach (var item in groupCost_Grp)
  15780. {
  15781. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  15782. {
  15783. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  15784. {
  15785. extraCostList.Add(new
  15786. Fin_GroupExtraCostDto_OP
  15787. {
  15788. Area = _dto.AreaId,
  15789. coefficient = 1.5M,
  15790. createUser = _dto.UserId,
  15791. currency = _dto.CardPriceCurrency,
  15792. diId = _dto.DiId,
  15793. ManagerConfirm = 0,
  15794. SupervisorConfirm = 0,
  15795. SYsupervisorConfirm = 0,
  15796. editType = 1,
  15797. PortType = 1,
  15798. price = _dto.CardPrice,
  15799. PriceCount = 1,
  15800. priceType = 1027,
  15801. priceDetailType = 1044,
  15802. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  15803. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  15804. });
  15805. }
  15806. }
  15807. }
  15808. start_Time = start_Time.AddDays(1);
  15809. }
  15810. }
  15811. if (extraCostList.Any())
  15812. {
  15813. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  15814. }
  15815. _sqlSugar.CommitTran();
  15816. #endregion
  15817. #region 应用推送
  15818. try
  15819. {
  15820. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15821. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15822. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15823. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15824. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15825. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15826. var diId = _dto.DiId;
  15827. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15828. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15829. #region 操作记录
  15830. var opInfo = new Crm_TableOperationRecord()
  15831. {
  15832. TableName = "Grp_HotelReservations",
  15833. PortType = _dto.PortType,
  15834. DataId = hotelId,
  15835. CreateUserId = _dto.UserId
  15836. };
  15837. //var opStatus = OperationEnum.NoOperation;
  15838. if (_dto.Id < 1) //添加操作
  15839. {
  15840. opInfo.OperationItem = OperationEnum.Add;
  15841. }
  15842. else if (_dto.Id > 0)
  15843. {
  15844. opInfo.OperationItem = OperationEnum.Edit;
  15845. }
  15846. string opRemark = string.Empty;
  15847. if (ccpInfo != null)
  15848. {
  15849. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  15850. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  15851. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  15852. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  15853. }
  15854. opInfo.Remark = opRemark;
  15855. await _tableorRep.AddAsync(opInfo);
  15856. #endregion
  15857. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  15858. //2024-10-21 新增LZ UID
  15859. var userIds = new List<int>() { 21 };
  15860. string title = $"费用审核";
  15861. string content = "";
  15862. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15863. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15864. try
  15865. {
  15866. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15867. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  15868. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  15869. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  15870. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  15871. }
  15872. catch (Exception ex)
  15873. {
  15874. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  15875. }
  15876. }
  15877. catch (Exception ex)
  15878. {
  15879. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  15880. }
  15881. try
  15882. {
  15883. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15884. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15885. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15886. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15887. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15888. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15889. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15890. //自动审核
  15891. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  15892. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  15893. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  15894. //2024-10-21 新增LZ UID
  15895. var userIds = new List<int>() { 21 };
  15896. string title = $"系统通知";
  15897. var diId = _dto.DiId;
  15898. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15899. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15900. string content = "";
  15901. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15902. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15903. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15904. }
  15905. catch (Exception ex)
  15906. {
  15907. }
  15908. #endregion
  15909. return Ok(_view);
  15910. }
  15911. /// <summary>
  15912. /// 酒店自动审核测试
  15913. /// Add Or Edit
  15914. /// </summary>
  15915. /// <param name="diid"></param>
  15916. /// <param name="dataId"></param>
  15917. /// <returns></returns>
  15918. [HttpPost]
  15919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15920. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  15921. {
  15922. #region 应用推送
  15923. try
  15924. {
  15925. //自动审核
  15926. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  15927. }
  15928. catch (Exception ex)
  15929. {
  15930. return Ok(JsonView(false, "操作失败"));
  15931. }
  15932. #endregion
  15933. return Ok(JsonView(false, "操作成功"));
  15934. }
  15935. /// <summary>
  15936. /// 酒店预订
  15937. /// Del
  15938. /// </summary>
  15939. /// <param name="_dto"></param>
  15940. /// <returns></returns>
  15941. [HttpPost]
  15942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15943. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  15944. {
  15945. #region 参数验证
  15946. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15947. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15948. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15949. #region 团组操作权限验证 76 酒店预定模块
  15950. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15951. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15952. #endregion
  15953. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15954. #region 页面操作权限验证
  15955. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15956. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  15957. #endregion
  15958. #endregion
  15959. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15960. #region 操作记录
  15961. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15962. {
  15963. TableName = "Grp_HotelReservations",
  15964. PortType = _dto.PortType,
  15965. OperationItem = OperationEnum.Del,
  15966. DataId = _dto.Id,
  15967. CreateUserId = _dto.UserId
  15968. });
  15969. #endregion
  15970. return Ok(data);
  15971. }
  15972. /// <summary>
  15973. /// 酒店预订
  15974. /// 生成VOUCHER
  15975. /// 2024.05.06 之前版本
  15976. /// </summary>
  15977. /// <param name="_dto"></param>
  15978. /// <returns></returns>
  15979. [HttpPost]
  15980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15981. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15982. {
  15983. try
  15984. {
  15985. #region 参数验证
  15986. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15987. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15988. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15989. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15990. #region 团组操作权限验证 76 酒店预定模块
  15991. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15992. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15993. #endregion
  15994. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15995. #region 页面操作权限验证
  15996. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15997. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15998. #endregion
  15999. #endregion
  16000. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  16001. //判断数据是否完整
  16002. if (hr != null)
  16003. {
  16004. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16005. {
  16006. string strFileName = "HotelStatement/";
  16007. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16008. if (dele != null)
  16009. strFileName += dele.TourCode;
  16010. //载入模板
  16011. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16012. Document doc = new Document(sss);
  16013. DocumentBuilder builder = new DocumentBuilder(doc);
  16014. #region 替换Word模板书签内容
  16015. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16016. //入住卷预定号码
  16017. if (doc.Range.Bookmarks["VNO"] != null)
  16018. {
  16019. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16020. mark.Text = hr.CheckNumber;
  16021. }
  16022. //酒店时间
  16023. if (doc.Range.Bookmarks["Date"] != null)
  16024. {
  16025. Bookmark mark = doc.Range.Bookmarks["Date"];
  16026. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16027. }
  16028. //团号
  16029. if (doc.Range.Bookmarks["TNo"] != null)
  16030. {
  16031. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16032. mark.Text = dele.TourCode;
  16033. }
  16034. //预定号码
  16035. if (doc.Range.Bookmarks["BookingId"] != null)
  16036. {
  16037. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16038. mark.Text = hr.ReservationsNo;
  16039. }
  16040. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16041. {
  16042. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16043. mark.Text = hr.DetermineNo;
  16044. }
  16045. //酒店城市
  16046. if (doc.Range.Bookmarks["City"] != null)
  16047. {
  16048. Bookmark mark = doc.Range.Bookmarks["City"];
  16049. mark.Text = hr.City;
  16050. }
  16051. //酒店名称
  16052. if (doc.Range.Bookmarks["HName"] != null)
  16053. {
  16054. Bookmark mark = doc.Range.Bookmarks["HName"];
  16055. mark.Text = hr.HotelName;
  16056. }
  16057. //酒店地址
  16058. if (doc.Range.Bookmarks["Address"] != null)
  16059. {
  16060. Bookmark mark = doc.Range.Bookmarks["Address"];
  16061. mark.Text = hr.HotelAddress;
  16062. }
  16063. //酒店电话
  16064. if (doc.Range.Bookmarks["Tel"] != null)
  16065. {
  16066. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16067. mark.Text = hr.HotelTel;
  16068. }
  16069. //酒店传真
  16070. if (doc.Range.Bookmarks["Fax"] != null)
  16071. {
  16072. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16073. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16074. {
  16075. mark.Text = hr.HotelFax;
  16076. }
  16077. }
  16078. //入住时间
  16079. if (doc.Range.Bookmarks["CIn"] != null)
  16080. {
  16081. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16082. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16083. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16084. }
  16085. //退房时间
  16086. if (doc.Range.Bookmarks["COut"] != null)
  16087. {
  16088. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16089. Bookmark mark = doc.Range.Bookmarks["COut"];
  16090. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16091. }
  16092. //客户名称
  16093. if (doc.Range.Bookmarks["GName"] != null)
  16094. {
  16095. string guestName = "";
  16096. string[] clients = new string[] { };
  16097. if (hr.GuestName.Contains(","))
  16098. {
  16099. clients = hr.GuestName.Split(",");
  16100. }
  16101. else
  16102. {
  16103. clients = new string[] { hr.GuestName };
  16104. }
  16105. List<int> clientIds_int = new List<int>();
  16106. if (clients.Length > 0)
  16107. {
  16108. foreach (var item in clients)
  16109. {
  16110. if (item.IsNumeric())
  16111. {
  16112. clientIds_int.Add(int.Parse(item));
  16113. }
  16114. }
  16115. }
  16116. if (clientIds_int.Count > 0)
  16117. {
  16118. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16119. foreach (var client in _clientDatas)
  16120. {
  16121. //男
  16122. if (client.Sex == 0) guestName += $"Mr.";
  16123. //女
  16124. else if (client.Sex == 1) guestName += $"Ms.";
  16125. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16126. {
  16127. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16128. }
  16129. //guestName += $"{client.Pinyin},";
  16130. }
  16131. if (guestName.Length > 0)
  16132. {
  16133. guestName = guestName.Substring(0, guestName.Length - 1);
  16134. }
  16135. }
  16136. else
  16137. {
  16138. guestName = hr.GuestName;
  16139. }
  16140. Bookmark mark = doc.Range.Bookmarks["GName"];
  16141. mark.Text = guestName;
  16142. }
  16143. //房间介绍
  16144. if (doc.Range.Bookmarks["ROOM"] != null)
  16145. {
  16146. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16147. mark.Text = hr.RoomExplanation;
  16148. }
  16149. //报价描述
  16150. if (doc.Range.Bookmarks["NOTE"] != null)
  16151. {
  16152. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16153. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16154. if (ss != null)
  16155. mark.Text = ss.Name;
  16156. }
  16157. //入住时间
  16158. if (doc.Range.Bookmarks["CheckIn"] != null)
  16159. {
  16160. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16161. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16162. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16163. }
  16164. //退房时间
  16165. if (doc.Range.Bookmarks["CheckOut"] != null)
  16166. {
  16167. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16168. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16169. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16170. }
  16171. //日期
  16172. if (doc.Range.Bookmarks["DT"] != null)
  16173. {
  16174. Bookmark mark = doc.Range.Bookmarks["DT"];
  16175. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16176. }
  16177. //名称
  16178. if (doc.Range.Bookmarks["VName"] != null)
  16179. {
  16180. Bookmark mark = doc.Range.Bookmarks["VName"];
  16181. mark.Text = hr.HotelName;
  16182. }
  16183. //号码
  16184. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  16185. {
  16186. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  16187. mark.Text = hr.CheckNumber;
  16188. }
  16189. #endregion
  16190. strFileName += "VOUCHER.doc";
  16191. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16192. doc.Save(fileDir);
  16193. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16194. return Ok(JsonView(true, "操作成功!", Url));
  16195. }
  16196. else
  16197. {
  16198. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  16199. }
  16200. }
  16201. else
  16202. {
  16203. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  16204. }
  16205. }
  16206. catch (Exception ex)
  16207. {
  16208. return Ok(JsonView(false, ex.Message));
  16209. }
  16210. }
  16211. /// <summary>
  16212. /// 酒店预订
  16213. /// 生成VOUCHER
  16214. /// 2024.05.06 之后版本
  16215. /// </summary>
  16216. /// <param name="_dto"></param>
  16217. /// <returns></returns>
  16218. [HttpPost]
  16219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16220. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  16221. {
  16222. #region 参数验证
  16223. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16224. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16225. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16226. #region 团组操作权限验证 76 酒店预定模块
  16227. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16228. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16229. #endregion
  16230. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16231. #region 页面操作权限验证
  16232. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16233. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16234. #endregion
  16235. #endregion
  16236. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  16237. //判断数据是否完整
  16238. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16239. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16240. string strFileName = "HotelStatement/";
  16241. string guestNames = ""; //格式Mr.xxx Ms.xxx
  16242. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  16243. #region 数据处理
  16244. List<int> guestIds = new List<int>();
  16245. //int index = 0;
  16246. foreach (var item in hrDtas)
  16247. {
  16248. if (item.GuestName.Contains(","))
  16249. {
  16250. string[] guestIdArr = item.GuestName.Split(',');
  16251. foreach (var guestIdStr in guestIdArr)
  16252. {
  16253. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  16254. if (guestBool)
  16255. {
  16256. guestIds.Add(guestId);
  16257. }
  16258. }
  16259. }
  16260. else guestNames += item.GuestName;
  16261. var voucherInfo = new HotelVoucherInfoView()
  16262. {
  16263. HotelName = item.HotelName,
  16264. CheckInDate = item.CheckInDate,
  16265. CheckOutDate = item.CheckOutDate,
  16266. ConfirmationNumber = item.DetermineNo.Trim(),
  16267. RoomType = item.RoomExplanation
  16268. };
  16269. vouchers.Add(voucherInfo);
  16270. }
  16271. if (guestIds.Count > 0)
  16272. {
  16273. guestIds = guestIds.Distinct().ToList();
  16274. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  16275. if (guestDatas.Count > 0)
  16276. {
  16277. guestNames = "";
  16278. foreach (var guest in guestDatas)
  16279. {
  16280. string guestName = "";
  16281. if (guest.Sex == 0) guestName += @"MR.";
  16282. else if (guest.Sex == 1) guestName += @"MS.";
  16283. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16284. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16285. guestNames += @$"{guestName.Trim()}、";
  16286. }
  16287. if (guestNames.Length > 0)
  16288. {
  16289. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16290. }
  16291. }
  16292. }
  16293. #endregion
  16294. //载入模板
  16295. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  16296. Document doc = new Document(sss);
  16297. DocumentBuilder builder = new DocumentBuilder(doc);
  16298. if (doc.Range.Bookmarks["GuestName"] != null)
  16299. {
  16300. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  16301. mark.Text = guestNames;
  16302. }
  16303. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16304. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  16305. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  16306. for (int i = 1; i <= vouchers.Count; i++)
  16307. {
  16308. HotelVoucherInfoView hviv = vouchers[i - 1];
  16309. builder.MoveToCell(0, i, 0, 0);
  16310. builder.Write(hviv.HotelName);
  16311. builder.MoveToCell(0, i, 1, 0);
  16312. builder.Write(hviv.CheckInDate);
  16313. builder.MoveToCell(0, i, 2, 0);
  16314. builder.Write(hviv.CheckOutDate);
  16315. builder.MoveToCell(0, i, 3, 0);
  16316. builder.Write(hviv.RoomType);
  16317. builder.MoveToCell(0, i, 4, 0);
  16318. builder.Write(hviv.ConfirmationNumber);
  16319. }
  16320. //删除多余行
  16321. int currRowIndex = vouchers.Count + 1;
  16322. int delRows = 21 - currRowIndex;
  16323. if (delRows > 0)
  16324. {
  16325. for (int i = 0; i < delRows; i++)
  16326. {
  16327. table.Rows.RemoveAt(currRowIndex);
  16328. //cultivateRowIndex++;
  16329. }
  16330. }
  16331. strFileName += "VOUCHER.docx";
  16332. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16333. doc.Save(fileDir);
  16334. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16335. return Ok(JsonView(true, "操作成功!", Url));
  16336. }
  16337. /// <summary>
  16338. /// 酒店预订
  16339. /// 生成VOUCHER 批量生成
  16340. /// New
  16341. /// </summary>
  16342. /// <param name="_dto"></param>
  16343. /// <returns></returns>
  16344. [HttpPost]
  16345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16346. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  16347. {
  16348. #region 参数验证
  16349. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16350. if (_dto.PageId < 1) _dto.PageId = 28;
  16351. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16352. #region 团组操作权限验证 76 酒店预定模块
  16353. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16354. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16355. #endregion
  16356. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16357. #region 页面操作权限验证
  16358. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16359. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16360. #endregion
  16361. #endregion
  16362. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  16363. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  16364. .OrderBy(x => x.CheckInDate)
  16365. .ToListAsync();
  16366. //判断数据是否完整
  16367. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16368. string strFileName = "HotelStatement/";
  16369. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16370. if (dele != null)
  16371. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  16372. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  16373. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  16374. .Where(it => it.IsDel == 0)
  16375. .ToListAsync();
  16376. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  16377. for (int i = 0; i < hrDtas.Count; i++)
  16378. {
  16379. string guestNames = string.Empty;
  16380. List<int> guestIds = new List<int>();
  16381. var item = hrDtas[i];
  16382. //处理客户姓名
  16383. if (item.GuestName.Contains(","))
  16384. {
  16385. string[] guestIdArr = item.GuestName.Split(',');
  16386. foreach (var guestIdStr in guestIdArr)
  16387. if (int.TryParse(guestIdStr, out int guestId))
  16388. guestIds.Add(guestId);
  16389. }
  16390. else
  16391. {
  16392. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  16393. if (guestIdBool)
  16394. {
  16395. guestIds.Add(guestId);
  16396. }
  16397. //NaN
  16398. if (item.GuestName.Contains("NaN"))
  16399. {
  16400. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  16401. }
  16402. }
  16403. if (guestIds.Count > 0)
  16404. {
  16405. guestIds = guestIds.Distinct().ToList();
  16406. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  16407. if (guestDatas1.Count > 0)
  16408. {
  16409. guestNames = "";
  16410. foreach (var guest in guestDatas1)
  16411. {
  16412. string guestName = "";
  16413. if (guest.Sex == 0) guestName += @"MR.";
  16414. else if (guest.Sex == 1) guestName += @"MS.";
  16415. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16416. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16417. guestNames += @$"{guestName.Trim()}、";
  16418. }
  16419. if (guestNames.Length > 0)
  16420. {
  16421. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16422. }
  16423. }
  16424. }
  16425. //if (!string.IsNullOrEmpty(guestNames))
  16426. //{
  16427. hrDtas[i].GuestName = guestNames;
  16428. //}
  16429. }
  16430. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  16431. Document doc = new Document();
  16432. DocumentBuilder builder = new DocumentBuilder(doc);
  16433. try
  16434. {
  16435. builder.MoveToDocumentStart();
  16436. foreach (var item in hrDtas)
  16437. {
  16438. //标题
  16439. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16440. builder.ParagraphFormat.LineSpacing = 1;
  16441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16442. builder.ParagraphFormat.Style.Font.Size = 9;
  16443. builder.ParagraphFormat.Style.Font.Bold = true;
  16444. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16445. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  16446. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16447. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16448. builder.ParagraphFormat.LineSpacing = 1;
  16449. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16450. builder.ParagraphFormat.Style.Font.Size = 9;
  16451. builder.ParagraphFormat.Style.Font.Bold = true;
  16452. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  16453. builder.StartTable();
  16454. // 设置边框颜色
  16455. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  16456. //设置边框样式
  16457. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  16458. //表格
  16459. #region 第一行
  16460. builder.InsertCell();
  16461. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16462. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16463. //builder.CellFormat.AllowAutoFit = false;
  16464. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16465. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16466. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16467. builder.CellFormat.WrapText = true; //自动换行
  16468. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16469. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  16470. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16471. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16472. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16473. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16474. builder.Write("TOUR NO:");
  16475. builder.InsertCell();
  16476. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16477. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16478. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16479. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16480. builder.ParagraphFormat.Style.Font.Bold = false;
  16481. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16482. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16483. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16484. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16485. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16486. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16487. builder.Write($"{dele?.TourCode ?? "-"}");
  16488. builder.InsertCell();
  16489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16492. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16493. builder.ParagraphFormat.Style.Font.Bold = false;
  16494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16500. builder.Write($"CITY:");
  16501. builder.InsertCell();
  16502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16503. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16504. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16505. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16506. builder.ParagraphFormat.Style.Font.Bold = false;
  16507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16509. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16510. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16511. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16512. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16513. builder.Write($"{item.City}");
  16514. builder.EndRow();
  16515. #endregion
  16516. #region 第二行
  16517. builder.InsertCell();
  16518. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16519. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16522. builder.ParagraphFormat.Style.Font.Bold = false;
  16523. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16524. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16525. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16526. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16527. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16528. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16529. builder.Write("CONFIRMATION NO:");
  16530. builder.InsertCell();
  16531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16532. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16533. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16534. builder.ParagraphFormat.Style.Font.Bold = false;
  16535. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16536. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16537. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16538. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16539. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16540. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16541. builder.CellFormat.VerticalMerge = CellMerge.None;
  16542. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16543. builder.Write($"{item.DetermineNo}");
  16544. builder.InsertCell();
  16545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16546. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16547. builder.InsertCell();
  16548. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16549. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16550. builder.EndRow();
  16551. #endregion
  16552. #region 第三行
  16553. builder.InsertCell();
  16554. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16555. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16556. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16557. builder.ParagraphFormat.Style.Font.Bold = false;
  16558. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16559. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16560. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16561. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16562. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16563. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16564. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16565. builder.Write($"HOTEL NAME:");
  16566. builder.InsertCell();
  16567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16570. builder.ParagraphFormat.Style.Font.Bold = false;
  16571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16578. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16579. builder.Write($"{item.HotelName}");
  16580. builder.InsertCell();
  16581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16582. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16583. builder.InsertCell();
  16584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16585. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16586. builder.EndRow();
  16587. #endregion
  16588. #region 第四行
  16589. builder.InsertCell();
  16590. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16591. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16592. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16593. builder.ParagraphFormat.Style.Font.Bold = false;
  16594. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16595. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16596. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16597. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16598. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16599. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16600. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16601. builder.Write($"HOTEL ADDRESS:");
  16602. builder.InsertCell();
  16603. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16604. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16605. builder.ParagraphFormat.Style.Font.Size = 8;
  16606. builder.ParagraphFormat.Style.Font.Bold = false;
  16607. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16608. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16609. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16610. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16611. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16612. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16613. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16614. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16615. builder.Write($"{item.HotelAddress}");
  16616. builder.InsertCell();
  16617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16618. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16619. builder.InsertCell();
  16620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16621. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16622. builder.EndRow();
  16623. #endregion
  16624. #region 第五行
  16625. builder.InsertCell();
  16626. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16627. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16628. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16629. builder.ParagraphFormat.Style.Font.Bold = false;
  16630. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16631. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16632. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16633. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16634. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16635. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16636. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16637. builder.Write("TEL:");
  16638. builder.InsertCell();
  16639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16642. builder.ParagraphFormat.Style.Font.Bold = false;
  16643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16650. builder.Write($"{item.HotelTel}");
  16651. builder.InsertCell();
  16652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16654. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16655. builder.ParagraphFormat.Style.Font.Bold = false;
  16656. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16663. builder.Write($"FAX:");
  16664. builder.InsertCell();
  16665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16667. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16668. builder.ParagraphFormat.Style.Font.Bold = false;
  16669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16672. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16673. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16674. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16675. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16676. builder.Write($"{item.HotelFax}");
  16677. builder.EndRow();
  16678. #endregion
  16679. #region 第六行
  16680. builder.InsertCell();
  16681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16682. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16683. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16684. builder.ParagraphFormat.Style.Font.Bold = false;
  16685. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16686. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16687. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16688. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16689. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16690. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16691. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16692. builder.Write("CHECK IN:");
  16693. builder.InsertCell();
  16694. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16695. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16696. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16697. builder.ParagraphFormat.Style.Font.Bold = false;
  16698. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16699. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16700. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16701. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16702. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16703. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16704. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16705. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  16706. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16707. builder.Write($"{checkInStr}");
  16708. builder.InsertCell();
  16709. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16710. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16711. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16712. builder.ParagraphFormat.Style.Font.Bold = false;
  16713. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16714. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16715. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16716. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16717. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16718. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16719. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16720. builder.Write($"CHECK OUT:");
  16721. builder.InsertCell();
  16722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16723. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16724. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16725. builder.ParagraphFormat.Style.Font.Bold = false;
  16726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16733. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  16734. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  16735. builder.Write($"{checkOutStr}");
  16736. builder.EndRow();
  16737. #endregion
  16738. #region 第七行
  16739. builder.InsertCell();
  16740. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16741. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16742. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16743. builder.ParagraphFormat.Style.Font.Bold = false;
  16744. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16745. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16746. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16747. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16748. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16749. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16750. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16751. builder.Write($"GUEST NAME:");
  16752. builder.InsertCell();
  16753. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16754. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16755. builder.ParagraphFormat.Style.Font.Size = 8;
  16756. builder.ParagraphFormat.Style.Font.Bold = false;
  16757. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16758. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16760. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16761. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16762. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16763. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16764. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16765. builder.Write($"{item.GuestName}");
  16766. builder.InsertCell();
  16767. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16768. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16769. builder.InsertCell();
  16770. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16771. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16772. builder.EndRow();
  16773. #endregion
  16774. #region 第八行
  16775. builder.InsertCell();
  16776. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16777. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16778. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16779. builder.ParagraphFormat.Style.Font.Bold = false;
  16780. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16781. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16782. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16783. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16784. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16785. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16786. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16787. builder.Write($"ROOM TYPE:");
  16788. builder.InsertCell();
  16789. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16790. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16791. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16792. builder.ParagraphFormat.Style.Font.Bold = false;
  16793. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16794. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16795. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16796. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16797. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16798. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16799. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16800. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16801. builder.Write($"{item.RoomExplanation}");
  16802. builder.InsertCell();
  16803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16804. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16805. builder.InsertCell();
  16806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16807. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16808. builder.EndRow();
  16809. #endregion
  16810. #region 第九行
  16811. builder.InsertCell();
  16812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16815. builder.ParagraphFormat.Style.Font.Bold = false;
  16816. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16817. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16818. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16819. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16820. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16821. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16822. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16823. builder.Write($"NOTE:");
  16824. builder.InsertCell();
  16825. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16826. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16827. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16828. builder.ParagraphFormat.Style.Font.Bold = false;
  16829. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16830. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16832. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16833. 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.");
  16834. builder.InsertCell();
  16835. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16836. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16837. builder.InsertCell();
  16838. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16839. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16840. builder.EndRow();
  16841. #endregion
  16842. builder.EndTable();
  16843. //换行
  16844. builder.Writeln("");
  16845. builder.Writeln("");
  16846. }
  16847. #region 获取文档中的所有表格 设置文字自适应
  16848. // 获取文档中的所有表格。
  16849. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  16850. {
  16851. // 遍历表格中的所有行。
  16852. foreach (Aspose.Words.Tables.Row row in table.Rows)
  16853. {
  16854. foreach (Cell cell in row.Cells)
  16855. {
  16856. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  16857. cellFormat.Width = 0;
  16858. }
  16859. }
  16860. }
  16861. #endregion
  16862. #region 设置页眉
  16863. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  16864. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  16865. if (System.IO.File.Exists(voucherHeaderPath))
  16866. {
  16867. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  16868. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  16869. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  16870. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  16871. // 调整图片位置
  16872. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  16873. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  16874. shape.Top = 50; // 将图片距离页眉上边缘的距离
  16875. shape.Left = 0; // 将图片距离页面左边缘的距离
  16876. shape.Width = 81; // 设置图片宽度
  16877. shape.Height = 36; // 设置图片高度
  16878. }
  16879. //靠右
  16880. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16881. //// 设置页脚上下边距
  16882. //builder.PageSetup.HeaderDistance = 42;
  16883. // 添加页眉线
  16884. Aspose.Words.Border borderHeader = null;
  16885. try
  16886. {
  16887. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  16888. }
  16889. catch (Exception e)
  16890. {
  16891. // TODO Auto-generated catch block
  16892. //e.printStackTrace();
  16893. }
  16894. borderHeader.Shadow = true;
  16895. borderHeader.DistanceFromText = 2;
  16896. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  16897. #endregion
  16898. }
  16899. catch (Exception ex)
  16900. {
  16901. }
  16902. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16903. doc.Save(fileDir);
  16904. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16905. return Ok(JsonView(true, "操作成功!", Url));
  16906. }
  16907. /// <summary>
  16908. /// 酒店预订
  16909. /// 生成 预定成本 Excel
  16910. /// </summary>
  16911. /// <param name="_dto"></param>
  16912. /// <returns></returns>
  16913. [HttpPost]
  16914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16915. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  16916. {
  16917. #region 参数验证
  16918. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  16919. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  16920. if (!vadalitorRes.IsValid)
  16921. {
  16922. var errors = new StringBuilder();
  16923. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  16924. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  16925. }
  16926. #region 团组操作权限验证 76 酒店预定模块
  16927. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16928. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16929. #endregion
  16930. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16931. #region 页面操作权限验证
  16932. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16933. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16934. #endregion
  16935. #endregion
  16936. decimal _rate = 1.00M;
  16937. string _currency = string.Empty;
  16938. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  16939. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16940. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  16941. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16942. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  16943. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  16944. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  16945. if (_GroupCostParameter == null)
  16946. {
  16947. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  16948. bool isIntType = int.TryParse(_currency, out int currId);
  16949. if (isIntType)
  16950. {
  16951. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16952. }
  16953. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16954. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16955. if (currInfo == null)
  16956. {
  16957. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16958. }
  16959. else _rate = currInfo.Rate;
  16960. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16961. {
  16962. _rate = _GroupCostParameter.Rate;
  16963. }
  16964. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16965. //string strFileName = "HotelStatement/";
  16966. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16967. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16968. var rateDatas = new List<dynamic>();
  16969. #region 数据处理
  16970. foreach (var item in hrDtas)
  16971. {
  16972. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16973. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16974. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16975. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16976. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16977. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16978. {
  16979. continue;
  16980. }
  16981. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16982. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16983. string singleRoomFeeStr = string.Empty,
  16984. doubleRoomFeeStr = string.Empty,
  16985. suiteRoomFeeStr = string.Empty,
  16986. otherRoomFeeStr = string.Empty,
  16987. payMoneyStr = string.Empty,
  16988. cardPriceStr = string.Empty;
  16989. if (roomCurr.Equals("CNY"))
  16990. {
  16991. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16992. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16993. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16994. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16995. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16996. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16997. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16998. }
  16999. else
  17000. {
  17001. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17002. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17003. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17004. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17005. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17006. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17007. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17008. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17009. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17010. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17011. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17012. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17013. if (ccpPaymentCurrency.Equals("CNY"))
  17014. {
  17015. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17016. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17017. }
  17018. else
  17019. {
  17020. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17021. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17022. }
  17023. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17024. if (hotelcardPriceCurrency.Equals("CNY"))
  17025. {
  17026. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17027. }
  17028. else
  17029. {
  17030. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17031. }
  17032. }
  17033. string breakfastPriceStr = string.Empty,
  17034. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17035. governmentRentStr = string.Empty,
  17036. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17037. cityTaxStr = string.Empty,
  17038. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17039. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17040. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17041. {
  17042. if (breakfastCurrency1.Equals("CNY"))
  17043. {
  17044. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17045. }
  17046. else
  17047. {
  17048. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17049. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17050. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17051. }
  17052. }
  17053. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17054. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17055. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17056. {
  17057. if (governmentRentCurrency.Equals("CNY"))
  17058. {
  17059. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17060. }
  17061. else
  17062. {
  17063. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17064. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17065. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17066. }
  17067. }
  17068. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17069. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17070. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17071. {
  17072. if (cityTaxStrCurrency1.Equals("CNY"))
  17073. {
  17074. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17075. }
  17076. else
  17077. {
  17078. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17079. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17080. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17081. }
  17082. }
  17083. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17084. int payDId = roomInfo?.PayDId ?? 0;
  17085. pcfds.Add(new HotelReservations_PCFD_View()
  17086. {
  17087. City = item.City,
  17088. HotelName = item.HotelName,
  17089. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17090. // SingleRoomCount = item.SingleRoomCount,
  17091. SingleRoomPrice = singleRoomFeeStr,
  17092. // DoubleRoomCount = item.DoubleRoomCount,
  17093. DoubleRoomPrice = doubleRoomFeeStr,
  17094. //SuiteRoomCount = item.SuiteRoomCount,
  17095. SuiteRoomPrice = suiteRoomFeeStr,
  17096. OtherRoomPrice = otherRoomFeeStr,
  17097. //OtherRoomCount = item.OtherRoomCount,
  17098. BreakfastPrice = breakfastPriceStr,
  17099. GovernmentRent = governmentRentStr,
  17100. CityTax = cityTaxStr,
  17101. RoomExplanation = item.RoomExplanation,
  17102. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17103. PayTime = roomInfo?.ConsumptionDate,
  17104. BankNo = roomInfo?.BankNo,
  17105. PayMoney = payMoneyStr,
  17106. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17107. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17108. CardPrice = cardPriceStr,
  17109. Remark = ccpInfo.Remark
  17110. });
  17111. }
  17112. #endregion
  17113. //载入模板
  17114. WorkbookDesigner designer = new WorkbookDesigner();
  17115. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17116. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17117. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17118. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17119. var rateDatas1 = rateDatas.Distinct();
  17120. var rateStr = string.Empty;
  17121. foreach (var item in rateDatas1)
  17122. {
  17123. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17124. }
  17125. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17126. designer.SetDataSource("Opertor", userInfo.CnName);
  17127. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17128. dt.TableName = "ViewMyHotelReservations";
  17129. designer.SetDataSource(dt);
  17130. designer.Process();
  17131. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17132. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17133. designer.Workbook.Save(serverPath);
  17134. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17135. #region 删除指定行
  17136. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17137. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17138. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17139. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17140. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17141. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17142. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17143. cssIndex = dt.Columns["CityTax"].Ordinal,
  17144. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17145. remarkIndex = dt.Columns["Remark"].Ordinal;
  17146. //删除指定列
  17147. foreach (DataRow item in dt.Rows)
  17148. {
  17149. string singleStr = item["SingleRoomPrice"].ToString();
  17150. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17151. if (containsDigitButNotZero1) singleDel = false;
  17152. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17153. string doubleStr = item["DoubleRoomPrice"].ToString();
  17154. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17155. if (containsDigitButNotZero2) doubleDel = false;
  17156. string suiteStr = item["SuiteRoomPrice"].ToString();
  17157. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17158. if (containsDigitButNotZero3) suiteDel = false;
  17159. string otherStr = item["OtherRoomPrice"].ToString();
  17160. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17161. if (containsDigitButNotZero4) otherDel = false;
  17162. string zcStr = item["BreakfastPrice"].ToString();
  17163. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17164. if (containsDigitButNotZero5) zcDel = false;
  17165. string dsStr = item["GovernmentRent"].ToString();
  17166. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17167. if (containsDigitButNotZero6) dsDel = false;
  17168. string cssStr = item["CityTax"].ToString();
  17169. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17170. if (containsDigitButNotZero7) cssDel = false;
  17171. string cpStr = item["ConsumptionPatterns"].ToString();
  17172. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17173. string remarkStr = item["Remark"].ToString();
  17174. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17175. }
  17176. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17177. DeleteColumn(serverPath, cpIndex, cpDel);
  17178. DeleteColumn(serverPath, dsIndex, dsDel);
  17179. DeleteColumn(serverPath, cssIndex, cssDel);
  17180. DeleteColumn(serverPath, zcIndex, zcDel);
  17181. DeleteColumn(serverPath, otherIndex, otherDel);
  17182. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17183. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17184. DeleteColumn(serverPath, singleIndex, singleDel);
  17185. #endregion
  17186. //只保留第一个表格
  17187. DeleteSheet(serverPath);
  17188. return Ok(JsonView(true, "操作成功", url = rst));
  17189. }
  17190. else
  17191. {
  17192. _currency = _GroupCostParameter.Currency;
  17193. bool isIntType = int.TryParse(_currency, out int currId);
  17194. if (isIntType)
  17195. {
  17196. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17197. }
  17198. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17199. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17200. if (currInfo == null)
  17201. {
  17202. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17203. }
  17204. if (!_currency.ToUpper().Equals("CNY"))
  17205. {
  17206. _rate = _GroupCostParameter.Rate;
  17207. }
  17208. _rate = currInfo.Rate;
  17209. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17210. //string strFileName = "HotelStatement/";
  17211. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17212. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17213. #region 数据处理
  17214. foreach (var item in hrDtas)
  17215. {
  17216. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17217. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17218. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17219. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17220. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17221. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17222. string singleRoomFeeStr = string.Empty,
  17223. doubleRoomFeeStr = string.Empty,
  17224. suiteRoomFeeStr = string.Empty,
  17225. otherRoomFeeStr = string.Empty,
  17226. payMoneyStr = string.Empty,
  17227. cardPriceStr = string.Empty;
  17228. if (roomCurr.Equals(_currency))
  17229. {
  17230. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  17231. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  17232. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  17233. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  17234. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  17235. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  17236. }
  17237. else
  17238. {
  17239. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17240. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17241. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17242. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17243. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17244. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17245. }
  17246. string breakfastPriceStr = string.Empty,
  17247. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17248. governmentRentStr = string.Empty,
  17249. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17250. cityTaxStrStr = string.Empty,
  17251. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17252. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  17253. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  17254. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  17255. int payDId = roomInfo?.PayDId ?? 0;
  17256. pcfds.Add(new HotelReservations_PCFD_View()
  17257. {
  17258. City = item.City,
  17259. HotelName = item.HotelName,
  17260. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17261. // SingleRoomCount = item.SingleRoomCount,
  17262. SingleRoomPrice = singleRoomFeeStr,
  17263. // DoubleRoomCount = item.DoubleRoomCount,
  17264. DoubleRoomPrice = doubleRoomFeeStr,
  17265. //SuiteRoomCount = item.SuiteRoomCount,
  17266. SuiteRoomPrice = suiteRoomFeeStr,
  17267. OtherRoomPrice = otherRoomFeeStr,
  17268. //OtherRoomCount = item.OtherRoomCount,
  17269. BreakfastPrice = breakfastPriceStr,
  17270. GovernmentRent = governmentRentStr,
  17271. CityTax = cityTaxStrStr,
  17272. RoomExplanation = item.RoomExplanation,
  17273. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17274. PayTime = roomInfo?.ConsumptionDate,
  17275. BankNo = roomInfo?.BankNo,
  17276. PayMoney = payMoneyStr,
  17277. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17278. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17279. CardPrice = cardPriceStr,
  17280. Remark = ccpInfo.Remark
  17281. });
  17282. }
  17283. #endregion
  17284. //载入模板
  17285. WorkbookDesigner designer = new WorkbookDesigner();
  17286. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17287. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17288. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17289. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17290. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  17291. designer.SetDataSource("Opertor", userInfo.CnName);
  17292. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17293. dt.TableName = "ViewMyHotelReservations";
  17294. designer.SetDataSource(dt);
  17295. designer.Process();
  17296. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17297. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17298. designer.Workbook.Save(serverPath);
  17299. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17300. #region 删除指定行
  17301. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17302. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17303. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17304. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17305. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17306. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17307. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17308. cssIndex = dt.Columns["CityTax"].Ordinal,
  17309. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17310. remarkIndex = dt.Columns["Remark"].Ordinal;
  17311. //删除指定列
  17312. foreach (DataRow item in dt.Rows)
  17313. {
  17314. string singleStr = item["SingleRoomPrice"].ToString();
  17315. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17316. if (containsDigitButNotZero1) singleDel = false;
  17317. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17318. string doubleStr = item["DoubleRoomPrice"].ToString();
  17319. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17320. if (containsDigitButNotZero2) doubleDel = false;
  17321. string suiteStr = item["SuiteRoomPrice"].ToString();
  17322. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17323. if (containsDigitButNotZero3) suiteDel = false;
  17324. string otherStr = item["OtherRoomPrice"].ToString();
  17325. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17326. if (containsDigitButNotZero4) otherDel = false;
  17327. string zcStr = item["BreakfastPrice"].ToString();
  17328. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17329. if (containsDigitButNotZero5) zcDel = false;
  17330. string dsStr = item["GovernmentRent"].ToString();
  17331. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17332. if (containsDigitButNotZero6) dsDel = false;
  17333. string cssStr = item["CityTax"].ToString();
  17334. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17335. if (containsDigitButNotZero7) cssDel = false;
  17336. string cpStr = item["ConsumptionPatterns"].ToString();
  17337. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17338. string remarkStr = item["Remark"].ToString();
  17339. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17340. }
  17341. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17342. DeleteColumn(serverPath, cpIndex, cpDel);
  17343. DeleteColumn(serverPath, dsIndex, dsDel);
  17344. DeleteColumn(serverPath, cssIndex, cssDel);
  17345. DeleteColumn(serverPath, zcIndex, zcDel);
  17346. DeleteColumn(serverPath, otherIndex, otherDel);
  17347. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17348. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17349. DeleteColumn(serverPath, singleIndex, singleDel);
  17350. #endregion
  17351. //只保留第一个表格
  17352. DeleteSheet(serverPath);
  17353. return Ok(JsonView(true, "操作成功", url = rst));
  17354. }
  17355. //return Ok(JsonView(false));
  17356. }
  17357. /// <summary>
  17358. /// 删除指定列
  17359. /// </summary>
  17360. /// <param name="file"></param>
  17361. /// <param name="columnIndex"></param>
  17362. /// <param name="isDel"></param>
  17363. private void DeleteColumn(string file, int columnIndex, bool isDel)
  17364. {
  17365. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17366. //wb.Save(file);
  17367. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  17368. if (sheet1 != null)
  17369. {
  17370. if (isDel)
  17371. {
  17372. Cells cells = sheet1.Cells;
  17373. cells.DeleteColumn(columnIndex);
  17374. }
  17375. }
  17376. wb.Save(file);
  17377. }
  17378. /// <summary>
  17379. /// 删除sheet
  17380. /// </summary>
  17381. /// <param name="file"></param>
  17382. /// <param name="sheetName"></param>
  17383. private void DeleteSheet(string file, string sheetName = "")
  17384. {
  17385. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17386. //wb.Save(file);
  17387. List<string> sheets = new List<string>();
  17388. foreach (var item in wb.Worksheets)
  17389. {
  17390. sheets.Add(item.Name);
  17391. }
  17392. if (sheets.Count > 0)
  17393. {
  17394. sheets.RemoveAt(0);//不删除第一个sheet
  17395. foreach (var item in sheets)
  17396. {
  17397. wb.Worksheets.RemoveAt(item);
  17398. }
  17399. }
  17400. wb.Save(file);
  17401. }
  17402. /// <summary>
  17403. /// 酒店预订
  17404. /// 确认单
  17405. /// </summary>
  17406. /// <param name="_dto"></param>
  17407. /// <returns></returns>
  17408. [HttpPost]
  17409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17410. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  17411. {
  17412. try
  17413. {
  17414. #region 参数验证
  17415. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17416. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17417. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17418. #region 团组操作权限验证 76 酒店预定模块
  17419. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17420. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17421. #endregion
  17422. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17423. #region 页面操作权限验证
  17424. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17425. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17426. #endregion
  17427. #endregion
  17428. //团组信息
  17429. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  17430. //酒店数据
  17431. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  17432. if (listhoteldata.Count < 0)
  17433. {
  17434. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  17435. }
  17436. //利datatable存储
  17437. DataTable dt = new DataTable();
  17438. dt.Columns.Add("CheckInDate", typeof(string));
  17439. dt.Columns.Add("City", typeof(string));
  17440. dt.Columns.Add("Hotel", typeof(string));
  17441. dt.Columns.Add("Room", typeof(string));
  17442. for (int i = 0; i < listhoteldata.Count; i++)
  17443. {
  17444. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  17445. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  17446. while (dayStart < dayEnd)
  17447. {
  17448. string temp = "";
  17449. DataRow row = dt.NewRow();
  17450. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  17451. row["City"] = listhoteldata[i].City;
  17452. row["Hotel"] = listhoteldata[i].HotelName;
  17453. if (listhoteldata[i].SingleRoomCount > 0)
  17454. {
  17455. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  17456. }
  17457. if (listhoteldata[i].DoubleRoomCount > 0)
  17458. {
  17459. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  17460. }
  17461. if (listhoteldata[i].SuiteRoomCount > 0)
  17462. {
  17463. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  17464. }
  17465. if (listhoteldata[i].OtherRoomCount > 0)
  17466. {
  17467. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  17468. }
  17469. row["Room"] = temp;
  17470. dt.Rows.Add(row);
  17471. dayStart = dayStart.AddDays(1);
  17472. }
  17473. }
  17474. Dictionary<string, string> dic = new Dictionary<string, string>();
  17475. dic.Add("Dele", di.TeamName);
  17476. dic.Add("City", di.VisitCountry);
  17477. //模板路径
  17478. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  17479. //载入模板
  17480. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  17481. DocumentBuilder builder = new DocumentBuilder(doc);
  17482. foreach (var key in dic.Keys)
  17483. {
  17484. builder.MoveToBookmark(key);
  17485. builder.Write(dic[key]);
  17486. }
  17487. //获取word里所有表格
  17488. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17489. //获取所填表格的序数
  17490. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17491. var rowStart = tableOne.Rows[0]; //获取第1行
  17492. //循环赋值
  17493. for (int i = 0; i < dt.Rows.Count; i++)
  17494. {
  17495. builder.MoveToCell(0, i + 1, 0, 0);
  17496. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  17497. builder.MoveToCell(0, i + 1, 1, 0);
  17498. builder.Write(dt.Rows[i]["City"].ToString());
  17499. builder.MoveToCell(0, i + 1, 2, 0);
  17500. builder.Write(dt.Rows[i]["Hotel"].ToString());
  17501. builder.MoveToCell(0, i + 1, 3, 0);
  17502. builder.Write(dt.Rows[i]["Room"].ToString());
  17503. }
  17504. //删除多余行
  17505. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  17506. {
  17507. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  17508. }
  17509. string strFileName = di.TeamName + "酒店确认单.doc";
  17510. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  17511. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  17512. return Ok(JsonView(true, "成功", url));
  17513. }
  17514. catch (Exception ex)
  17515. {
  17516. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  17517. }
  17518. }
  17519. #endregion
  17520. #region 团组状态
  17521. /// <summary>
  17522. /// 团组状态列表 Page
  17523. /// </summary>
  17524. /// <param name="dto">团组列表请求dto</param>
  17525. /// <returns></returns>
  17526. [HttpPost]
  17527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17528. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  17529. {
  17530. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17531. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  17532. {
  17533. string sqlWhere = string.Empty;
  17534. if (dto.IsSure == 0) //未完成
  17535. {
  17536. sqlWhere += string.Format(@" And IsSure = 0");
  17537. }
  17538. else if (dto.IsSure == 1) //已完成
  17539. {
  17540. sqlWhere += string.Format(@" And IsSure = 1");
  17541. }
  17542. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  17543. {
  17544. string tj = dto.SearchCriteria;
  17545. 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}%')",
  17546. tj, tj, tj, tj, tj);
  17547. }
  17548. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  17549. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  17550. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  17551. From (
  17552. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  17553. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  17554. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  17555. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  17556. From Grp_DelegationInfo gdi
  17557. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  17558. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  17559. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  17560. Where gdi.IsDel = 0 {0}
  17561. ) temp ", sqlWhere);
  17562. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  17563. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  17564. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  17565. }
  17566. else
  17567. {
  17568. return Ok(JsonView(false, "查询失败"));
  17569. }
  17570. }
  17571. /// <summary>
  17572. /// 团组状态
  17573. /// 设置操作完成
  17574. /// </summary>
  17575. /// <param name="dto">团组列表请求dto</param>
  17576. /// <returns></returns>
  17577. [HttpPost]
  17578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17579. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  17580. {
  17581. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17582. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  17583. {
  17584. Id = dto.Id,
  17585. IsSure = 1
  17586. };
  17587. var result = await _sqlSugar.Updateable(_DelegationInfo)
  17588. .UpdateColumns(it => new { it.IsSure })
  17589. .WhereColumns(it => new { it.Id })
  17590. .ExecuteCommandAsync();
  17591. if (result > 0)
  17592. {
  17593. return Ok(JsonView(true, "操作完成!"));
  17594. }
  17595. return Ok(JsonView(false, "操作失败!"));
  17596. }
  17597. #endregion
  17598. #region 保险费用录入
  17599. /// <summary>
  17600. /// 根据团组Id查询保险费用列表
  17601. /// </summary>
  17602. /// <param name="dto"></param>
  17603. /// <returns></returns>
  17604. [HttpPost]
  17605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17606. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  17607. {
  17608. Result groupData = await _customersRep.CustomersByDiId(dto);
  17609. if (groupData.Code != 0)
  17610. {
  17611. return Ok(JsonView(false, groupData.Msg));
  17612. }
  17613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17614. }
  17615. /// <summary>
  17616. /// 根据保险费用Id查询保险费用详细
  17617. /// </summary>
  17618. /// <param name="dto"></param>
  17619. /// <returns></returns>
  17620. [HttpPost]
  17621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17622. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  17623. {
  17624. try
  17625. {
  17626. Result groupData = await _customersRep.CustomersById(dto);
  17627. if (groupData.Code != 0)
  17628. {
  17629. return Ok(JsonView(false, groupData.Msg));
  17630. }
  17631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17632. }
  17633. catch (Exception ex)
  17634. {
  17635. return Ok(JsonView(false, ex.Message));
  17636. }
  17637. }
  17638. /// <summary>
  17639. /// 保险费用录入页面初始化绑定
  17640. /// </summary>
  17641. /// <param name="dto"></param>
  17642. /// <returns></returns>
  17643. [HttpPost]
  17644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17645. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  17646. {
  17647. try
  17648. {
  17649. Result groupData = await _customersRep.CustomersInitialize(dto);
  17650. if (groupData.Code != 0)
  17651. {
  17652. return Ok(JsonView(false, groupData.Msg));
  17653. }
  17654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17655. }
  17656. catch (Exception ex)
  17657. {
  17658. return Ok(JsonView(false, ex.Message));
  17659. }
  17660. }
  17661. /// <summary>
  17662. /// 保险费用操作(Status:1.新增,2.修改)
  17663. /// </summary>
  17664. /// <param name="dto"></param>
  17665. /// <returns></returns>
  17666. [HttpPost]
  17667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17668. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  17669. {
  17670. Result groupData = await _customersRep.OpCustomers(dto);
  17671. if (groupData.Code != 0)
  17672. {
  17673. return Ok(JsonView(false, groupData.Msg));
  17674. }
  17675. #region 应用推送
  17676. try
  17677. {
  17678. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  17679. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  17680. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  17681. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17682. //自动审核
  17683. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  17684. //2024-10-21 新增LZ UID
  17685. var userIds = new List<int>() { 21 };
  17686. string title = $"系统通知";
  17687. var diId = dto.DiId;
  17688. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17689. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17690. string content = "";
  17691. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17692. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17693. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17694. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  17695. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  17696. }
  17697. catch (Exception ex)
  17698. {
  17699. }
  17700. #endregion
  17701. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17702. }
  17703. /// <summary>
  17704. /// 保险文件上传
  17705. /// </summary>
  17706. /// <param name="file"></param>
  17707. /// <returns></returns>
  17708. [HttpPost]
  17709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17710. public async Task<IActionResult> UploadCus(IFormFile file)
  17711. {
  17712. try
  17713. {
  17714. if (file != null)
  17715. {
  17716. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17717. //文件名称
  17718. string projectFileName = file.FileName;
  17719. //上传的文件的路径
  17720. string filePath = "";
  17721. if (!Directory.Exists(fileDir))
  17722. {
  17723. Directory.CreateDirectory(fileDir);
  17724. }
  17725. //上传的文件的路径
  17726. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  17727. using (FileStream fs = System.IO.File.Create(filePath))
  17728. {
  17729. file.CopyTo(fs);
  17730. fs.Flush();
  17731. }
  17732. return Ok(JsonView(true, "上传成功!", projectFileName));
  17733. }
  17734. else
  17735. {
  17736. return Ok(JsonView(false, "上传失败!"));
  17737. }
  17738. }
  17739. catch (Exception ex)
  17740. {
  17741. return Ok(JsonView(false, "程序错误!"));
  17742. throw;
  17743. }
  17744. }
  17745. /// <summary>
  17746. /// 保险删除指定文件
  17747. /// </summary>
  17748. /// <param name="dto"></param>
  17749. /// <returns></returns>
  17750. [HttpPost]
  17751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17752. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  17753. {
  17754. try
  17755. {
  17756. string filePath = "";
  17757. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17758. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  17759. //int id = 0;
  17760. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  17761. // 删除该文件
  17762. try
  17763. {
  17764. System.IO.File.Delete(filePath);
  17765. 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()
  17766. {
  17767. Attachment = "",
  17768. }).ExecuteCommandAsync();
  17769. if (result != 0)
  17770. {
  17771. return Ok(JsonView(true, "成功!"));
  17772. }
  17773. else
  17774. {
  17775. return Ok(JsonView(false, "失败!"));
  17776. }
  17777. }
  17778. catch (Exception)
  17779. {
  17780. 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()
  17781. {
  17782. Attachment = "",
  17783. }).ExecuteCommandAsync();
  17784. if (result != 0)
  17785. {
  17786. return Ok(JsonView(true, "成功!"));
  17787. }
  17788. else
  17789. {
  17790. return Ok(JsonView(false, "失败!"));
  17791. }
  17792. }
  17793. }
  17794. catch (Exception ex)
  17795. {
  17796. return Ok(JsonView(false, "程序错误!"));
  17797. throw;
  17798. }
  17799. }
  17800. /// <summary>
  17801. /// 保险费用操作(删除)
  17802. /// </summary>
  17803. /// <param name="dto"></param>
  17804. /// <returns></returns>
  17805. [HttpPost]
  17806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17807. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  17808. {
  17809. try
  17810. {
  17811. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  17812. if (!res)
  17813. {
  17814. return Ok(JsonView(false, "删除失败"));
  17815. }
  17816. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  17817. {
  17818. IsDel = 1,
  17819. DeleteUserId = dto.DeleteUserId,
  17820. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  17821. }).ExecuteCommandAsync();
  17822. return Ok(JsonView(true, "删除成功!"));
  17823. }
  17824. catch (Exception ex)
  17825. {
  17826. return Ok(JsonView(false, "程序错误!"));
  17827. throw;
  17828. }
  17829. }
  17830. #endregion
  17831. #region 接团客户名单 PageId 104
  17832. /// <summary>
  17833. /// 接团客户名单
  17834. /// 迁移数据(慎用!)
  17835. /// </summary>
  17836. /// <returns></returns>
  17837. [HttpPost]
  17838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17839. public async Task<IActionResult> PostTourClientListChange()
  17840. {
  17841. try
  17842. {
  17843. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  17844. //var groupClinetData1
  17845. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  17846. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  17847. int updateCount = 0;
  17848. if (oldOAClientList.Count > 0)
  17849. {
  17850. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  17851. _sqlSugar.BeginTran();
  17852. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  17853. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  17854. foreach (var item in oldOAClientList)
  17855. {
  17856. int comId = 0;
  17857. string format = "yyyy-MM-dd HH:mm:ss";
  17858. string data11 = "1990-01-01 00:00";
  17859. var data1 = IsValidDate(item.OPdate, format);
  17860. if (data1) data11 = item.OPdate;
  17861. //客户公司验证
  17862. if (!string.IsNullOrEmpty(item.Company))
  17863. {
  17864. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  17865. if (clientComInfo == null) // add
  17866. {
  17867. var addInfo = new Crm_CustomerCompany()
  17868. {
  17869. CompanyAbbreviation = "",
  17870. CompanyFullName = item.Company,
  17871. Address = "",
  17872. PostCodes = "",
  17873. LastedOpUserId = item.OPer,
  17874. LastedOpDt = Convert.ToDateTime(data11),
  17875. CreateUserId = item.OPer,
  17876. CreateTime = Convert.ToDateTime(data11),
  17877. IsDel = 0
  17878. };
  17879. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  17880. if (comId1 > 0) comId = comId1;
  17881. }
  17882. else comId = clientComInfo.Id;
  17883. }
  17884. //客户人员验证
  17885. int clientId = 0;
  17886. string name = item.LastName + item.Name;
  17887. if (!string.IsNullOrEmpty(name))
  17888. {
  17889. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  17890. if (clientInfo == null)
  17891. {
  17892. DateTime? dateTime = null;
  17893. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  17894. if (isDt) dateTime = birthDayDt;
  17895. var addInfo1 = new Crm_DeleClient()
  17896. {
  17897. CrmCompanyId = comId,
  17898. DiId = -1,
  17899. LastName = item.LastName,
  17900. FirstName = item.Name,
  17901. OldName = "",
  17902. Pinyin = item.Pinyin,
  17903. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  17904. Marriage = 0,
  17905. Phone = item.Phone,
  17906. Job = item.Job,
  17907. BirthDay = dateTime
  17908. };
  17909. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  17910. if (clientId1 > 0) clientId = clientId1;
  17911. }
  17912. else clientId = clientInfo.Id;
  17913. }
  17914. if (clientId < 1)
  17915. {
  17916. continue;
  17917. }
  17918. int airType = 0;
  17919. if (item.AirType == "超经舱") airType = 459;
  17920. else if (item.AirType == "公务舱") airType = 458;
  17921. else if (item.AirType == "经济舱") airType = 460;
  17922. else if (item.AirType == "其他") airType = 565;
  17923. else if (item.AirType == "头等舱") airType = 457;
  17924. var _TourClientListEntity = new Grp_TourClientList()
  17925. {
  17926. DiId = item.Diid,
  17927. ClientId = clientId,
  17928. CreateUserId = item.OPer,
  17929. CreateTime = Convert.ToDateTime(data11),
  17930. Remark = item.Remark,
  17931. IsDel = item.Isdel,
  17932. ShippingSpaceTypeId = airType,
  17933. ShippingSpaceSpecialNeeds = item.AirRemark,
  17934. HotelSpecialNeeds = item.RoomType
  17935. };
  17936. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  17937. if (_TourClientList > 0)
  17938. {
  17939. updateCount++;
  17940. }
  17941. }
  17942. _sqlSugar.CommitTran();
  17943. }
  17944. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  17945. }
  17946. catch (Exception ex)
  17947. {
  17948. _sqlSugar.RollbackTran();
  17949. return Ok(JsonView(false, ex.Message));
  17950. }
  17951. //return Ok(JsonView(true));
  17952. }
  17953. private bool IsValidDate(string dateString, string format)
  17954. {
  17955. DateTime dateValue;
  17956. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  17957. return valid;
  17958. }
  17959. /// <summary>
  17960. /// 接团客户名单
  17961. /// 根据团组Id查询List
  17962. /// </summary>
  17963. /// <param name="_dto"></param>
  17964. /// <returns></returns>
  17965. [HttpPost]
  17966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17967. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17968. {
  17969. #region 参数验证
  17970. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17971. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17972. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17973. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17974. #region 页面操作权限验证
  17975. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17976. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17977. #endregion
  17978. #endregion
  17979. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17980. if (viewData.Code != 0)
  17981. {
  17982. return Ok(JsonView(false, viewData.Msg));
  17983. }
  17984. return Ok(JsonView(viewData.Data));
  17985. }
  17986. /// <summary>
  17987. /// 接团客户名单
  17988. /// 基础数据 Init
  17989. /// </summary>
  17990. /// <param name="_dto"></param>
  17991. /// <returns></returns>
  17992. [HttpPost]
  17993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17994. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17995. {
  17996. #region 参数验证
  17997. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17998. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17999. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18000. #region 页面操作权限验证
  18001. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18002. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18003. #endregion
  18004. #endregion
  18005. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18006. }
  18007. /// <summary>
  18008. /// 接团客户名单
  18009. /// 根据 Id查询 Details
  18010. /// </summary>
  18011. /// <param name="_dto"></param>
  18012. /// <returns></returns>
  18013. [HttpPost]
  18014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18015. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18016. {
  18017. #region 参数验证
  18018. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18019. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18020. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18021. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18022. #region 页面操作权限验证
  18023. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18024. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18025. #endregion
  18026. #endregion
  18027. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18028. if (viewData.Code != 0)
  18029. {
  18030. return Ok(JsonView(false, viewData.Msg));
  18031. }
  18032. return Ok(JsonView(viewData.Data));
  18033. }
  18034. /// <summary>
  18035. /// 接团客户名单
  18036. /// Add Or Edit
  18037. /// </summary>
  18038. /// <param name="_dto"></param>
  18039. /// <returns></returns>
  18040. [HttpPost]
  18041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18042. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18043. {
  18044. #region 参数验证
  18045. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18046. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18047. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18048. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18049. #region 页面操作权限验证
  18050. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18051. if (_dto.Id == 0) //添加
  18052. {
  18053. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18054. }
  18055. else if (_dto.Id >= 0) //修改
  18056. {
  18057. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18058. }
  18059. #endregion
  18060. #endregion
  18061. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18062. if (viewData.Code != 0)
  18063. {
  18064. return Ok(JsonView(false, viewData.Msg));
  18065. }
  18066. return Ok(JsonView(true));
  18067. }
  18068. /// <summary>
  18069. /// 接团客户名单
  18070. /// json字符串 AddMultiple(添加多个)
  18071. /// </summary>
  18072. /// <param name="_dto"></param>
  18073. /// <returns></returns>
  18074. [HttpPost]
  18075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18076. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18077. {
  18078. #region 参数验证
  18079. string jsonLabel = _dto.JsonLabel;
  18080. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18081. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18082. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18083. #region 页面操作权限验证
  18084. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18085. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18086. #endregion
  18087. #endregion
  18088. var request = new TourClientListAddMultipleDto();
  18089. request.DiId = _dto.DiId;
  18090. request.UserId = _dto.UserId;
  18091. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18092. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18093. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18094. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18095. var infos = new List<TourClientListInfo>();
  18096. foreach (var data in datas)
  18097. {
  18098. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18099. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18100. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18101. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18102. {
  18103. continue;
  18104. }
  18105. infos.Add(new TourClientListInfo()
  18106. {
  18107. IsAccompany = 1,
  18108. LastName = lastName,
  18109. FirstName = firstName,
  18110. Pinyin = lastNameEn + @"/" + firstNameEn,
  18111. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18112. CompanyFullName = data.CompanyFullName,
  18113. Job = data.Job
  18114. });
  18115. }
  18116. if (infos.Any())
  18117. {
  18118. var viewData = await _tourClientListRep._AddMultiple(request);
  18119. if (viewData.Code != 0)
  18120. {
  18121. return Ok(JsonView(false, viewData.Msg));
  18122. }
  18123. return Ok(JsonView(true));
  18124. }
  18125. return Ok(JsonView(false));
  18126. }
  18127. /// <summary>
  18128. /// 接团客户名单
  18129. /// AddMultiple(添加多个)
  18130. /// </summary>
  18131. /// <param name="_dto"></param>
  18132. /// <returns></returns>
  18133. [HttpPost]
  18134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18135. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18136. {
  18137. #region 参数验证
  18138. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18139. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18140. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18141. #region 页面操作权限验证
  18142. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18143. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18144. #endregion
  18145. #endregion
  18146. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18147. if (viewData.Code != 0)
  18148. {
  18149. return Ok(JsonView(false, viewData.Msg));
  18150. }
  18151. return Ok(JsonView(true));
  18152. }
  18153. /// <summary>
  18154. /// 接团客户名单
  18155. /// Del
  18156. /// </summary>
  18157. /// <param name="_dto"></param>
  18158. /// <returns></returns>
  18159. [HttpPost]
  18160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18161. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18162. {
  18163. #region 参数验证
  18164. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18165. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18166. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18167. #region 页面操作权限验证
  18168. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18169. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18170. #endregion
  18171. #endregion
  18172. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  18173. if (viewData.Code != 0)
  18174. {
  18175. return Ok(JsonView(false, viewData.Msg));
  18176. }
  18177. return Ok(JsonView(true));
  18178. }
  18179. /// <summary>
  18180. /// 接团客户名单
  18181. /// 文件下载 客户名单
  18182. /// </summary>
  18183. /// <param name="_dto"></param>
  18184. /// <returns></returns>
  18185. [HttpPost]
  18186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18187. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  18188. {
  18189. #region 参数验证
  18190. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18191. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18192. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  18193. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18194. #region 页面操作权限验证
  18195. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18196. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18197. #endregion
  18198. #endregion
  18199. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  18200. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  18201. From Grp_TourClientList tcl
  18202. Left Join
  18203. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  18204. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  18205. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  18206. From Crm_DeleClient dc
  18207. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  18208. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  18209. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  18210. Where dc.IsDel = 0) temp
  18211. On temp.DcId =tcl.ClientId
  18212. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  18213. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  18214. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  18215. //载入模板
  18216. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  18217. if (_dto.Language == 1)
  18218. {
  18219. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  18220. }
  18221. //载入模板
  18222. var doc = new Document(tempPath);
  18223. DocumentBuilder builder = new DocumentBuilder(doc);
  18224. //获取word里所有表格
  18225. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18226. //获取所填表格的序数
  18227. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18228. var rowStart = tableOne.Rows[0]; //获取第1行
  18229. if (_dto.Language == 0)
  18230. {
  18231. //循环赋值
  18232. for (int i = 0; i < DcList.Count; i++)
  18233. {
  18234. EncryptionProcessor.DecryptProperties(DcList[i]);
  18235. builder.MoveToCell(0, i + 1, 0, 0);
  18236. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  18237. builder.MoveToCell(0, i + 1, 1, 0);
  18238. int sex = DcList[i].Sex;
  18239. string sexStr = string.Empty;
  18240. if (sex == 0) sexStr = "男";
  18241. else if (sex == 1) sexStr = "女";
  18242. else sexStr = "未设置";
  18243. builder.Write(sexStr);
  18244. builder.MoveToCell(0, i + 1, 2, 0);
  18245. string birthDay = DcList[i].BirthDay;
  18246. string birthDayStr = string.Empty;
  18247. if (!string.IsNullOrEmpty(birthDay))
  18248. {
  18249. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  18250. }
  18251. builder.Write(birthDayStr);
  18252. builder.MoveToCell(0, i + 1, 3, 0);
  18253. string company = "";
  18254. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18255. {
  18256. company = DcList[i].CompanyFullName.ToString();
  18257. }
  18258. builder.Write(company);
  18259. builder.MoveToCell(0, i + 1, 4, 0);
  18260. builder.Write(DcList[i].Job);
  18261. }
  18262. }
  18263. else if (_dto.Language == 1)
  18264. {
  18265. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  18266. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  18267. List<string> transArrayStr = new List<string>();
  18268. string transStrRes1 = "";
  18269. for (int i = 0; i < DcList.Count; i++)
  18270. {
  18271. var dc = DcList[i];
  18272. EncryptionProcessor.DecryptProperties(dc);
  18273. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  18274. if (dc.Job.Equals("暂无")) dc.Job = "-";
  18275. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  18276. if (DcList.Count - 1 == i) transStrRes1 += str1;
  18277. else transStrRes1 += $"{str1}|";
  18278. }
  18279. //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";
  18280. string transStrRes = "";
  18281. if (transStrRes1.Length > 0)
  18282. {
  18283. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  18284. }
  18285. //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
  18286. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  18287. //List<string> transArray = new List<string> { };
  18288. List<TranslateInfo> transArray = new List<TranslateInfo>();
  18289. if (transStrRes.Contains("|"))
  18290. {
  18291. string[] transArray1 = transStrRes.Split('|');
  18292. if (transArray1.Length > 0)
  18293. {
  18294. foreach (var item in transArray1)
  18295. {
  18296. if (item.Contains("&"))
  18297. {
  18298. string[] transArray2 = item.Split('&');
  18299. int index = 0;
  18300. string companyName = "", job = "";
  18301. if (transArray2.Length > 0)
  18302. {
  18303. bool success = int.TryParse(transArray2[0].Trim(), out index);
  18304. if (1 < transArray2.Length) companyName = transArray2[1];
  18305. if (2 < transArray2.Length) job = transArray2[2];
  18306. }
  18307. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  18308. }
  18309. }
  18310. }
  18311. }
  18312. //循环赋值
  18313. for (int i = 0; i < DcList.Count; i++)
  18314. {
  18315. string PYName = "";
  18316. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  18317. {
  18318. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  18319. string PY_First = DcList[i].Pinyin.Split('/')[1];
  18320. PYName = PY_First + " " + PY_Last;
  18321. }
  18322. else
  18323. {
  18324. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  18325. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  18326. PYName = PY_First + " " + PY_Last;
  18327. }
  18328. builder.MoveToCell(0, i + 1, 0, 0);
  18329. builder.Write(PYName);
  18330. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  18331. builder.MoveToCell(0, i + 1, 1, 0);
  18332. builder.Write(sex);
  18333. DateTime birthDt;
  18334. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  18335. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  18336. builder.MoveToCell(0, i + 1, 2, 0);
  18337. builder.Write(birthday);
  18338. string company = string.Empty, job = string.Empty;
  18339. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  18340. if (dcTransInfo != null)
  18341. {
  18342. company = dcTransInfo.CompanyName;
  18343. job = dcTransInfo.Job;
  18344. }
  18345. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18346. {
  18347. //查询对照表
  18348. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  18349. if (tempCec != null)
  18350. {
  18351. company = tempCec.enName;
  18352. }
  18353. //翻译
  18354. else
  18355. {
  18356. }
  18357. }
  18358. builder.MoveToCell(0, i + 1, 3, 0);
  18359. builder.Write(company);
  18360. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  18361. {
  18362. //查询对照表
  18363. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  18364. if (tempPec != null)
  18365. {
  18366. job = tempPec.enName;
  18367. }
  18368. //翻译
  18369. else
  18370. {
  18371. }
  18372. }
  18373. builder.MoveToCell(0, i + 1, 4, 0);
  18374. builder.Write(job);
  18375. }
  18376. }
  18377. //删除多余行
  18378. while (tableOne.Rows.Count > DcList.Count + 1)
  18379. {
  18380. tableOne.Rows.RemoveAt(DcList.Count + 1);
  18381. }
  18382. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  18383. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  18384. doc.Save(fileDir);
  18385. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  18386. return Ok(JsonView(true, "操作成功!", Url));
  18387. }
  18388. private class TranslateInfo
  18389. {
  18390. public int Index { get; set; }
  18391. public string CompanyName { get; set; }
  18392. public string Job { get; set; }
  18393. }
  18394. [HttpPost]
  18395. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  18396. {
  18397. if (files.Count == 0)
  18398. {
  18399. return Ok(JsonView(false, "文件为空"));
  18400. }
  18401. KiMiApiClient KiMiApi = new KiMiApiClient();
  18402. var seedConter = await KiMiApi.UploadFilesAsync(files);
  18403. if (seedConter.Count == 0)
  18404. {
  18405. return Ok(JsonView(false, "上传结果为空!"));
  18406. }
  18407. var messages = new List<SeedMessages>
  18408. {
  18409. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  18410. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  18411. };
  18412. messages.InsertRange(1, seedConter);
  18413. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  18414. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  18415. string clients = kimiApiResult_JObject["content"].ToString();
  18416. string startStr = "```json", endStr = "```";
  18417. // 判断并清除开头部分
  18418. if (clients.StartsWith(startStr))
  18419. {
  18420. clients = clients.Remove(0, startStr.Length);
  18421. }
  18422. // 判断并清除结尾部分
  18423. if (clients.EndsWith(endStr))
  18424. {
  18425. clients = clients.Remove(clients.Length - endStr.Length);
  18426. }
  18427. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  18428. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  18429. {
  18430. {"姓", "LastName" },
  18431. {"名", "FirstName" },
  18432. {"姓名拼音", "Pinyin" },
  18433. {"性别", "Sex" },
  18434. {"单位", "CompanyFullName" },
  18435. {"职务", "Job" },
  18436. {"出生日期", "Birthday" },
  18437. };
  18438. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  18439. foreach (var item in clients_JObject)
  18440. {
  18441. BaiduClientOCRView cdc = new BaiduClientOCRView();
  18442. foreach (var field in clientFieldMap.Keys)
  18443. {
  18444. if (item.TryGetValue(field, out JToken value))
  18445. {
  18446. var getValue = value.ToString();
  18447. System.Type type = cdc.GetType();
  18448. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  18449. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  18450. propertyInfo.SetValue(cdc, propertyValue);
  18451. }
  18452. }
  18453. crmClients.Add(cdc);
  18454. }
  18455. return Ok(JsonView(new
  18456. {
  18457. fileCount = files.Count,
  18458. UploadCount = seedConter.Count,
  18459. ApiResult = clients,
  18460. CrmClients = crmClients
  18461. }));
  18462. }
  18463. #endregion
  18464. #region 团组倒推表
  18465. /// <summary>
  18466. /// 倒推表基础数据
  18467. /// Init
  18468. /// </summary>
  18469. /// <returns></returns>
  18470. [HttpPost]
  18471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18472. public async Task<IActionResult> PostInvertedListInit()
  18473. {
  18474. var viewData = await _invertedListRep._Init();
  18475. if (viewData.Code != 0)
  18476. {
  18477. return Ok(JsonView(false, viewData.Msg));
  18478. }
  18479. return Ok(JsonView(viewData.Data));
  18480. }
  18481. /// <summary>
  18482. /// 倒推表
  18483. /// Info
  18484. /// </summary>
  18485. /// <param name="dto"></param>
  18486. /// <returns></returns>
  18487. [HttpPost]
  18488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18489. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  18490. {
  18491. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  18492. if (viewData.Code != 0)
  18493. {
  18494. return Ok(JsonView(false, viewData.Msg));
  18495. }
  18496. return Ok(JsonView(viewData.Data));
  18497. }
  18498. /// <summary>
  18499. /// 倒推表
  18500. /// Create
  18501. /// </summary>
  18502. /// <param name="dto"></param>
  18503. /// <returns></returns>
  18504. [HttpPost]
  18505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18506. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  18507. {
  18508. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  18509. if (viewData.Code != 0)
  18510. {
  18511. return Ok(JsonView(false, viewData.Msg));
  18512. }
  18513. return Ok(JsonView(viewData.Data));
  18514. }
  18515. /// <summary>
  18516. /// 倒推表
  18517. /// Update
  18518. /// </summary>
  18519. /// <param name="dto"></param>
  18520. /// <returns></returns>
  18521. [HttpPost]
  18522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18523. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  18524. {
  18525. var viewData = await _invertedListRep._Update(dto);
  18526. if (viewData.Code != 0)
  18527. {
  18528. return Ok(JsonView(false, viewData.Msg));
  18529. }
  18530. return Ok(JsonView(viewData.Data));
  18531. }
  18532. /// <summary>
  18533. /// 倒推表
  18534. /// File Download
  18535. /// </summary>
  18536. /// <param name="dto"></param>
  18537. /// <returns></returns>
  18538. [HttpPost]
  18539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18540. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  18541. {
  18542. var info2 = await _invertedListRep._Info(1, dto.DiId);
  18543. if (info2.Code != 0)
  18544. {
  18545. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  18546. }
  18547. var info1 = info2.Data as InvertedListInfoView;
  18548. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  18549. string teamName = "";
  18550. if (info != null) teamName = info.TeamName;
  18551. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  18552. var doc = new Document();
  18553. var builder = new DocumentBuilder(doc);
  18554. #region old insert
  18555. ////载入模板
  18556. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  18557. //Document doc = new Document(tempPath);
  18558. //DocumentBuilder builder = new DocumentBuilder(doc);
  18559. //利用键值对存放数据
  18560. //Dictionary<string, string> dic = new Dictionary<string, string>();
  18561. //dic.Add("TeamName", teamName);
  18562. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  18563. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  18564. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  18565. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  18566. //dic.Add("SQRemark", info1.ApprovalRemark);
  18567. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  18568. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  18569. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  18570. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  18571. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  18572. //dic.Add("QZRemark", info1.VisaInformationRemark);
  18573. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  18574. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  18575. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  18576. //dic.Add("CQRemark", info1.IssueVisaRemark);
  18577. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  18578. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  18579. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  18580. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  18581. //#region 填充word模板书签内容
  18582. //foreach (var key in dic.Keys)
  18583. //{
  18584. // builder.MoveToBookmark(key);
  18585. // builder.Write(dic[key]);
  18586. //}
  18587. //#endregion
  18588. #endregion
  18589. #region New Insert
  18590. string titleFont = $"仿宋",
  18591. contentFont = $"仿宋";
  18592. var fontColor = Color.FromArgb(64, 64, 64);
  18593. //设置标题 团组名称
  18594. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18595. builder.Font.Name = titleFont;
  18596. builder.Font.Color = fontColor;
  18597. builder.Font.Size = 12;
  18598. builder.Font.Bold = true;
  18599. builder.Writeln(teamName);
  18600. //设置副标题 团组出访时间
  18601. builder.Font.Size = 12;
  18602. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  18603. builder.Writeln();
  18604. var backgroundColor = Color.FromArgb(199, 199, 199);
  18605. var table = builder.StartTable();
  18606. builder.InsertCell();
  18607. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  18608. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  18609. builder.CellFormat.Borders.LineWidth = 1;
  18610. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  18611. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  18612. builder.RowFormat.Height = 40;
  18613. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18614. builder.Font.Name = contentFont;
  18615. builder.Font.Size = 12;
  18616. builder.Font.Bold = true;
  18617. builder.Font.Color = fontColor;
  18618. builder.Write("时间");
  18619. builder.InsertCell();
  18620. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  18621. builder.Write("流程");
  18622. builder.InsertCell();
  18623. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  18624. builder.Write("说明");
  18625. builder.EndRow();
  18626. //报批资料准备
  18627. if (info1.IsSelectedAirportd)
  18628. {
  18629. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  18630. }
  18631. //报批/提供送签资料
  18632. if (info1.IsSelectedApprovalData)
  18633. {
  18634. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  18635. }
  18636. //出批件护照办理
  18637. if (info1.IsSelectedIssueApproval)
  18638. {
  18639. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  18640. }
  18641. //签证资料准备
  18642. if (info1.IsSelectedVisaInfo)
  18643. {
  18644. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  18645. }
  18646. //送签
  18647. if (info1.IsSelectedSendVisa)
  18648. {
  18649. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  18650. }
  18651. //出签
  18652. if (info1.IsSelectedIssueVisa)
  18653. {
  18654. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  18655. }
  18656. //机票
  18657. if (info1.IsSelectedAirTicket)
  18658. {
  18659. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  18660. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  18661. }
  18662. //酒店
  18663. if (info1.IsSelectedHotel)
  18664. {
  18665. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  18666. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  18667. }
  18668. //开行前会
  18669. if (info1.IsSelectedPreTripMeeting)
  18670. {
  18671. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  18672. }
  18673. //送机
  18674. if (info1.IsSelectedAirportdDropOff)
  18675. {
  18676. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  18677. }
  18678. builder.EndTable();
  18679. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  18680. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  18681. for (int i = 0; i < table.Rows.Count; i++)
  18682. {
  18683. var row = table.Rows[i];
  18684. //设置宽度
  18685. row.Cells[0].CellFormat.Width = 20.00;
  18686. row.Cells[1].CellFormat.Width = 30.00;
  18687. row.Cells[2].CellFormat.Width = 50.00;
  18688. if (i != 0)
  18689. {
  18690. //边框设置
  18691. InvertedListFileDownloadSetBorders(row.Cells, 0);
  18692. InvertedListFileDownloadSetBorders(row.Cells, 1);
  18693. InvertedListFileDownloadSetBorders(row.Cells, 2);
  18694. }
  18695. }
  18696. #region 页脚插入图片
  18697. // 创建页脚
  18698. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  18699. doc.FirstSection.HeadersFooters.Add(footer);
  18700. Paragraph para = new Paragraph(doc);
  18701. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  18702. footer.AppendChild(para);
  18703. builder.MoveTo(para);
  18704. string imagePath = "./Images/FMGJ_Log.png";
  18705. builder.InsertImage(imagePath);
  18706. #endregion
  18707. #endregion
  18708. var fileDir = AppSettingsHelper.Get("WordBasePath");
  18709. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  18710. string filePath = fileDir + $@"InvertedList/{fileName}";
  18711. doc.Save(filePath);
  18712. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  18713. return Ok(JsonView(true, "操作成功!", Url));
  18714. }
  18715. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  18716. {
  18717. var fontColor = Color.FromArgb(64, 64, 64);
  18718. builder.InsertCell();
  18719. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  18720. builder.RowFormat.Height = 40;
  18721. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18723. builder.Font.Name = fontName;
  18724. builder.Font.Size = 8;
  18725. builder.Font.Bold = true;
  18726. builder.Font.Color = fontColor;
  18727. builder.Write(dateTime);
  18728. builder.InsertCell();
  18729. builder.Font.Size = 9;
  18730. builder.Font.Bold = true;
  18731. builder.Font.Color = fontColor;
  18732. builder.Write(content);
  18733. builder.InsertCell();
  18734. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18735. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18736. builder.Font.Size = 9;
  18737. builder.Font.Bold = false;
  18738. builder.Font.Color = fontColor;
  18739. builder.Write(reamrk);
  18740. builder.EndRow();
  18741. }
  18742. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  18743. {
  18744. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  18745. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  18746. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  18747. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  18748. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  18749. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  18750. }
  18751. #endregion
  18752. #region 会务倒推表
  18753. /// <summary>
  18754. /// 会务倒推表
  18755. /// Init
  18756. /// </summary>
  18757. /// <returns></returns>
  18758. [HttpPost]
  18759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18760. public async Task<IActionResult> InforRetrogressTableInit()
  18761. {
  18762. var groupData = await _groupRepository.PostShareGroupInfos(1);
  18763. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  18764. return Ok(JsonView(false, groupData.Msg));
  18765. }
  18766. /// <summary>
  18767. /// 会务倒推表
  18768. /// ExcelDownload
  18769. /// </summary>
  18770. /// <param name="dto"></param>
  18771. /// <returns></returns>
  18772. [HttpPost]
  18773. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  18774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18775. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  18776. {
  18777. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  18778. var validatorRes = await validator.ValidateAsync(dto);
  18779. if (!validatorRes.IsValid)
  18780. {
  18781. StringBuilder sb = new StringBuilder();
  18782. foreach (var item in validatorRes.Errors)
  18783. {
  18784. sb.AppendLine(item.ErrorMessage);
  18785. }
  18786. return Ok(JsonView(false, sb.ToString()));
  18787. }
  18788. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  18789. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  18790. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  18791. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  18792. #region Excel
  18793. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  18794. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  18795. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  18796. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  18797. var fileNamePrefix = string.Empty;
  18798. if (days >= 30)
  18799. {
  18800. tempPath += $"会务工作倒推进度表(30天).xlsx";
  18801. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  18802. }
  18803. else if (days < 30 && days > 7)
  18804. {
  18805. tempPath += $"会务工作倒推进度表(15天).xlsx";
  18806. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  18807. }
  18808. else if (days <= 7)
  18809. {
  18810. tempPath += $"会务工作倒推进度表(7天).xlsx";
  18811. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  18812. }
  18813. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  18814. fileName = CommonFun.ValidFileName(fileName);
  18815. //载入模板
  18816. WorkbookDesigner designer = new WorkbookDesigner();
  18817. designer.Workbook = new Workbook(tempPath);
  18818. designer.Process();
  18819. if (!Directory.Exists(savePath))
  18820. {
  18821. Directory.CreateDirectory(savePath);
  18822. }
  18823. string serverPath = $"{savePath}{fileName}";
  18824. designer.Workbook.Save(serverPath);
  18825. string rst = $"{servicePath}{ftpPath}{fileName}";
  18826. #endregion
  18827. return Ok(JsonView(new { url = rst }));
  18828. }
  18829. #endregion
  18830. #region 三公签证费用(签证费、代办费)
  18831. /// <summary>
  18832. /// 三公签证费用(签证费、代办费)
  18833. /// List
  18834. /// </summary>
  18835. /// <returns></returns>
  18836. [HttpPost]
  18837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18838. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  18839. {
  18840. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  18841. if (_view.Code != 0)
  18842. {
  18843. return Ok(JsonView(false, _view.Msg));
  18844. }
  18845. return Ok(JsonView(true, "操作成功!", _view.Data));
  18846. }
  18847. /// <summary>
  18848. /// 三公签证费用(签证费、代办费)
  18849. /// Add Or Update
  18850. /// </summary>
  18851. /// <returns></returns>
  18852. [HttpPost]
  18853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18854. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  18855. {
  18856. var _view = await _visaFeeInfoRep._Update(_dto);
  18857. if (_view.Code != 0)
  18858. {
  18859. return Ok(JsonView(false, _view.Msg));
  18860. }
  18861. return Ok(JsonView(true, _view.Msg));
  18862. }
  18863. #endregion
  18864. #region 酒店询价
  18865. /// <summary>
  18866. /// 酒店询价
  18867. /// Init
  18868. /// </summary>
  18869. /// <returns></returns>
  18870. [HttpPost]
  18871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18872. public async Task<IActionResult> PostHotelInquiryInit()
  18873. {
  18874. var res = await _hotelInquiryRep._Init();
  18875. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18876. return Ok(JsonView(true, res.Msg, res.Data));
  18877. }
  18878. /// <summary>
  18879. /// 酒店询价
  18880. /// page Item
  18881. /// </summary>
  18882. /// <param name="_dto"></param>
  18883. /// <returns></returns>
  18884. [HttpPost]
  18885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18886. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  18887. {
  18888. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  18889. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18890. var view = res.Data as PageDataViewBase;
  18891. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  18892. }
  18893. /// <summary>
  18894. /// 酒店询价
  18895. /// info
  18896. /// </summary>
  18897. /// <param name="_dto"></param>
  18898. /// <returns></returns>
  18899. [HttpPost]
  18900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18901. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  18902. {
  18903. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  18904. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18905. return Ok(JsonView(true, res.Msg, res.Data));
  18906. }
  18907. /// <summary>
  18908. /// 酒店询价
  18909. /// Add Or Edit
  18910. /// </summary>
  18911. /// <param name="_dto"></param>
  18912. /// <returns></returns>
  18913. [HttpPost]
  18914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18915. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  18916. {
  18917. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  18918. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18919. return Ok(JsonView(true, res.Msg, res.Data));
  18920. }
  18921. /// <summary>
  18922. /// 酒店询价
  18923. /// Del
  18924. /// </summary>
  18925. /// <param name="_dto"></param>
  18926. /// <returns></returns>
  18927. [HttpPost]
  18928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18929. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  18930. {
  18931. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  18932. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18933. return Ok(JsonView(true, res.Msg, res.Data));
  18934. }
  18935. #endregion
  18936. #region 下载匹配op行程单
  18937. /// <summary>
  18938. /// 匹配op行程单
  18939. /// Init
  18940. /// </summary>
  18941. /// <param name="dto">团组列表请求dto</param>
  18942. /// <returns></returns>
  18943. [HttpPost]
  18944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18945. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  18946. {
  18947. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18948. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18949. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  18950. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  18951. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  18952. .Where(it => it.IsDel == 0)
  18953. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  18954. .OrderByDescending(it => it.VisitStartDate)
  18955. .ToList();
  18956. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  18957. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18958. var diids = groupInfos.Select(it => it.Id).ToList();
  18959. List<string> countrys = new List<string>();
  18960. foreach (var item in country)
  18961. {
  18962. var data = _groupRepository.FormartTeamName(item);
  18963. var dataArray = _groupRepository.GroupSplitCountry(data);
  18964. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18965. }
  18966. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  18967. List<string> areaArray = new List<string>(); //GetGroupCityLine
  18968. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  18969. foreach (var item in areaItem)
  18970. {
  18971. string areaStr = item.Value;
  18972. if (!string.IsNullOrEmpty(areaStr))
  18973. {
  18974. string[] str1 = areaStr.Split("-");
  18975. if (str1.Length > 0)
  18976. {
  18977. areaArray.AddRange(str1);
  18978. }
  18979. }
  18980. }
  18981. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  18982. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  18983. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  18984. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  18985. .ToList();
  18986. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  18987. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  18988. .Where(it => countriesIds.Contains(it.Id))
  18989. .Select(it => new { it.Id, Name = it.Name_CN })
  18990. .ToList();
  18991. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  18992. .Select(it => it.TeamName).ToList();
  18993. stopwatch.Stop();
  18994. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  18995. }
  18996. ///// <summary>
  18997. ///// 匹配op行程单
  18998. ///// Init 查询区域数据
  18999. ///// </summary>
  19000. ///// <param name="dto">团组列表请求dto</param>
  19001. ///// <returns></returns>
  19002. //[HttpPost]
  19003. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19004. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  19005. //{
  19006. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  19007. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  19008. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  19009. // if (string.IsNullOrEmpty(countriesDataStr))
  19010. // {
  19011. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  19012. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  19013. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  19014. // }
  19015. // else
  19016. // {
  19017. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  19018. // }
  19019. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  19020. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  19021. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  19022. // List<dynamic> childList = new List<dynamic>();
  19023. // int parentId = dto.CountriesId;
  19024. // if (provinceData.Count > 1)
  19025. // {
  19026. // foreach (var item1 in provinceData)
  19027. // {
  19028. // List<dynamic> childList1 = new List<dynamic>();
  19029. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  19030. // foreach (var item2 in citiesData1)
  19031. // {
  19032. // List<dynamic> childList2 = new List<dynamic>();
  19033. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19034. // foreach (var item3 in countiesData1)
  19035. // {
  19036. // childList2.Add(new
  19037. // {
  19038. // id = item3.Id,
  19039. // parentId = item2.Id,
  19040. // level = "district",
  19041. // name = item3.Name_CN,
  19042. // });
  19043. // }
  19044. // childList1.Add(new
  19045. // {
  19046. // id = item2.Id,
  19047. // parentId = item1.Id,
  19048. // level = "city",
  19049. // name = item2.Name_CN,
  19050. // childList = childList2
  19051. // });
  19052. // }
  19053. // childList.Add(new
  19054. // {
  19055. // id = item1.Id,
  19056. // parentId = parentId,
  19057. // level = "province",
  19058. // name = item1.Name_CN,
  19059. // childList = childList1
  19060. // });
  19061. // }
  19062. // //城市
  19063. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  19064. // foreach (var item2 in citiesData2)
  19065. // {
  19066. // List<dynamic> childList22 = new List<dynamic>();
  19067. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19068. // foreach (var item3 in countiesData1)
  19069. // {
  19070. // childList22.Add(new
  19071. // {
  19072. // id = item3.Id,
  19073. // parentId = item2.Id,
  19074. // level = "district",
  19075. // name = item3.Name_CN,
  19076. // });
  19077. // }
  19078. // childList.Add(new
  19079. // {
  19080. // id = item2.Id,
  19081. // parentId = parentId,
  19082. // level = "city",
  19083. // name = item2.Name_CN,
  19084. // childList = childList22
  19085. // });
  19086. // }
  19087. // }
  19088. // else
  19089. // {
  19090. // foreach (var item2 in citiesData)
  19091. // {
  19092. // string cname = item2.Name_CN;
  19093. // List<dynamic> childList1 = new List<dynamic>();
  19094. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19095. // foreach (var item3 in countiesData1)
  19096. // {
  19097. // childList1.Add(new
  19098. // {
  19099. // Id = item3.Id,
  19100. // parentId = item2.Id,
  19101. // level = "district",
  19102. // name = item3.Name_CN
  19103. // });
  19104. // }
  19105. // childList.Add(new
  19106. // {
  19107. // id = item2.Id,
  19108. // parentId = parentId,
  19109. // level = "city",
  19110. // name = item2.Name_CN,
  19111. // childList = childList1
  19112. // });
  19113. // }
  19114. // }
  19115. // stopwatch.Stop();
  19116. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  19117. //}
  19118. /// <summary>
  19119. /// 匹配op行程单
  19120. /// 接团信息列表 Page
  19121. /// </summary>
  19122. /// <param name="dto">团组列表请求dto</param>
  19123. /// <returns></returns>
  19124. [HttpPost]
  19125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19126. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  19127. {
  19128. var swatch = new Stopwatch();
  19129. swatch.Start();
  19130. #region 参数验证
  19131. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19132. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19133. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19134. #region 页面操作权限验证
  19135. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19136. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  19137. #endregion
  19138. #endregion
  19139. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19140. {
  19141. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  19142. //string sqlWhere = "";
  19143. if (!string.IsNullOrEmpty(dto.Country))
  19144. {
  19145. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  19146. }
  19147. if (!string.IsNullOrEmpty(dto.Area))
  19148. {
  19149. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  19150. }
  19151. if (!string.IsNullOrEmpty(dto.TeamName))
  19152. {
  19153. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  19154. }
  19155. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  19156. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  19157. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  19158. swatch.Stop();
  19159. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  19160. }
  19161. else
  19162. {
  19163. return Ok(JsonView(false, "查询失败"));
  19164. }
  19165. }
  19166. /// <summary>
  19167. /// 匹配op行程单
  19168. /// 行程单下载
  19169. /// </summary>
  19170. /// <param name="dto">团组列表请求dto</param>
  19171. /// <returns></returns>
  19172. [HttpPost]
  19173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19174. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  19175. {
  19176. #region 参数验证
  19177. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19178. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19180. #region 页面操作权限验证
  19181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19182. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  19183. #endregion
  19184. #endregion
  19185. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19186. {
  19187. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  19188. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  19189. }
  19190. else
  19191. {
  19192. return Ok(JsonView(false, "下载失败!"));
  19193. }
  19194. }
  19195. #endregion
  19196. #region 国家信息 数据 注释
  19197. //[HttpPost]
  19198. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  19199. //{
  19200. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  19201. // foreach (var item in dto)
  19202. // {
  19203. // infos.Add(new Grp_GroupsTaskAssignment()
  19204. // {
  19205. // DIId = item,
  19206. // CTId = 82,
  19207. // UId = 248,
  19208. // IsEnable = 1,
  19209. // CreateUserId = 233,
  19210. // CreateTime = DateTime.Now,
  19211. // IsDel = 0
  19212. // });
  19213. // infos.Add(new Grp_GroupsTaskAssignment()
  19214. // {
  19215. // DIId = item,
  19216. // CTId = 82,
  19217. // UId = 286,
  19218. // IsEnable = 1,
  19219. // CreateUserId = 233,
  19220. // CreateTime = DateTime.Now,
  19221. // IsDel = 0
  19222. // });
  19223. // }
  19224. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  19225. // return Ok("操作成功");
  19226. //}
  19227. //public class paramJsonDto
  19228. //{
  19229. // public List<CountriesInfo> str { get; set; }
  19230. //}
  19231. //[HttpPost]
  19232. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  19233. //{
  19234. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  19235. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  19236. // List<Sys_Cities> cities = new List<Sys_Cities>();
  19237. // List<Sys_Cities> districts = new List<Sys_Cities>();
  19238. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19239. // _sqlSugar.BeginTran();
  19240. // int countitiesIndex = 0;
  19241. // foreach (var item in dto.str)
  19242. // {
  19243. // dynamic data = item.c;
  19244. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  19245. // if (data != null)
  19246. // {
  19247. // countitiesIndex++;
  19248. // foreach (var item1 in data)
  19249. // {
  19250. // string cnname = item1.cn;
  19251. // string enname = item1.en;
  19252. // Sys_Cities provinceInfo = new Sys_Cities()
  19253. // {
  19254. // CountriesId = countriesId,
  19255. // Name_CN = cnname,
  19256. // Name_EN = enname,
  19257. // ParentId = 0,
  19258. // IsCapital = 1,
  19259. // CreateUserId = 208,
  19260. // CreateTime = DateTime.Now,
  19261. // IsDel = 0
  19262. // };
  19263. // if (item1.lv == "province") //省份
  19264. // {
  19265. // provinceInfo.Level = 1;
  19266. // int provinceId = 0;
  19267. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  19268. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  19269. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19270. // var data1 = item1.c;
  19271. // foreach (var item2 in data1)
  19272. // {
  19273. // if (item2.lv == "city")
  19274. // {
  19275. // string citycnname = item2.cn;
  19276. // string cityenname = item2.en;
  19277. // Sys_Cities cityInfo = new Sys_Cities()
  19278. // {
  19279. // CountriesId = countriesId,
  19280. // ParentId = provinceId,
  19281. // Level = 2,
  19282. // Name_CN = citycnname,
  19283. // Name_EN = cityenname,
  19284. // IsCapital = 1,
  19285. // CreateUserId = 208,
  19286. // CreateTime = DateTime.Now,
  19287. // IsDel = 0
  19288. // };
  19289. // if (item2.c != null)
  19290. // {
  19291. // int cityId = 0;
  19292. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  19293. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19294. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  19295. // foreach (var item3 in item2.c)
  19296. // {
  19297. // if (item3.lv == "district")
  19298. // {
  19299. // var districtInfo = new Sys_Cities()
  19300. // {
  19301. // CountriesId = countriesId,
  19302. // Name_CN = item3.cn,
  19303. // Name_EN = item3.en,
  19304. // Level = 3,
  19305. // ParentId = cityId,
  19306. // IsCapital = 1,
  19307. // CreateUserId = 208,
  19308. // CreateTime = DateTime.Now,
  19309. // IsDel = 0
  19310. // };
  19311. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19312. // //{
  19313. // districts.Add(districtInfo);
  19314. // //}
  19315. // }
  19316. // }
  19317. // }
  19318. // else
  19319. // {
  19320. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  19321. // //{
  19322. // cities.Add(cityInfo);
  19323. // //}
  19324. // }
  19325. // }
  19326. // }
  19327. // }
  19328. // else if (item1.lv == "city")//城市
  19329. // {
  19330. // provinceInfo.Level = 2;
  19331. // if (item1.c != null)
  19332. // {
  19333. // int cityId = 0;
  19334. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  19335. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19336. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19337. // foreach (var item3 in item1.c)
  19338. // {
  19339. // if (item3.lv == "district")
  19340. // {
  19341. // var districtInfo = new Sys_Cities()
  19342. // {
  19343. // CountriesId = countriesId,
  19344. // Name_CN = item3.cn,
  19345. // Name_EN = item3.en,
  19346. // Level = 3,
  19347. // ParentId = cityId,
  19348. // IsCapital = 1,
  19349. // CreateUserId = 208,
  19350. // CreateTime = DateTime.Now,
  19351. // IsDel = 0
  19352. // };
  19353. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19354. // //{
  19355. // districts.Add(districtInfo);
  19356. // //}
  19357. // }
  19358. // }
  19359. // }
  19360. // else
  19361. // {
  19362. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  19363. // //{
  19364. // cities.Add(provinceInfo);
  19365. // //}
  19366. // }
  19367. // }
  19368. // }
  19369. // }
  19370. // }
  19371. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  19372. // cities = cities.Distinct().ToList();
  19373. // districts = districts.Distinct().ToList();
  19374. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  19375. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  19376. // cities.AddRange(districts);
  19377. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  19378. // //_sqlSugar.RollbackTran();
  19379. // _sqlSugar.CommitTran();
  19380. // return Ok(JsonView(false, "操作成功!"));
  19381. //}
  19382. //[HttpPost]
  19383. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  19384. //{
  19385. // List<CountitiesInfo> infos = dto.MyProperty;
  19386. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  19387. // _sqlSugar.BeginTran();
  19388. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19389. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  19390. // foreach (var item in infos)
  19391. // {
  19392. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  19393. // if (countryInfo != null)
  19394. // {
  19395. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  19396. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  19397. // if (cityInfo1 != null)
  19398. // {
  19399. // cityInfo1.IsCapital = 0;
  19400. // cityInfos.Add(cityInfo1);
  19401. // }
  19402. // }
  19403. // }
  19404. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  19405. // .UpdateColumns(it => it.IsCapital)
  19406. // .WhereColumns(it => it.Id)
  19407. // .ExecuteCommand();
  19408. // //_sqlSugar.RollbackTran();
  19409. // _sqlSugar.CommitTran();
  19410. // return Ok(JsonView(false, "操作成功!"));
  19411. //}
  19412. //public class CounrtiesDto
  19413. //{
  19414. // public List<CountitiesInfo> MyProperty { get; set; }
  19415. //}
  19416. //public class CountitiesInfo
  19417. //{
  19418. // /// <summary>
  19419. // /// 圣约翰
  19420. // /// </summary>
  19421. // public string capital_name_chinese { get; set; }
  19422. // /// <summary>
  19423. // ///
  19424. // /// </summary>
  19425. // public string capital_name { get; set; }
  19426. // /// <summary>
  19427. // ///
  19428. // /// </summary>
  19429. // public string country_type { get; set; }
  19430. // /// <summary>
  19431. // /// 安提瓜和巴布达
  19432. // /// </summary>
  19433. // public string country_name_chinese { get; set; }
  19434. // /// <summary>
  19435. // /// 安提瓜和巴布达
  19436. // /// </summary>
  19437. // public string country_name_chinese_short { get; set; }
  19438. // /// <summary>
  19439. // /// 安提瓜和巴布达
  19440. // /// </summary>
  19441. // public string country_name_chinese_UN { get; set; }
  19442. // /// <summary>
  19443. // ///
  19444. // /// </summary>
  19445. // public string country_name_english_abbreviation { get; set; }
  19446. // /// <summary>
  19447. // ///
  19448. // /// </summary>
  19449. // public string country_name_english_formal { get; set; }
  19450. // /// <summary>
  19451. // ///
  19452. // /// </summary>
  19453. // public string country_name_english_UN { get; set; }
  19454. // /// <summary>
  19455. // ///
  19456. // /// </summary>
  19457. // public string continent_name { get; set; }
  19458. // /// <summary>
  19459. // ///
  19460. // /// </summary>
  19461. // public string subregion_name { get; set; }
  19462. // /// <summary>
  19463. // ///
  19464. // /// </summary>
  19465. // public string country_code2 { get; set; }
  19466. // /// <summary>
  19467. // ///
  19468. // /// </summary>
  19469. // public string country_code3 { get; set; }
  19470. // /// <summary>
  19471. // ///
  19472. // /// </summary>
  19473. // public string phone_code { get; set; }
  19474. //}
  19475. //public class CountriesInfo : BasicInfo
  19476. //{
  19477. // public List<CitiesInfo> c { get; set; }
  19478. //}
  19479. //public class CitiesInfo : BasicInfo
  19480. //{
  19481. // public List<AreaInfo> c { get; set; }
  19482. //}
  19483. //public class AreaInfo : BasicInfo
  19484. //{
  19485. // public List<AreaInfo> c { get; set; }
  19486. //}
  19487. //public class BasicInfo
  19488. //{
  19489. // public string code { get; set; }
  19490. // public string cn { get; set; }
  19491. // public string lv { get; set; }
  19492. // public string en { get; set; }
  19493. //}
  19494. #endregion
  19495. #region 查看邀请方
  19496. /// <summary>
  19497. /// 查看邀请方
  19498. /// 邀请方信息 Init
  19499. /// </summary>
  19500. /// <param name="dto"></param>
  19501. /// <returns></returns>
  19502. [HttpPost]
  19503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19504. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  19505. {
  19506. string sqlWhere = string.Empty;
  19507. if (!string.IsNullOrEmpty(dto.Search))
  19508. {
  19509. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  19510. }
  19511. string sql = string.Format($@"Select
  19512. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  19513. Id,
  19514. UnitName
  19515. From Res_InvitationOfficialActivityData
  19516. Where IsDel = 0
  19517. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  19518. RefAsync<int> total = 0;
  19519. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19520. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  19521. }
  19522. /// <summary>
  19523. /// 查看邀请方
  19524. /// 国家信息 Init
  19525. /// </summary>
  19526. /// <param name="dto"></param>
  19527. /// <returns></returns>
  19528. [HttpPost]
  19529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19530. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  19531. {
  19532. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  19533. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19534. var diids = groupInfos.Select(it => it.Id).ToList();
  19535. List<string> countrys = new List<string>();
  19536. foreach (var item in country)
  19537. {
  19538. var data = _groupRepository.FormartTeamName(item);
  19539. var dataArray = _groupRepository.GroupSplitCountry(data);
  19540. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19541. }
  19542. countrys = countrys.Distinct().ToList();
  19543. for (int i = 0; i < countrys.Count; i++)
  19544. {
  19545. string item = countrys[i];
  19546. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  19547. {
  19548. countrys.Remove(item);
  19549. i--;
  19550. }
  19551. }
  19552. RefAsync<int> total = 0;
  19553. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  19554. .Where(it => countrys.Contains(it.Name_CN))
  19555. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19556. .Select(it => new { id = it.Id, name = it.Name_CN })
  19557. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19558. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19559. }
  19560. /// <summary>
  19561. /// 查看邀请方
  19562. /// 城市信息 Init
  19563. /// </summary>
  19564. /// <param name="dto"></param>
  19565. /// <returns></returns>
  19566. [HttpPost]
  19567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19568. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  19569. {
  19570. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  19571. RefAsync<int> total = 0;
  19572. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  19573. .Where(it => it.CountriesId == dto.CountiesId)
  19574. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19575. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  19576. .Select(it => new { id = it.Id, name = it.Name_CN })
  19577. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19578. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19579. }
  19580. /// <summary>
  19581. /// 查看邀请方
  19582. /// 团组名称 Init
  19583. /// </summary>
  19584. /// <param name="dto"></param>
  19585. /// <returns></returns>
  19586. [HttpPost]
  19587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19588. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  19589. {
  19590. var watch = new Stopwatch();
  19591. watch.Start();
  19592. RefAsync<int> total = 0;
  19593. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  19594. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  19595. .Where((oa, di) => oa.IsDel == 0)
  19596. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  19597. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  19598. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  19599. .Distinct()
  19600. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19601. watch.Stop();
  19602. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  19603. }
  19604. /// <summary>
  19605. /// 查看邀请方
  19606. /// 团组 & 邀请方信息
  19607. /// </summary>
  19608. /// <param name="dto"></param>
  19609. /// <returns></returns>
  19610. [HttpPost]
  19611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19612. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  19613. {
  19614. var watch = new Stopwatch();
  19615. watch.Start();
  19616. RefAsync<int> total = 0;
  19617. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  19618. .AS("Grp_DelegationInfo")
  19619. .Includes(x => x.InvitingInfos)
  19620. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  19621. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  19622. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  19623. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  19624. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  19625. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  19626. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19627. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  19628. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  19629. infos.ForEach(x =>
  19630. {
  19631. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  19632. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  19633. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  19634. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  19635. });
  19636. watch.Stop();
  19637. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  19638. }
  19639. #endregion
  19640. #region 报批行程
  19641. /// <summary>
  19642. /// 报批行程初始化
  19643. /// </summary>
  19644. /// <param name="dto"></param>
  19645. /// <returns></returns>
  19646. [HttpPost]
  19647. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  19648. {
  19649. const int chiNumber = 5;
  19650. var jw = JsonView(false);
  19651. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  19652. var group = groupList.First();
  19653. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  19654. group = groupList.First(x => x.Id == diid);
  19655. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19656. .Where(x => x.DiId == diid && x.IsDel == 0)
  19657. .ToArray();
  19658. var count = 1;
  19659. foreach (var item in blackCodeList)
  19660. {
  19661. if (string.IsNullOrWhiteSpace(item.Title))
  19662. {
  19663. item.Title = "未设置名称数据" + count;
  19664. }
  19665. count++;
  19666. };
  19667. if (group == null)
  19668. {
  19669. jw.Msg = "暂无团组!";
  19670. return Ok(jw);
  19671. }
  19672. var data = new
  19673. {
  19674. groupList = groupList.Select(x => new
  19675. {
  19676. x.TeamName,
  19677. x.Id
  19678. }),
  19679. content = new ArrayList(),
  19680. groupInfo = new
  19681. {
  19682. group.VisitDays,
  19683. group.TourCode,
  19684. group.VisitPNumber,
  19685. group.TeamName,
  19686. group.Id,
  19687. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  19688. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  19689. },
  19690. blackCodeList = blackCodeList.Select(x => new
  19691. {
  19692. x.Title,
  19693. x.Id
  19694. }),
  19695. FileTempList = new ArrayList()
  19696. {
  19697. new { Index = 1,FileName = "旧模板" },
  19698. new { Index = 2,FileName = "省外办" },
  19699. new { Index = 3,FileName = "市外办" },
  19700. }
  19701. };
  19702. var resultArr = new ArrayList();
  19703. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  19704. #region 默认不生成行程
  19705. //if (content.Count == 0)
  19706. //{
  19707. // var stay = "-";
  19708. // var cityPath = "-";
  19709. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19710. // .Where(x => x.DiId == diid && x.IsDel == 0)
  19711. // .ToList();
  19712. // //添加城市路径以及住宿地
  19713. // //黑屏代码数据
  19714. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  19715. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19716. // {
  19717. // jw = JsonView(true, "黑屏代码有误!", data);
  19718. // return Ok(jw);
  19719. // }
  19720. // data = data with
  19721. // {
  19722. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  19723. // {
  19724. // x.Title,
  19725. // x.Id,
  19726. // }).ToArray())
  19727. // };
  19728. // foreach (DataRow row in dtBlack.Rows)
  19729. // {
  19730. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19731. // {
  19732. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  19733. // return Ok(jw);
  19734. // }
  19735. // }
  19736. // //黑屏代码获取时间区间
  19737. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19738. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19739. // _sqlSugar.BeginTran();
  19740. // for (int i = 0; i < timeArr.Count; i++)
  19741. // {
  19742. // stay = "-";
  19743. // cityPath = "-";
  19744. // DateTime NewData = DateTime.Parse(timeArr[i]);
  19745. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19746. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19747. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19748. // if (tbSelect.Length > 0)
  19749. // {
  19750. // List<string> threeCodeStr = new List<string>();
  19751. // foreach (var item in tbSelect)
  19752. // {
  19753. // var threeCode = item["Three"].ToString() ?? "";
  19754. // if (threeCode.Length == 6)
  19755. // {
  19756. // var start = threeCode.Substring(0, 3);
  19757. // var end = threeCode.Substring(3, 3);
  19758. // if (threeCodeStr.Count == 0)
  19759. // {
  19760. // threeCodeStr.Add(start);
  19761. // threeCodeStr.Add(end);
  19762. // }
  19763. // else
  19764. // {
  19765. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19766. // {
  19767. // threeCodeStr.Add(end);
  19768. // }
  19769. // else
  19770. // {
  19771. // threeCodeStr.Add(start);
  19772. // threeCodeStr.Add(end);
  19773. // }
  19774. // }
  19775. // }
  19776. // }
  19777. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19778. // var last = threeCodeStr.Last();
  19779. // foreach (var item in threeCodeStr)
  19780. // {
  19781. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19782. // if (item.Equals(last))
  19783. // {
  19784. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19785. // }
  19786. // }
  19787. // cityPath = cityPath.Trim('-');
  19788. // }
  19789. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  19790. // appro.Diid = diid ?? -1;
  19791. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19792. // appro.Id = thisId;
  19793. // appro.CreateUserId = dto.UserId;
  19794. // appro.CreateTime = DateTime.Now;
  19795. // content.Add(appro);
  19796. // }
  19797. // _sqlSugar.CommitTran();
  19798. //}
  19799. #endregion
  19800. foreach (var x in content)
  19801. {
  19802. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  19803. if (chiList.Count < chiNumber)
  19804. {
  19805. for (int i = chiList.Count; i < chiNumber; i++)
  19806. {
  19807. chiList.Add(new Grp_ApprovalTravelDetails());
  19808. }
  19809. }
  19810. resultArr.Add(new
  19811. {
  19812. x.Id,
  19813. x.Date,
  19814. x.Diid,
  19815. chiList = chiList.Select(x1 => new
  19816. {
  19817. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19818. x1.Details,
  19819. x1.ParentId,
  19820. x1.Id
  19821. })
  19822. });
  19823. }
  19824. data = data with
  19825. {
  19826. content = resultArr,
  19827. };
  19828. jw = JsonView(true, "获取成功!", data);
  19829. return Ok(jw);
  19830. }
  19831. /// <summary>
  19832. /// 报批行程删除
  19833. /// </summary>
  19834. /// <param name="dto"></param>
  19835. /// <returns></returns>
  19836. [HttpPost]
  19837. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  19838. {
  19839. var jw = JsonView(false);
  19840. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19841. if (group == null)
  19842. {
  19843. jw.Msg = "团组参数有误!";
  19844. return Ok(jw);
  19845. }
  19846. try
  19847. {
  19848. _sqlSugar.BeginTran();
  19849. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  19850. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  19851. {
  19852. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19853. DeleteUserId = dto.uesrId,
  19854. IsDel = 1
  19855. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  19856. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  19857. {
  19858. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19859. DeleteUserId = dto.uesrId,
  19860. IsDel = 1
  19861. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  19862. _sqlSugar.CommitTran();
  19863. jw = JsonView(true, "删除成功");
  19864. }
  19865. catch (Exception ex)
  19866. {
  19867. jw = JsonView(false, ex.Message);
  19868. }
  19869. return Ok(jw);
  19870. }
  19871. /// <summary>
  19872. /// 报批行程保存
  19873. /// </summary>
  19874. /// <param name="dto"></param>
  19875. /// <returns></returns>
  19876. [HttpPost]
  19877. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  19878. {
  19879. var jw = JsonView(false);
  19880. var Find = dto.Arr.Find(x => x.id == 0);
  19881. if (Find != null)
  19882. {
  19883. jw.Msg = "生成的ID为0!";
  19884. return Ok(jw);
  19885. }
  19886. foreach (var item in dto.Arr)
  19887. {
  19888. foreach (var chi in item.chiList)
  19889. {
  19890. if (chi.parentId == 0)
  19891. {
  19892. chi.parentId = item.id;
  19893. }
  19894. }
  19895. }
  19896. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  19897. _sqlSugar.BeginTran();
  19898. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  19899. {
  19900. var parentIds = dto.Arr.Select(x => x.id).ToList();
  19901. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  19902. {
  19903. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19904. DeleteUserId = dto.UserId,
  19905. IsDel = 1
  19906. }).ExecuteCommand();
  19907. }
  19908. try
  19909. {
  19910. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  19911. {
  19912. CreateTime = DateTime.Now,
  19913. CreateUserId = dto.UserId,
  19914. Details = x.details,
  19915. ParentId = x.parentId,
  19916. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19917. Remark = "",
  19918. IsDel = 0
  19919. }).ToList()).ExecuteCommand();
  19920. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  19921. {
  19922. Id = x.id,
  19923. Details = x.details,
  19924. ParentId = x.parentId,
  19925. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19926. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  19927. {
  19928. Details = x.Details,
  19929. ParentId = x.ParentId,
  19930. Time = x.Time
  19931. }).ExecuteCommand();
  19932. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  19933. {
  19934. Id = x.id,
  19935. Date = x.date,
  19936. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  19937. {
  19938. Date = x.Date
  19939. }).ExecuteCommand();
  19940. _sqlSugar.CommitTran();
  19941. jw = JsonView(true, "保存成功!");
  19942. }
  19943. catch (Exception ex)
  19944. {
  19945. _sqlSugar.RollbackTran();
  19946. jw = JsonView(false, "保存失败!" + ex.Message);
  19947. }
  19948. return Ok(jw);
  19949. }
  19950. /// <summary>
  19951. /// 报批行程生成
  19952. /// </summary>
  19953. /// <param name="dto"></param>
  19954. /// <returns></returns>
  19955. [HttpPost]
  19956. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  19957. {
  19958. var jw = JsonView(false);
  19959. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19960. if (group == null)
  19961. {
  19962. jw.Msg = "暂无该团组!";
  19963. return Ok(jw);
  19964. }
  19965. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  19966. //黑屏代码数据
  19967. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  19968. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19969. {
  19970. jw.Msg = "黑屏代码有误!";
  19971. return Ok(jw);
  19972. }
  19973. foreach (DataRow row in dtBlack.Rows)
  19974. {
  19975. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19976. {
  19977. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  19978. return Ok(jw);
  19979. }
  19980. }
  19981. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  19982. var resultArr = new ArrayList();
  19983. //if (officialActivitiesArr.Count == 0)
  19984. //{
  19985. // jw.Msg = "暂无公务出访信息!";
  19986. // return Ok(jw);
  19987. //}
  19988. try
  19989. {
  19990. _sqlSugar.BeginTran();
  19991. DeleteApprovalJourney(new
  19992. Domain.Dtos.Groups.DeleteApprovalJourney
  19993. {
  19994. Diid = dto.Diid,
  19995. uesrId = dto.Userid
  19996. });
  19997. var stay = "-";
  19998. var cityPath = "-";
  19999. var arriveCountry = string.Empty;
  20000. //添加城市路径以及住宿地
  20001. //黑屏代码获取时间区间
  20002. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20003. var empty = "【未收入该三字码!请机票同事录入】";
  20004. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20005. #region 配置公务活动时间
  20006. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  20007. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  20008. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  20009. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  20010. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  20011. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20012. {
  20013. 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" }),
  20014. 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"}),
  20015. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20016. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  20017. };
  20018. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  20019. {
  20020. 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" }),
  20021. 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"}),
  20022. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  20023. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  20024. };
  20025. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  20026. {
  20027. 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" }),
  20028. 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"}),
  20029. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  20030. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  20031. };
  20032. #endregion
  20033. var nextDayNum = 0;
  20034. for (int i = 0; i < timeArr.Count; i++)
  20035. {
  20036. stay = "-";
  20037. cityPath = "-";
  20038. var chiarr = new List<Grp_ApprovalTravelDetails>();
  20039. DateTime NewData = DateTime.Parse(timeArr[i]);
  20040. //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();
  20041. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20042. if (nextDayNum > 0)
  20043. {
  20044. nextDayNum--;
  20045. }
  20046. if (tbSelect.Length > 0)
  20047. {
  20048. List<string> threeCodeStr = new List<string>();
  20049. bool isTrade = false;
  20050. string trip = string.Empty;
  20051. foreach (var item in tbSelect)
  20052. {
  20053. if (nextDayNum == 0)
  20054. {
  20055. nextDayNum = Convert.ToInt32(item["Sign"]);
  20056. }
  20057. var airStartTime = item["StartTime"].ToString() ?? "0000";
  20058. var airEndTime = item["EndTime"].ToString() ?? "0000";
  20059. var takeOffTime = DateTime.Parse(timeArr[i]);
  20060. var fallToTime = DateTime.Parse(timeArr[i]);
  20061. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  20062. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  20063. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  20064. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  20065. if (nextDayNum > 0)
  20066. {
  20067. fallToTime = fallToTime.AddDays(nextDayNum);
  20068. }
  20069. trip = string.Empty;
  20070. var start = string.Empty;
  20071. var end = string.Empty;
  20072. var threeCode = item["Three"].ToString() ?? "";
  20073. if (threeCode.Length == 6)
  20074. {
  20075. start = threeCode.Substring(0, 3);
  20076. end = threeCode.Substring(3, 3);
  20077. if (threeCodeStr.Count == 0)
  20078. {
  20079. threeCodeStr.Add(start);
  20080. threeCodeStr.Add(end);
  20081. }
  20082. else
  20083. {
  20084. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20085. {
  20086. threeCodeStr.Add(end);
  20087. }
  20088. else
  20089. {
  20090. threeCodeStr.Add(start);
  20091. threeCodeStr.Add(end);
  20092. }
  20093. }
  20094. }
  20095. //处理机票信息
  20096. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20097. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20098. if (start_Object == null)
  20099. {
  20100. start_Object = new Res_ThreeCode()
  20101. {
  20102. AirPort = empty,
  20103. AirPort_En = empty,
  20104. City = empty,
  20105. Country = empty,
  20106. Four = empty,
  20107. Three = empty,
  20108. };
  20109. }
  20110. if (end_Object == null)
  20111. {
  20112. end_Object = new Res_ThreeCode()
  20113. {
  20114. AirPort = empty,
  20115. AirPort_En = empty,
  20116. City = empty,
  20117. Country = empty,
  20118. Four = empty,
  20119. Three = empty,
  20120. };
  20121. }
  20122. //机型判断
  20123. string airModel = item["AirModel"].ToString();
  20124. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  20125. string flightTime = item["FlightTime"].ToString();
  20126. flightTime = ParseBlackTime(flightTime);
  20127. //航班号
  20128. string flightcode = item["Fliagtcode"].ToString();
  20129. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  20130. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  20131. if (aircompany == null)
  20132. {
  20133. aircompany = new Res_AirCompany
  20134. {
  20135. CnName = hsEmpty,
  20136. EnName = hsEmpty,
  20137. ShortCode = hsEmpty,
  20138. };
  20139. }
  20140. //航班前公务安排
  20141. if (tbSelect.First().Equals(item) && i != 0)
  20142. {
  20143. foreach (var takeoff in takeoffTimes)
  20144. {
  20145. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  20146. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  20147. {
  20148. foreach (var addTime in takeoff.Item2)
  20149. {
  20150. chiarr.Add(new Grp_ApprovalTravelDetails
  20151. {
  20152. Time = addTime,
  20153. CreateTime = DateTime.Now,
  20154. CreateUserId = dto.Userid,
  20155. ParentId = 0,
  20156. Details = "公务活动"
  20157. });
  20158. }
  20159. break;
  20160. }
  20161. }
  20162. }
  20163. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  20164. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  20165. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  20166. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  20167. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  20168. if (isTrade)
  20169. {
  20170. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  20171. trip += "(转机不出机场)。";
  20172. }
  20173. //else
  20174. //{
  20175. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  20176. //}
  20177. chiarr.Add(new Grp_ApprovalTravelDetails
  20178. {
  20179. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  20180. CreateTime = DateTime.Now,
  20181. CreateUserId = dto.Userid,
  20182. ParentId = 0,
  20183. Details = trip
  20184. });
  20185. //最后一条到达的时间安排公务
  20186. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  20187. {
  20188. bool isCheckCountry = false;
  20189. if (end_Object.Country != arriveCountry)
  20190. {
  20191. arriveCountry = end_Object.Country;
  20192. isCheckCountry = true;
  20193. }
  20194. if (nextDayNum == 0)
  20195. {
  20196. //需要入境的情况
  20197. if (isCheckCountry)
  20198. {
  20199. foreach (var fallTime in fallTimesCheckCountry)
  20200. {
  20201. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20202. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20203. {
  20204. foreach (var addTime in fallTime.Item2)
  20205. {
  20206. chiarr.Add(new Grp_ApprovalTravelDetails
  20207. {
  20208. Time = addTime,
  20209. CreateTime = DateTime.Now,
  20210. CreateUserId = dto.Userid,
  20211. ParentId = 0,
  20212. Details = "公务活动"
  20213. });
  20214. }
  20215. break;
  20216. }
  20217. }
  20218. }
  20219. else
  20220. {
  20221. foreach (var fallTime in fallTimesNotCheckCountry)
  20222. {
  20223. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20224. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20225. {
  20226. foreach (var addTime in fallTime.Item2)
  20227. {
  20228. chiarr.Add(new Grp_ApprovalTravelDetails
  20229. {
  20230. Time = addTime,
  20231. CreateTime = DateTime.Now,
  20232. CreateUserId = dto.Userid,
  20233. ParentId = 0,
  20234. Details = "公务活动"
  20235. });
  20236. }
  20237. break;
  20238. }
  20239. }
  20240. }
  20241. }
  20242. }
  20243. }
  20244. //添加乘车语句
  20245. //chiarr.Add(new Grp_ApprovalTravelDetails
  20246. //{
  20247. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  20248. // CreateTime = DateTime.Now,
  20249. // CreateUserId = dto.Userid,
  20250. // ParentId = 0,
  20251. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  20252. //});
  20253. //if (i != timeArr.Count - 1)
  20254. //{
  20255. // fallToTime = fallToTime.AddHours(2.5);
  20256. // foreach (var item in Times)
  20257. // {
  20258. // //排列公务时间
  20259. // if (fallToTime.Hour < item.Item1)
  20260. // {
  20261. // chiarr.Add(new Grp_ApprovalTravelDetails
  20262. // {
  20263. // Time = $"{item.Item2} - {item.Item3}",
  20264. // CreateTime = DateTime.Now,
  20265. // CreateUserId = dto.Userid,
  20266. // ParentId = 0,
  20267. // Details = "公务活动"
  20268. // });
  20269. // }
  20270. // }
  20271. //}
  20272. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20273. var last = threeCodeStr.Last();
  20274. foreach (var item in threeCodeStr)
  20275. {
  20276. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20277. if (item.Equals(last))
  20278. {
  20279. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20280. }
  20281. }
  20282. cityPath = cityPath.Trim('-');
  20283. }
  20284. else
  20285. {
  20286. foreach (var item in Times)
  20287. {
  20288. chiarr.Add(new Grp_ApprovalTravelDetails
  20289. {
  20290. Time = $"{item.Item2} - {item.Item3}",
  20291. CreateTime = DateTime.Now,
  20292. CreateUserId = dto.Userid,
  20293. ParentId = 0,
  20294. Details = "公务活动"
  20295. });
  20296. }
  20297. }
  20298. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20299. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20300. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  20301. appro.Diid = dto.Diid;
  20302. appro.CreateUserId = dto.Userid;
  20303. appro.CreateTime = DateTime.Now;
  20304. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20305. appro.Id = thisId;
  20306. //foreach (var item in gwinfo)
  20307. //{
  20308. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  20309. // chi.Details = "拜访" + item.Client;
  20310. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  20311. // {
  20312. // chi.Details += "," + item.ReqSample;
  20313. // }
  20314. // chi.ParentId = thisId;
  20315. // chi.Time = item.Time;
  20316. // chiarr.Add(chi);
  20317. //}
  20318. if (chiarr.Count < 6)
  20319. {
  20320. for (int j = chiarr.Count; j < 6; j++)
  20321. {
  20322. chiarr.Add(new
  20323. Grp_ApprovalTravelDetails());
  20324. }
  20325. }
  20326. resultArr.Add(new
  20327. {
  20328. appro.Id,
  20329. appro.Date,
  20330. appro.Diid,
  20331. chiList = chiarr.Select(x1 => new
  20332. {
  20333. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20334. x1.Details,
  20335. x1.ParentId,
  20336. x1.Id
  20337. })
  20338. });
  20339. }
  20340. _sqlSugar.CommitTran();
  20341. jw = JsonView(true, "生成成功!", resultArr);
  20342. }
  20343. catch (Exception ex)
  20344. {
  20345. jw.Code = 400;
  20346. jw.Msg = "生成失败!" + ex.Message;
  20347. }
  20348. return Ok(jw);
  20349. }
  20350. /// <summary>
  20351. /// 报批行程word导出
  20352. /// </summary>
  20353. /// <param name="dto"></param>
  20354. /// <returns></returns>
  20355. [HttpPost]
  20356. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  20357. {
  20358. var jw = JsonView(false);
  20359. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20360. if (group == null)
  20361. {
  20362. jw.Msg = "暂无该团组!";
  20363. return Ok(jw);
  20364. }
  20365. //模板路径
  20366. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  20367. var fileName = string.Empty;
  20368. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  20369. bool bold = false;
  20370. if (dto.FileIndex == 1)
  20371. {
  20372. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  20373. }
  20374. else if (dto.FileIndex == 2)
  20375. {
  20376. fileName = "省外办-报批.docx";
  20377. bold = false;
  20378. titleFont = "方正黑体简体";
  20379. timeFont = "Times New Roman";
  20380. contentFont = "方正仿宋_GBK";
  20381. }
  20382. else if (dto.FileIndex == 3)
  20383. {
  20384. fileName = "市外办-报批.docx";
  20385. titleFont = "方正黑体简体";
  20386. timeFont = "Times New Roman";
  20387. contentFont = "方正仿宋简体";
  20388. }
  20389. tempPath = tempPath + fileName;
  20390. //载入模板
  20391. Document doc = new Document(tempPath);
  20392. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20393. //获取所填表格的序数
  20394. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20395. Aspose.Words.Tables.Row titleRowClone = null;
  20396. Aspose.Words.Tables.Row CenterRowClone = null;
  20397. int index = 0;
  20398. int indexChi = 0;
  20399. int SetIndex = 0;
  20400. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  20401. //获取数据,放到datatable
  20402. foreach (var item in ApprovalTravelArr)
  20403. {
  20404. if (index > 0)
  20405. {
  20406. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  20407. tableOne.AppendChild(titleRowClone);
  20408. }
  20409. var textTime = item.Date;
  20410. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  20411. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  20412. SetIndex++;
  20413. if (ChiRep.Count > 0)
  20414. {
  20415. foreach (var itemChi in ChiRep)
  20416. {
  20417. var txtTime = itemChi.Time;
  20418. var txtDetail = itemChi.Details;
  20419. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  20420. {
  20421. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  20422. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20423. //indexChi++;
  20424. //SetIndex++;
  20425. break;
  20426. }
  20427. if (indexChi > 0)
  20428. {
  20429. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20430. tableOne.AppendChild(CenterRowClone);
  20431. }
  20432. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  20433. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  20434. indexChi++;
  20435. SetIndex++;
  20436. }
  20437. }
  20438. //else
  20439. //{
  20440. // if (indexChi > 0)
  20441. // {
  20442. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20443. // tableOne.AppendChild(CenterRowClone);
  20444. // }
  20445. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  20446. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20447. // indexChi++;
  20448. // SetIndex++;
  20449. //}
  20450. index++;
  20451. }
  20452. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  20453. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20454. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20455. jw.Code = 200;
  20456. jw.Msg = "";
  20457. return Ok(jw);
  20458. }
  20459. private string ParseBlackTime(string time)
  20460. {
  20461. // 匹配可能只有分钟的情况
  20462. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  20463. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  20464. if (match.Success)
  20465. {
  20466. string hours = match.Groups[1].Value;
  20467. string minutes = match.Groups[2].Value;
  20468. // 如果小时部分为空,则只显示分钟
  20469. if (string.IsNullOrEmpty(hours))
  20470. {
  20471. return $"{minutes}分钟";
  20472. }
  20473. // 如果分钟部分为空,则只显示小时
  20474. else if (string.IsNullOrEmpty(minutes))
  20475. {
  20476. return $"{hours}小时";
  20477. }
  20478. // 否则显示完整格式
  20479. else
  20480. {
  20481. return $"{hours}小时{minutes}分钟";
  20482. }
  20483. }
  20484. else
  20485. {
  20486. return "未知时长";
  20487. }
  20488. }
  20489. private string intToString(int numberVal)
  20490. {
  20491. string numberval = numberVal.ToString();
  20492. Dictionary<char, string> Number = new Dictionary<char, string>();
  20493. Number.Add('1', "一");
  20494. Number.Add('2', "二");
  20495. Number.Add('3', "三");
  20496. Number.Add('4', "四");
  20497. Number.Add('5', "五");
  20498. Number.Add('6', "六");
  20499. Number.Add('7', "七");
  20500. Number.Add('8', "八");
  20501. Number.Add('9', "九");
  20502. string stringNumberVal = string.Empty;
  20503. for (int i = 0; i < numberval.Length; i++)
  20504. {
  20505. if (i == 0)
  20506. {
  20507. stringNumberVal += Number[numberval[i]];
  20508. }
  20509. else if (i >= 1)
  20510. {
  20511. if (numberval[i] == '0')
  20512. {
  20513. stringNumberVal = "十";
  20514. }
  20515. else
  20516. {
  20517. stringNumberVal += "十" + Number[numberval[i]];
  20518. }
  20519. }
  20520. }
  20521. return stringNumberVal;
  20522. }
  20523. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  20524. {
  20525. //获取table中的某个单元格,从0开始
  20526. Cell lshCell = table.Rows[rows].Cells[cells];
  20527. //将单元格中段落移除
  20528. foreach (Paragraph item in lshCell.Paragraphs)
  20529. {
  20530. lshCell.Paragraphs.Remove(item);
  20531. }
  20532. if (val.Contains("\r\n"))
  20533. {
  20534. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  20535. foreach (var item in spArr)
  20536. {
  20537. //新建一个段落
  20538. Paragraph p = new Paragraph(doc);
  20539. var r = new Run(doc, item);
  20540. //设置字体
  20541. if (!string.IsNullOrEmpty(font))
  20542. {
  20543. r.Font.Name = font;
  20544. }
  20545. r.Font.Bold = bold;
  20546. //把设置的值赋给之前新建的段落
  20547. p.AppendChild(r);
  20548. //将此段落加到单元格内
  20549. lshCell.AppendChild(p);
  20550. }
  20551. }
  20552. else
  20553. {
  20554. //新建一个段落
  20555. Paragraph p = new Paragraph(doc);
  20556. var r = new Run(doc, val);
  20557. //设置字体
  20558. if (!string.IsNullOrEmpty(font))
  20559. {
  20560. r.Font.Name = font;
  20561. }
  20562. r.Font.Bold = bold;
  20563. //把设置的值赋给之前新建的段落
  20564. p.AppendChild(r);
  20565. //将此段落加到单元格内
  20566. lshCell.AppendChild(p);
  20567. }
  20568. }
  20569. //[HttpPost]
  20570. //public async Task<IActionResult> ServerHttp(string paramStr)
  20571. //{
  20572. // paramStr = paramStr.TrimEnd('\'');
  20573. // paramStr = paramStr.TrimStart('\'');
  20574. // JsonView jw = JsonView(false);
  20575. // JObject param = JObject.Parse(paramStr);
  20576. // if (!param.ContainsKey("url"))
  20577. // {
  20578. // jw.Msg = "url null";
  20579. // return Ok(jw);
  20580. // }
  20581. // string url = param["url"]!.ToString();
  20582. // var methon = "get";
  20583. // Dictionary<string, string> headValues = null;
  20584. // string bodyStr = string.Empty;
  20585. // if (param.ContainsKey("methon"))
  20586. // {
  20587. // methon = param["methon"]!.ToString().ToLower();
  20588. // }
  20589. // if (param.ContainsKey("header"))
  20590. // {
  20591. // var header = param["header"]!.ToString();
  20592. // JObject headerJobject = JObject.Parse(header);
  20593. // headValues = new Dictionary<string, string>();
  20594. // foreach (JProperty item in headerJobject.Properties())
  20595. // {
  20596. // var value = item.Value.ToString();
  20597. // var head = item.Path;
  20598. // headValues.Add(head, value);
  20599. // }
  20600. // }
  20601. // HttpClient client = new HttpClient();
  20602. // string responseString = string.Empty;
  20603. // StringContent content = null;
  20604. // if (headValues != null)
  20605. // {
  20606. // foreach (var item in headValues.Keys)
  20607. // {
  20608. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  20609. // {
  20610. // if (param.ContainsKey("body"))
  20611. // {
  20612. // bodyStr = param["body"]!.ToString();
  20613. // }
  20614. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  20615. // }
  20616. // else
  20617. // {
  20618. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  20619. // }
  20620. // }
  20621. // }
  20622. // try
  20623. // {
  20624. // if (methon == "get")
  20625. // {
  20626. // responseString = await client.GetStringAsync(url);
  20627. // }
  20628. // else if (methon == "post")
  20629. // {
  20630. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  20631. // {
  20632. // Content = content
  20633. // };
  20634. // var response = await client.SendAsync(request);
  20635. // try
  20636. // {
  20637. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  20638. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  20639. // {
  20640. // using (StreamReader reader = new StreamReader(gzipStream))
  20641. // {
  20642. // responseString = await reader.ReadToEndAsync();
  20643. // }
  20644. // }
  20645. // }
  20646. // catch (Exception)
  20647. // {
  20648. // responseString = await response.Content.ReadAsStringAsync();
  20649. // }
  20650. // }
  20651. // else
  20652. // {
  20653. // responseString = "methon error";
  20654. // }
  20655. // jw = JsonView(true, "success", responseString);
  20656. // }
  20657. // catch (Exception ex)
  20658. // {
  20659. // jw.Msg = "error " + ex.Message;
  20660. // jw.Data = ex.StackTrace;
  20661. // }
  20662. // finally
  20663. // {
  20664. // client.Dispose();
  20665. // }
  20666. // return Ok(jw);
  20667. //}
  20668. #endregion
  20669. #region 团组接待意见调查
  20670. /// <summary>
  20671. /// 团组接待意见调查 - 信息管理
  20672. /// 基础数据(团组)
  20673. /// </summary>
  20674. /// <returns></returns>
  20675. [HttpGet]
  20676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20677. public async Task<IActionResult> OpinionaireInit()
  20678. {
  20679. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  20680. .Select(x => new
  20681. {
  20682. x.Id,
  20683. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  20684. })
  20685. .OrderByDescending(x => x.Id)
  20686. .ToListAsync();
  20687. return Ok(JsonView(groupData, groupData.Count));
  20688. }
  20689. /// <summary>
  20690. /// 团组接待意见调查 - 信息管理
  20691. /// 列表
  20692. /// </summary>
  20693. /// <param name="groupId"></param>
  20694. /// <returns></returns>
  20695. [HttpGet("{groupId}")]
  20696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20697. public async Task<IActionResult> OpinionaireManageList(int groupId)
  20698. {
  20699. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20700. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  20701. .Select(x => new
  20702. {
  20703. x.Id,
  20704. x.TourGuideName,
  20705. x.CityName,
  20706. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  20707. x.CreateTime
  20708. })
  20709. .OrderBy(x => x.Id)
  20710. .ToListAsync();
  20711. return Ok(JsonView(data));
  20712. }
  20713. /// <summary>
  20714. /// 团组接待意见调查 - 信息管理
  20715. /// 保存
  20716. /// </summary>
  20717. /// <param name="dto"></param>
  20718. /// <returns></returns>
  20719. [HttpPost]
  20720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20721. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  20722. {
  20723. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20724. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20725. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20726. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  20727. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  20728. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  20729. _opinionaireRep.BeginTran();
  20730. if (addData != null && addData.Count > 0)
  20731. {
  20732. foreach (var item in addData)
  20733. {
  20734. item.CreateUserId = currUserInfo.UserId;
  20735. item.DiId = dto.DiId;
  20736. }
  20737. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  20738. }
  20739. if (updData != null && updData.Count > 0)
  20740. {
  20741. var upd = await _opinionaireRep._sqlSugar
  20742. .Updateable(updData)
  20743. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  20744. .WhereColumns(x => new { x.Id })
  20745. .ExecuteCommandAsync();
  20746. }
  20747. _opinionaireRep.CommitTran();
  20748. return Ok(JsonView("操作成功!"));
  20749. }
  20750. /// <summary>
  20751. /// 团组接待意见调查 - 信息管理
  20752. /// 删除
  20753. /// </summary>
  20754. /// <param name="id"></param>
  20755. /// <returns></returns>
  20756. [HttpDelete("{id}")]
  20757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20758. public async Task<IActionResult> OpinionaireManageDel(int id)
  20759. {
  20760. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20761. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20762. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  20763. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  20764. if (!del) return Ok(JsonView("操作失败!"));
  20765. return Ok(JsonView("操作成功!"));
  20766. }
  20767. /// <summary>
  20768. /// 团组接待意见调查 - 用户
  20769. /// 列表
  20770. /// </summary>
  20771. /// <param name="diId"></param>
  20772. /// <returns></returns>
  20773. [HttpGet("{diId}")]
  20774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20775. public async Task<IActionResult> OpinionaireUserList(int diId)
  20776. {
  20777. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20778. var sql = string.Format(@"
  20779. SELECT
  20780. o.Id,
  20781. o.DiId,
  20782. di.TeamName AS 'GroupName',
  20783. di.VisitPNumber AS 'PeopleNumber',
  20784. di.ClientName AS 'LeadGroup',
  20785. di.VisitCountry AS 'Travel',
  20786. di.VisitDays AS 'Days',
  20787. o.CityName,
  20788. o.TourGuideName,
  20789. o.Catering,
  20790. o.CateringReason,
  20791. o.Stay,
  20792. o.StayReason,
  20793. o.[Route],
  20794. o.RouteReason,
  20795. o.OfficialActivity,
  20796. o.OfficialActivityReason,
  20797. o.TourGuide,
  20798. o.TourGuideReason,
  20799. o.[Translate],
  20800. o.TranslateReason,
  20801. o.Trip,
  20802. o.TripReason,
  20803. o.ESFileName,
  20804. o.SignatureDate,
  20805. o.Remark
  20806. FROM
  20807. Grp_Opinionaire o
  20808. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  20809. WHERE
  20810. o.IsDel = 0
  20811. AND o.DiId = {0}
  20812. ORDER BY
  20813. o.Id ASC", diId);
  20814. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  20815. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  20816. return Ok(JsonView(data));
  20817. }
  20818. /// <summary>
  20819. /// 团组接待意见调查 - 用户
  20820. /// 保存
  20821. /// </summary>
  20822. /// <param name="dto"></param>
  20823. /// <returns></returns>
  20824. [HttpPost]
  20825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20826. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  20827. {
  20828. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  20829. foreach (var item in dto)
  20830. {
  20831. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  20832. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  20833. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  20834. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  20835. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  20836. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  20837. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  20838. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  20839. }
  20840. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  20841. if (!Directory.Exists(filePathBase))
  20842. {
  20843. Directory.CreateDirectory(filePathBase);
  20844. }
  20845. #region 上传文件
  20846. var filePaths = new List<string>();
  20847. foreach (var item in dto)
  20848. {
  20849. var file = item.File;
  20850. // 将文件保存到指定位置
  20851. var filePath = Path.Combine(filePathBase, file.FileName);
  20852. using (var stream = new FileStream(filePath, FileMode.Create))
  20853. {
  20854. await file.CopyToAsync(stream);
  20855. }
  20856. //验证文件是否上传成功
  20857. if (!System.IO.File.Exists(filePath))
  20858. {
  20859. foreach (var filePathStr in filePaths)
  20860. {
  20861. System.IO.File.Delete(filePathStr);
  20862. }
  20863. return Ok(JsonView(false, "文件上传失败!"));
  20864. }
  20865. item.ESFileName = file.FileName;
  20866. }
  20867. #endregion
  20868. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  20869. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  20870. .UpdateColumns(x => new
  20871. {
  20872. x.Catering,
  20873. x.CateringReason,
  20874. x.Stay,
  20875. x.StayReason,
  20876. x.Route,
  20877. x.RouteReason,
  20878. x.OfficialActivity,
  20879. x.OfficialActivityReason,
  20880. x.TourGuide,
  20881. x.TourGuideReason,
  20882. x.Translate,
  20883. x.TranslateReason,
  20884. x.Trip,
  20885. x.TripReason,
  20886. x.ESFileName,
  20887. x.SignatureDate,
  20888. x.Remark
  20889. })
  20890. .WhereColumns(x => new { x.Id })
  20891. .ExecuteCommandAsync();
  20892. if (upd < 1)
  20893. {
  20894. foreach (var filePathStr in filePaths)
  20895. {
  20896. System.IO.File.Delete(filePathStr);
  20897. }
  20898. return Ok(JsonView(false));
  20899. }
  20900. return Ok(JsonView(true));
  20901. }
  20902. #endregion
  20903. #region 团组餐厅相关信息
  20904. /// <summary>
  20905. /// 团组相关餐厅信息
  20906. /// 基础数据(团组)
  20907. /// </summary>
  20908. /// <returns></returns>
  20909. [HttpGet]
  20910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20911. public async Task<IActionResult> RestaurantInit()
  20912. {
  20913. return Ok(await _restaurantRep.InitAsync());
  20914. }
  20915. /// <summary>
  20916. /// 团组相关餐厅信息
  20917. /// Item
  20918. /// </summary>
  20919. /// <param name="dto"></param>
  20920. /// <returns></returns>
  20921. [HttpPost]
  20922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20923. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  20924. {
  20925. int portType = dto.PortType,
  20926. groupId = dto.GroupId;
  20927. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20928. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20929. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  20930. }
  20931. /// <summary>
  20932. /// 团组相关餐厅信息
  20933. /// List
  20934. /// </summary>
  20935. /// <param name="dto"></param>
  20936. /// <returns></returns>
  20937. [HttpPost]
  20938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20939. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  20940. {
  20941. int portType = dto.PortType,
  20942. groupId = dto.GroupId;
  20943. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20944. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20945. var sql = string.Format(@" SELECT
  20946. ri.Id,
  20947. ri.GroupId,
  20948. ri.Date,
  20949. ri.StartTime,
  20950. ri.EndTime,
  20951. CASE WHEN ri.Type = 1 THEN '早餐'
  20952. WHEN ri.Type = 2 THEN '午餐'
  20953. WHEN ri.Type = 3 THEN '晚餐'
  20954. ELSE '其他'
  20955. END AS 'Type',
  20956. ri.Name,
  20957. ri.Address,
  20958. ri.Tel,
  20959. ri.Remark,
  20960. ri.CreateTime,
  20961. u.CnName AS CreateUserName
  20962. FROM
  20963. Grp_RestaurantInfo ri
  20964. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  20965. WHERE
  20966. ri.IsDel = 0
  20967. AND ri.GroupId = {0}
  20968. ORDER BY
  20969. ri.Date ASC
  20970. ", groupId);
  20971. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  20972. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  20973. return Ok(JsonView(infos));
  20974. }
  20975. /// <summary>
  20976. /// 团组相关餐厅信息
  20977. /// Info
  20978. /// </summary>
  20979. /// <param name="dto"></param>
  20980. /// <returns></returns>
  20981. [HttpPost]
  20982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20983. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  20984. {
  20985. int portType = dto.PortType,
  20986. id = dto.Id;
  20987. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20988. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20989. return Ok(await _restaurantRep.InfoAsync(portType, id));
  20990. }
  20991. /// <summary>
  20992. /// 团组相关餐厅信息
  20993. /// Op
  20994. /// </summary>
  20995. /// <param name="dto"></param>
  20996. /// <returns></returns>
  20997. [HttpPost]
  20998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20999. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  21000. {
  21001. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21002. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  21003. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  21004. return Ok(await _restaurantRep.OpAsync(dto));
  21005. }
  21006. /// <summary>
  21007. /// 团组相关餐厅信息
  21008. /// Del
  21009. /// </summary>
  21010. /// <param name="dto"></param>
  21011. /// <returns></returns>
  21012. [HttpPost]
  21013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21014. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  21015. {
  21016. int userId = dto.DeleteUserId;
  21017. var id = dto.Id;
  21018. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21019. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  21020. return Ok(await _restaurantRep.DelAsync(dto));
  21021. }
  21022. #endregion
  21023. // /// <summary>
  21024. // ///
  21025. // /// </summary>
  21026. // /// <param name="_dto"></param>
  21027. // /// <returns></returns>
  21028. // [HttpPost]
  21029. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21030. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21031. // {
  21032. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21033. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  21034. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  21035. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21036. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  21037. // dic_psg.Add("客人", 974);
  21038. // dic_psg.Add("司机", 975);
  21039. // dic_psg.Add("导游", 976);
  21040. // dic_psg.Add("公司内部人员", 977);
  21041. // dic_psg.Add("司机/导游/公司内部人员", 978);
  21042. // foreach (var item in list_visa)
  21043. // {
  21044. // Grp_VisaInfo temp = new Grp_VisaInfo();
  21045. // temp.Id = item.Id;
  21046. // temp.DIId = item.DIId;
  21047. // temp.VisaClient = item.VisaClient;
  21048. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  21049. // temp.VisaCurrency = item.VisaCurrency;
  21050. // temp.IsThird = item.IsThird;
  21051. // if (dic_psg.ContainsKey(item.PassengerType))
  21052. // {
  21053. // temp.PassengerType = dic_psg[item.PassengerType];
  21054. // }
  21055. // else {
  21056. // temp.PassengerType = -1;
  21057. // }
  21058. // temp.VisaNumber = item.VisaNumber;
  21059. // temp.VisaFreeNumber = item.VisaFreeNumber;
  21060. // temp.CreateUserId = item.Operators;
  21061. // DateTime dt_ct;
  21062. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  21063. // if (b_ct)
  21064. // {
  21065. // temp.CreateTime = dt_ct;
  21066. // }
  21067. // else
  21068. // {
  21069. // temp.CreateTime = DateTime.Now;
  21070. // }
  21071. // temp.DeleteTime = "";
  21072. // temp.DeleteUserId = 0;
  21073. // temp.Remark = item.Remark;
  21074. // if (string.IsNullOrEmpty(temp.Remark)) {
  21075. // temp.Remark = "";
  21076. // }
  21077. // temp.IsDel = item.IsDel;
  21078. // temp.VisaDescription = item.VisaAttachment;
  21079. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  21080. //([Id]
  21081. // ,[DIId]
  21082. // ,[VisaClient]
  21083. // ,[VisaPrice]
  21084. // ,[VisaCurrency]
  21085. // ,[IsThird]
  21086. // ,[PassengerType]
  21087. // ,[VisaNumber]
  21088. // ,[VisaFreeNumber]
  21089. // ,[CreateUserId]
  21090. // ,[CreateTime]
  21091. // ,[DeleteTime]
  21092. // ,[DeleteUserId]
  21093. // ,[Remark]
  21094. // ,[IsDel]
  21095. // ,[visaDescription])
  21096. // VALUES
  21097. // ({0},{1},'{2}',{3},{4}
  21098. //,{5},{6},{7},{8},{9}
  21099. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  21100. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  21101. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  21102. //);
  21103. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  21104. // }
  21105. // return Ok(JsonView(true, "操作成功!"));
  21106. // }
  21107. /// <summary>
  21108. /// 123132123
  21109. /// </summary>
  21110. /// <param name="_dto"></param>
  21111. /// <returns></returns>
  21112. [HttpPost]
  21113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21114. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21115. {
  21116. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21117. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  21118. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  21119. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21120. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  21121. dicDetail.Add(789, 1034);
  21122. dicDetail.Add(790, 1035);
  21123. dicDetail.Add(791, 1036);
  21124. dicDetail.Add(792, 1037);
  21125. dicDetail.Add(793, 1038);
  21126. dicDetail.Add(794, 1039);
  21127. dicDetail.Add(795, 1040);
  21128. dicDetail.Add(796, 1041);
  21129. dicDetail.Add(797, 1042);
  21130. dicDetail.Add(798, 1043);
  21131. dicDetail.Add(801, 1044);
  21132. dicDetail.Add(802, 1045);
  21133. dicDetail.Add(803, 1046);
  21134. Dictionary<int, int> dic = new Dictionary<int, int>();
  21135. dic.Add(806, 1027);
  21136. dic.Add(807, 1028);
  21137. dic.Add(808, 1029);
  21138. dic.Add(809, 1030);
  21139. dic.Add(810, 1031);
  21140. dic.Add(811, 1032);
  21141. dic.Add(812, 1033);
  21142. foreach (var item in list_visa)
  21143. {
  21144. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  21145. temp.Coefficient = item.coefficient;
  21146. DateTime dtCrt;
  21147. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  21148. if (b1)
  21149. {
  21150. temp.CreateTime = dtCrt;
  21151. }
  21152. else
  21153. {
  21154. temp.CreateTime = DateTime.Now;
  21155. }
  21156. temp.CreateUserId = item.Operators;
  21157. temp.DeleteTime = "";
  21158. temp.DeleteUserId = 0;
  21159. temp.DiId = int.Parse(item.DIID);
  21160. temp.FilePath = item.FilePath;
  21161. temp.IsDel = item.IsDel;
  21162. temp.Price = item.Price;
  21163. temp.PriceCount = 1;
  21164. temp.PriceCurrency = item.Currency;
  21165. int detailId = 0;
  21166. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  21167. {
  21168. detailId = dicDetail[item.PriceTypeDetail];
  21169. }
  21170. temp.PriceDetailType = detailId;
  21171. temp.PriceDt = DateTime.Now;
  21172. temp.PriceName = item.PriceName;
  21173. temp.PriceSum = item.Price;
  21174. int tid = 0;
  21175. if (dic.ContainsKey(item.PriceType))
  21176. {
  21177. tid = dic[item.PriceType];
  21178. }
  21179. temp.PriceType = tid;
  21180. temp.Remark = item.Remark;
  21181. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  21182. }
  21183. return Ok(JsonView(true, "操作成功!"));
  21184. }
  21185. [HttpPost]
  21186. public IActionResult TimeTest()
  21187. {
  21188. var jw = JsonView(false, "error");
  21189. _sqlSugar.BeginTran();
  21190. try
  21191. {
  21192. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  21193. .Select(x => new Crm_NewClientData
  21194. {
  21195. Id = x.Id,
  21196. Client = x.Client,
  21197. Contact = x.Contact,
  21198. Location = x.Location,
  21199. })
  21200. .ToList();
  21201. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  21202. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  21203. Stopwatch stopwatch = new Stopwatch();
  21204. // 开始计时
  21205. stopwatch.Start();
  21206. foreach (var item in clientList)
  21207. {
  21208. EncryptionProcessor.DecryptProperties(item);
  21209. }
  21210. stopwatch.Stop();
  21211. jw.Code = 200;
  21212. jw.Data = stopwatch.ElapsedMilliseconds;
  21213. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  21214. }
  21215. catch (Exception ex)
  21216. {
  21217. jw.Code = 400;
  21218. jw.Msg = ex.Message;
  21219. }
  21220. return Ok(jw);
  21221. }
  21222. }
  21223. }