GroupsController.cs 1.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using EyeSoft.Runtime.InteropServices;
  7. using Microsoft.AspNetCore.SignalR;
  8. using Microsoft.IdentityModel.Tokens;
  9. using Microsoft.VisualBasic;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetTaste;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.SS.Formula.Functions;
  14. using NPOI.SS.UserModel;
  15. using NPOI.SS.Util;
  16. using NPOI.XSSF.UserModel;
  17. using OASystem.API.Middlewares;
  18. using OASystem.API.OAMethodLib;
  19. using OASystem.API.OAMethodLib.APNs;
  20. using OASystem.API.OAMethodLib.File;
  21. using OASystem.API.OAMethodLib.Hub.HubClients;
  22. using OASystem.API.OAMethodLib.Hub.Hubs;
  23. using OASystem.API.OAMethodLib.JuHeAPI;
  24. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  25. using OASystem.Domain.AesEncryption;
  26. using OASystem.Domain.Attributes;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Entities.Customer;
  32. using OASystem.Domain.Entities.Financial;
  33. using OASystem.Domain.Entities.Groups;
  34. using OASystem.Domain.ViewModels.Financial;
  35. using OASystem.Domain.ViewModels.Groups;
  36. using OASystem.Domain.ViewModels.QiYeWeChat;
  37. using OASystem.Domain.ViewModels.Statistics;
  38. using OASystem.Infrastructure.Repositories.CRM;
  39. using OASystem.Infrastructure.Repositories.Financial;
  40. using OASystem.Infrastructure.Repositories.Groups;
  41. using OASystem.Infrastructure.Tools;
  42. using Org.BouncyCastle.Crypto;
  43. using Org.BouncyCastle.Utilities;
  44. using Quartz.Util;
  45. using SqlSugar.Extensions;
  46. using System.Collections;
  47. using System.Data;
  48. using System.Diagnostics;
  49. using System.Globalization;
  50. using System.IO.Compression;
  51. using System.Text.Json;
  52. using System.Web;
  53. using System.Xml.Linq;
  54. using TencentCloud.Ocr.V20181119.Models;
  55. using static OASystem.API.OAMethodLib.JWTHelper;
  56. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  57. using Bookmark = Aspose.Words.Bookmark;
  58. using Cell = Aspose.Words.Tables.Cell;
  59. using Table = Aspose.Words.Tables.Table;
  60. namespace OASystem.API.Controllers
  61. {
  62. /// <summary>
  63. /// 团组相关
  64. /// </summary>
  65. //[Authorize]
  66. [Route("api/[controller]/[action]")]
  67. public class GroupsController : ControllerBase
  68. {
  69. private readonly ILogger<GroupsController> _logger;
  70. private readonly GrpScheduleRepository _grpScheduleRep;
  71. private readonly IMapper _mapper;
  72. private readonly DelegationInfoRepository _groupRepository;
  73. private readonly TaskAssignmentRepository _taskAssignmentRep;
  74. private readonly AirTicketResRepository _airTicketResRep;
  75. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  76. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  77. private readonly DelegationEnDataRepository _delegationEnDataRep;
  78. private readonly DelegationVisaRepository _delegationVisaRep;
  79. private readonly VisaPriceRepository _visaPriceRep;
  80. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  81. private readonly HotelPriceRepository _hotelPriceRep;
  82. private readonly CustomersRepository _customersRep;
  83. private readonly MessageRepository _message;
  84. private readonly SqlSugarClient _sqlSugar;
  85. private readonly TourClientListRepository _tourClientListRep;
  86. private readonly TeamRateRepository _teamRateRep;
  87. #region 成本相关
  88. private readonly CheckBoxsRepository _checkBoxs;
  89. private readonly GroupCostRepository _GroupCostRepository;
  90. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  91. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  92. #endregion
  93. private readonly SetDataRepository _setDataRep;
  94. private string url;
  95. private string path;
  96. private readonly EnterExitCostRepository _enterExitCostRep;
  97. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  98. private readonly UsersRepository _usersRep;
  99. private readonly IJuHeApiService _juHeApi;
  100. private readonly InvertedListRepository _invertedListRep;
  101. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  102. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  103. private readonly ThreeCodeRepository _threeCodeRepository;
  104. private readonly HotelInquiryRepository _hotelInquiryRep;
  105. private readonly FeeAuditRepository _feeAuditRep;
  106. private readonly VisaCommissionRepository _visaCommissionRep;
  107. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  108. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  109. private readonly List<CurrencyInfo> _currencyInit;
  110. private readonly List<int> _portTypeData;
  111. private readonly TableOperationRecordRepository _tableorRep;
  112. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  113. private readonly RestaurantRepository _restaurantRep;
  114. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  115. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  116. /// <summary>
  117. /// 构造函数
  118. /// </summary>
  119. /// <param name="logger"></param>
  120. /// <param name="mapper"></param>
  121. /// <param name="hubContext"></param>
  122. /// <param name="sqlSugar"></param>
  123. /// <param name="grpScheduleRep"></param>
  124. /// <param name="groupRepository"></param>
  125. /// <param name="taskAssignmentRep"></param>
  126. /// <param name="airTicketResRep"></param>
  127. /// <param name="decreasePaymentsRep"></param>
  128. /// <param name="InvitationOfficialActivitiesRep"></param>
  129. /// <param name="delegationEnDataRep"></param>
  130. /// <param name="enterExitCostRep"></param>
  131. /// <param name="delegationVisaRep"></param>
  132. /// <param name="message"></param>
  133. /// <param name="visaPriceRep"></param>
  134. /// <param name="carTouristGuideGroundRep"></param>
  135. /// <param name="checkBoxs"></param>
  136. /// <param name="GroupCostRepository"></param>
  137. /// <param name="CostTypeHotelNumberRepository"></param>
  138. /// <param name="GroupCostParameterRepository"></param>
  139. /// <param name="hotelPriceRep"></param>
  140. /// <param name="customersRep"></param>
  141. /// <param name="setDataRep"></param>
  142. /// <param name="tourClientListRep"></param>
  143. /// <param name="teamRateRep"></param>
  144. /// <param name="usersRep"></param>
  145. /// <param name="juHeApi"></param>
  146. /// <param name="invertedListRep"></param>
  147. /// <param name="visaFeeInfoRep"></param>
  148. /// <param name="ticketBlackCodeRep"></param>
  149. /// <param name="hotelInquiryRep"></param>
  150. /// <param name="threeCodeRepository"></param>
  151. /// <param name="feeAuditRep"></param>
  152. /// <param name="visaCommissionRep"></param>
  153. /// <param name="ffrRep"></param>
  154. /// <param name="opinionaireRep"></param>
  155. /// <param name="tableorRep"></param>
  156. /// <param name="enterExitCostDraftRep"></param>
  157. /// <param name="restaurantRep"></param>
  158. /// <param name="enterExitCostQuoteRep"></param>
  159. public GroupsController(
  160. ILogger<GroupsController> logger,
  161. IMapper mapper,
  162. IHubContext<ChatHub, IChatClient> hubContext,
  163. SqlSugarClient sqlSugar,
  164. GrpScheduleRepository grpScheduleRep,
  165. DelegationInfoRepository groupRepository,
  166. TaskAssignmentRepository taskAssignmentRep,
  167. AirTicketResRepository airTicketResRep,
  168. DecreasePaymentsRepository decreasePaymentsRep,
  169. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  170. DelegationEnDataRepository delegationEnDataRep,
  171. EnterExitCostRepository enterExitCostRep,
  172. DelegationVisaRepository delegationVisaRep,
  173. MessageRepository message,
  174. VisaPriceRepository visaPriceRep,
  175. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  176. CheckBoxsRepository checkBoxs,
  177. GroupCostRepository GroupCostRepository,
  178. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  179. GroupCostParameterRepository GroupCostParameterRepository,
  180. HotelPriceRepository hotelPriceRep,
  181. CustomersRepository customersRep,
  182. SetDataRepository setDataRep,
  183. TourClientListRepository tourClientListRep,
  184. TeamRateRepository teamRateRep,
  185. UsersRepository usersRep, IJuHeApiService juHeApi,
  186. InvertedListRepository invertedListRep,
  187. VisaFeeInfoRepository visaFeeInfoRep,
  188. TicketBlackCodeRepository ticketBlackCodeRep,
  189. HotelInquiryRepository hotelInquiryRep,
  190. ThreeCodeRepository threeCodeRepository,
  191. FeeAuditRepository feeAuditRep,
  192. VisaCommissionRepository visaCommissionRep,
  193. ForeignReceivablesRepository ffrRep,
  194. OpinionaireRepository opinionaireRep,
  195. TableOperationRecordRepository tableorRep,
  196. EnterExitCostDraftRepository enterExitCostDraftRep,
  197. RestaurantRepository restaurantRep,
  198. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  199. GroupOrderPreInfoRepository grpOrderPreInfoRep
  200. )
  201. {
  202. _logger = logger;
  203. _mapper = mapper;
  204. _grpScheduleRep = grpScheduleRep;
  205. _groupRepository = groupRepository;
  206. _taskAssignmentRep = taskAssignmentRep;
  207. _airTicketResRep = airTicketResRep;
  208. _sqlSugar = sqlSugar;
  209. url = AppSettingsHelper.Get("ExcelBaseUrl");
  210. path = AppSettingsHelper.Get("ExcelBasePath");
  211. if (!System.IO.Directory.Exists(path))
  212. {
  213. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  214. }
  215. _decreasePaymentsRep = decreasePaymentsRep;
  216. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  217. _delegationEnDataRep = delegationEnDataRep;
  218. _enterExitCostRep = enterExitCostRep;
  219. _delegationVisaRep = delegationVisaRep;
  220. _message = message;
  221. _visaPriceRep = visaPriceRep;
  222. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  223. _checkBoxs = checkBoxs;
  224. _GroupCostRepository = GroupCostRepository;
  225. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  226. _GroupCostParameterRepository = GroupCostParameterRepository;
  227. _hotelPriceRep = hotelPriceRep;
  228. _customersRep = customersRep;
  229. _setDataRep = setDataRep;
  230. _tourClientListRep = tourClientListRep;
  231. _teamRateRep = teamRateRep;
  232. _hubContext = hubContext;
  233. _usersRep = usersRep;
  234. _juHeApi = juHeApi;
  235. _invertedListRep = invertedListRep;
  236. _visaFeeInfoRep = visaFeeInfoRep;
  237. _ticketBlackCodeRep = ticketBlackCodeRep;
  238. _hotelInquiryRep = hotelInquiryRep;
  239. _threeCodeRepository = threeCodeRepository;
  240. _feeAuditRep = feeAuditRep;
  241. _visaCommissionRep = visaCommissionRep;
  242. _ffrRep = ffrRep;
  243. _opinionaireRep = opinionaireRep;
  244. _currencyInit = new List<CurrencyInfo>()
  245. {
  246. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  247. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  248. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  249. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  250. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  251. };
  252. _portTypeData = new List<int>() { 2, 3 };
  253. _tableorRep = tableorRep;
  254. _enterExitCostDraftRep = enterExitCostDraftRep;
  255. _restaurantRep = restaurantRep;
  256. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  257. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  258. }
  259. #region 流程管控
  260. /// <summary>
  261. /// 获取团组流程管控信息
  262. /// </summary>
  263. /// <param name="_jsonDto"></param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  267. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  268. {
  269. if (string.IsNullOrEmpty(_jsonDto.Paras))
  270. {
  271. return Ok(JsonView(false, "参数为空"));
  272. }
  273. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  274. if (_ScheduleDto != null)
  275. {
  276. if (_ScheduleDto.SearchType == 2)//获取列表
  277. {
  278. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  279. return Ok(JsonView(_grpScheduleViewList));
  280. }
  281. else//获取对象
  282. {
  283. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  284. if (_grpScheduleView != null)
  285. {
  286. return Ok(JsonView(_grpScheduleView));
  287. }
  288. }
  289. }
  290. else
  291. {
  292. return Ok(JsonView(false, "参数反序列化失败"));
  293. }
  294. return Ok(JsonView(false, "暂无数据!"));
  295. }
  296. /// <summary>
  297. /// 修改团组流程管控详细表数据
  298. /// </summary>
  299. /// <param name="dto"></param>
  300. /// <returns></returns>
  301. [HttpPost]
  302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  303. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  304. {
  305. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  306. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  307. .SetColumns(it => it.Duty == _detail.Duty)
  308. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  309. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  310. .SetColumns(it => it.JobContent == _detail.JobContent)
  311. .SetColumns(it => it.Remark == _detail.Remark)
  312. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  313. .Where(s => s.Id == dto.Id)
  314. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  315. .ExecuteCommandAsync();
  316. if (result > 0)
  317. {
  318. return Ok(JsonView(true, "保存成功!"));
  319. }
  320. return Ok(JsonView(false, "保存失败!"));
  321. }
  322. /// <summary>
  323. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  324. /// </summary>
  325. /// <param name="dto"></param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  330. {
  331. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  332. _detail.IsDel = 1;
  333. _detail.DeleteUserId = dto.Duty;
  334. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  335. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  336. .SetColumns(it => it.IsDel == _detail.IsDel)
  337. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  338. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  339. .Where(it => it.Id == dto.Id)
  340. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  341. //.WhereColumns(s => s.Id == dto.Id)
  342. .ExecuteCommandAsync();
  343. if (result > 0)
  344. {
  345. return Ok(JsonView(true, "删除成功!"));
  346. }
  347. return Ok(JsonView(false, "删除失败!"));
  348. }
  349. /// <summary>
  350. /// 增加团组流程管控详细表数据
  351. /// </summary>
  352. /// <param name="dto"></param>
  353. /// <returns></returns>
  354. [HttpPost]
  355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  356. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  357. {
  358. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  359. if (DateTime.Now < _detail.ExpectBeginDt)
  360. {
  361. _detail.StepStatus = 0;
  362. }
  363. else
  364. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  365. _detail.StepStatus = 1;
  366. }
  367. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  368. if (result > 0)
  369. {
  370. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  371. return Ok(JsonView(true, "添加成功!", _result));
  372. }
  373. return Ok(JsonView(false, "添加失败!"));
  374. }
  375. #endregion
  376. #region 团组前期信息
  377. /// <summary>
  378. /// 团组前期信息 Init
  379. /// </summary>
  380. /// <returns></returns>
  381. [HttpGet]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> GroupOrderPreInfo()
  384. {
  385. return Ok(await _grpOrderPreInfoRep.DataInit());
  386. }
  387. /// <summary>
  388. /// 国家数据源
  389. /// </summary>
  390. /// <returns></returns>
  391. [HttpGet]
  392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  393. public async Task<IActionResult> CountryInit()
  394. {
  395. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  396. return Ok(JsonView(countrys));
  397. }
  398. /// <summary>
  399. /// 城市数据源
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpGet("{countryLabel}")]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> CityByCountry(string countryLabel)
  405. {
  406. countryLabel=HttpUtility.UrlDecode(countryLabel);
  407. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  408. var citys = Array.Empty<string?>();
  409. if (countryList.Any())
  410. {
  411. var cityDatas = await _sqlSugar
  412. .Queryable<Grp_NationalTravelFee>()
  413. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  414. .ToArrayAsync();
  415. foreach (var item in cityDatas)
  416. {
  417. if (item.City.Contains("城市"))
  418. {
  419. item.City = item.Country + "-所有城市";
  420. }
  421. }
  422. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  423. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  424. }
  425. return Ok(JsonView(citys));
  426. }
  427. /// <summary>
  428. /// 团组前期信息 Info
  429. /// </summary>
  430. /// <param name="id">Id</param>
  431. /// <param name="tempId">Id</param>
  432. /// <returns></returns>
  433. [HttpGet("{id}/{tempId}")]
  434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  435. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  436. {
  437. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  438. }
  439. /// <summary>
  440. /// 团组前期信息 Save
  441. /// </summary>
  442. /// <param name="dto">Id</param>
  443. /// <returns></returns>
  444. [HttpPost]
  445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  446. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  447. {
  448. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  449. }
  450. /// <summary>
  451. /// 团组前期信息 文件下载
  452. /// </summary>
  453. /// <param name="id">Id</param>
  454. /// <param name="tempId">Id</param>
  455. /// <returns></returns>
  456. [HttpGet("{id}/{tempId}")]
  457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  458. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  459. {
  460. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  461. var data = view.Data as GrpOrderPreInfoView;
  462. #region Excel
  463. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  464. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  465. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  466. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  467. var fileNamePrefix = string.Empty;
  468. if (tempId == 1405)
  469. {
  470. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  471. fileNamePrefix = $"{data.Name}_无商邀版";
  472. }
  473. else if (tempId == 1406)
  474. {
  475. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  476. fileNamePrefix = $"{data.Name}_有商邀版";
  477. }
  478. else
  479. {
  480. //tempId == 1404 默认下载
  481. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  482. fileNamePrefix = $"{data.Name}_单接送机";
  483. }
  484. foreach (var item in data.Items)
  485. {
  486. var obj = item.NewValue;
  487. if (obj == null) item.OriginVal = "";
  488. else if (obj.Equals("有") || obj.Equals("无"))
  489. {
  490. item.OriginVal = obj.ToString();
  491. }
  492. else if (obj is object[] objArray)
  493. {
  494. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  495. item.OriginVal = string.Join("、", stringArray);
  496. }
  497. else if (obj is string[] stringArray)
  498. {
  499. item.OriginVal = string.Join("、", stringArray);
  500. } else if (obj.Equals("-"))
  501. {
  502. item.OriginVal = "";
  503. }
  504. }
  505. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  506. fileName = CommonFun.ValidFileName(fileName);
  507. //载入模板
  508. WorkbookDesigner designer = new WorkbookDesigner();
  509. designer.Workbook = new Workbook(tempPath);
  510. if (tempId == 1406)
  511. {
  512. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  513. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  514. for (int i = 1; i <= view2.Length; i++)
  515. {
  516. view2[i - 1].Index = i;
  517. }
  518. designer.SetDataSource("View1", view1);
  519. designer.SetDataSource("View2", view2);
  520. }
  521. else
  522. {
  523. designer.SetDataSource("View", data.Items);
  524. }
  525. designer.Process();
  526. if (!Directory.Exists(savePath))
  527. {
  528. Directory.CreateDirectory(savePath);
  529. }
  530. string serverPath = $"{savePath}{fileName}";
  531. designer.Workbook.Save(serverPath);
  532. string rst = $"{servicePath}{ftpPath}{fileName}";
  533. #endregion
  534. return Ok(JsonView(new { url = rst }));
  535. }
  536. #endregion
  537. #region 团组基本信息
  538. /// <summary>
  539. /// 接团信息列表
  540. /// </summary>
  541. /// <param name="dto">团组列表请求dto</param>
  542. /// <returns></returns>
  543. [HttpPost]
  544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  545. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  546. {
  547. var groupData = await _groupRepository.GetGroupList(dto);
  548. if (groupData.Code != 0)
  549. {
  550. return Ok(JsonView(false, groupData.Msg));
  551. }
  552. return Ok(JsonView(groupData.Data));
  553. }
  554. /// <summary>
  555. /// 分页查询团组列表
  556. /// </summary>
  557. /// <param name="dto"></param>
  558. /// <returns></returns>
  559. [HttpPost]
  560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  561. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  562. {
  563. var watch = new Stopwatch();
  564. watch.Start();
  565. RefAsync<int> total = 0;
  566. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  567. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  568. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  569. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  570. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  571. .Distinct()
  572. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  573. watch.Stop();
  574. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  575. }
  576. /// <summary>
  577. /// 接团信息列表 Page Init
  578. /// </summary>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> PostGroupPageListInit()
  583. {
  584. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  585. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  586. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  587. var _view = new
  588. {
  589. depData = depDatas,
  590. rankData = rankDatas
  591. };
  592. return Ok(JsonView(true, "查询成功!", _view));
  593. }
  594. /// <summary>
  595. /// 接团信息列表 Page
  596. /// </summary>
  597. /// <param name="dto">团组列表请求dto</param>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  602. {
  603. #region 参数验证
  604. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  605. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  606. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  607. #region 页面操作权限验证
  608. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  609. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  610. #endregion
  611. #endregion
  612. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  613. {
  614. string sqlWhere = string.Empty;
  615. if (dto.IsSure == 0) //未完成
  616. {
  617. sqlWhere += string.Format(@" And IsSure = 0");
  618. }
  619. else if (dto.IsSure == 1) //已完成
  620. {
  621. sqlWhere += string.Format(@" And IsSure = 1");
  622. }
  623. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  624. {
  625. string tj = dto.SearchCriteria;
  626. 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}%')",
  627. tj, tj, tj, tj, tj);
  628. }
  629. if (int.TryParse(dto.Rank, out int rankId))
  630. {
  631. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  632. }
  633. string sqlWhere1 = string.Empty;
  634. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  635. {
  636. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  637. }
  638. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  639. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  640. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  641. JietuanOperator,IsSure,CreateTime,IsBid
  642. From (
  643. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  644. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  645. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  646. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  647. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  648. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  649. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  650. From Grp_DelegationInfo gdi
  651. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  652. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  653. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  654. Where gdi.IsDel = 0 {0}
  655. ) temp {1}", sqlWhere, sqlWhere1);
  656. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  657. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  658. var _view = new
  659. {
  660. PageFuncAuth = pageFunAuthView,
  661. Data = _DelegationList
  662. };
  663. return Ok(JsonView(true, "查询成功!", _view, total));
  664. }
  665. else
  666. {
  667. return Ok(JsonView(false, "查询失败"));
  668. }
  669. }
  670. /// <summary>
  671. /// 团组列表
  672. /// </summary>
  673. /// <returns></returns>
  674. [HttpPost]
  675. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  676. {
  677. #region 参数验证
  678. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  679. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  680. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  681. #region 页面操作权限验证
  682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  683. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  684. #endregion
  685. #endregion
  686. if (dto.PortType != 1 && dto.PortType != 2)
  687. {
  688. return Ok(JsonView(false, "查询失败!"));
  689. }
  690. string orderbyStr = "order by gdi.CreateTime Desc";
  691. string sqlWhere = string.Empty;
  692. if (dto.IsSure == 0) //未完成
  693. {
  694. sqlWhere += string.Format(@" And IsSure = 0");
  695. }
  696. else if (dto.IsSure == 1) //已完成
  697. {
  698. sqlWhere += string.Format(@" And IsSure = 1");
  699. }
  700. //团组类型
  701. if (dto.TeamDid > 0)
  702. {
  703. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  704. }
  705. //团组名称
  706. if (!string.IsNullOrEmpty(dto.TeamName))
  707. {
  708. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  709. }
  710. //客户名称
  711. if (!string.IsNullOrEmpty(dto.ClientName))
  712. {
  713. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  714. }
  715. //客户单位
  716. if (!string.IsNullOrEmpty(dto.ClientUnit))
  717. {
  718. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  719. }
  720. //出访时间
  721. if (!string.IsNullOrEmpty(dto.visitDataTime))
  722. {
  723. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  724. orderbyStr = "order by gdi.VisitDate";
  725. }
  726. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  727. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  728. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  729. JietuanOperator,IsSure,CreateTime
  730. From (
  731. Select row_number() over({0}) as Row_Number,
  732. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  733. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  734. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  735. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  736. From Grp_DelegationInfo gdi
  737. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  738. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  739. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  740. Where gdi.IsDel = 0 {1}
  741. ) temp ", orderbyStr, sqlWhere);
  742. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  743. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  744. #region 处理所属部门
  745. /*
  746. * 1.sq 和 gyy 等显示 市场部
  747. * 2.王鸽和主管及张总还有管理员号统一国交部
  748. * 2-1. 4 管理员 ,21 张海麟
  749. */
  750. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  751. List<int> userIds1 = new List<int>() { 4, 21 };
  752. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  753. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  754. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  755. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  756. .ToList();
  757. foreach (var item in _DelegationList)
  758. {
  759. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  760. }
  761. #endregion
  762. var _view = new
  763. {
  764. PageFuncAuth = pageFunAuthView,
  765. Data = _DelegationList
  766. };
  767. return Ok(JsonView(true, "查询成功!", _view, total));
  768. }
  769. /// <summary>
  770. /// 接团信息详情
  771. /// </summary>
  772. /// <param name="dto">团组info请求dto</param>
  773. /// <returns></returns>
  774. [HttpPost]
  775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  776. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  777. {
  778. var groupData = await _groupRepository.GetGroupInfo(dto);
  779. if (groupData.Code != 0)
  780. {
  781. return Ok(JsonView(false, groupData.Msg));
  782. }
  783. return Ok(JsonView(groupData.Data));
  784. }
  785. /// <summary>
  786. /// 接团信息 编辑添加
  787. /// 基础信息数据源
  788. /// </summary>
  789. /// <param name="dto"></param>
  790. /// <returns></returns>
  791. [HttpPost]
  792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  793. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  794. {
  795. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, groupData.Msg));
  799. }
  800. return Ok(JsonView(groupData.Data));
  801. }
  802. /// <summary>
  803. /// 接团信息 操作(增改)
  804. /// </summary>
  805. /// <param name="dto"></param>
  806. /// <returns></returns>
  807. [HttpPost]
  808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  809. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  810. {
  811. // 创建 Stopwatch 实例
  812. Stopwatch stopwatch = Stopwatch.StartNew();
  813. decimal ffrPrice = 0.00M;
  814. DateTime? visitDt = null;
  815. if (dto.Status == 2)
  816. {
  817. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  818. if (groupInfo != null)
  819. {
  820. ffrPrice = groupInfo.PaymentMoney;
  821. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  822. }
  823. }
  824. var groupData = await _groupRepository.GroupOperation(dto);
  825. if (groupData.Code != 0)
  826. {
  827. return Ok(JsonView(false, groupData.Msg));
  828. }
  829. int diId = 0;
  830. try
  831. {
  832. //添加时 默认加入团组汇率
  833. if (dto.Status == 1) //添加
  834. {
  835. diId = groupData.Data;
  836. //添加默认币种
  837. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  838. //默认分配权限
  839. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  840. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  841. var _managerIds = new List<int>() { 22, 32, 21 };
  842. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  843. if (userIds.Count > 0)
  844. {
  845. userIds.Add(208);
  846. //创建团组管控
  847. GroupStepForDelegation.CreateWorkStep(diId);
  848. //发送消息
  849. string groupName = dto.TeamName;
  850. string createGroupUser = string.Empty;
  851. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  852. if (userInfo != null) createGroupUser = userInfo.CnName;
  853. string title = $"系统通知";
  854. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  855. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  856. }
  857. //默认创建倒推表
  858. await _invertedListRep._Create(dto.UserId, diId);
  859. }
  860. else if (dto.Status == 2)
  861. {
  862. diId = dto.Id;
  863. }
  864. #region 签证人员团组时间通知
  865. #region 计算出访起止时间
  866. var startTime = new DateTime();
  867. var endTime = new DateTime();
  868. if (DateTime.TryParse(dto.VisitDate, out startTime))
  869. {
  870. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  871. }
  872. #endregion
  873. #endregion
  874. #region 团组操作默认添加/修改收款账单
  875. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  876. {
  877. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  878. .Where(x => x.IsDel == 0 &&
  879. x.Diid == diId &&
  880. x.Remark.Equals("预付款")
  881. )
  882. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  883. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  884. .FirstAsync();
  885. ffrInfo = new Fin_ForeignReceivables()
  886. {
  887. Diid = diId,
  888. PriceName = dto.ClientUnit,
  889. Price = dto.PaymentMoney,
  890. Count = 1,
  891. Unit = $"元",
  892. ItemSumPrice = dto.PaymentMoney,
  893. Rate = 1.0000M,
  894. Currency = 836,
  895. AddingWay = 0,
  896. CreateUserId = dto.UserId,
  897. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  898. Remark = $"预付款"
  899. };
  900. if (ffrInfo == null) //Add
  901. {
  902. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  903. }
  904. else //修改
  905. {
  906. await _sqlSugar.Updateable(ffrInfo)
  907. .UpdateColumns(x => new
  908. {
  909. x.PriceName,
  910. x.Price,
  911. x.ItemSumPrice,
  912. x.CreateTime,
  913. x.CreateUserId
  914. })
  915. .WhereColumns(x => x.Id)
  916. .ExecuteCommandAsync();
  917. }
  918. }
  919. #endregion
  920. if (diId > 0)
  921. {
  922. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  923. }
  924. // 停止计时
  925. stopwatch.Stop();
  926. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  927. }
  928. catch (Exception ex)
  929. {
  930. // 停止计时
  931. stopwatch.Stop();
  932. Logs("[response]" + JsonConvert.SerializeObject(dto));
  933. Logs(ex.Message);
  934. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  935. }
  936. // 停止计时
  937. stopwatch.Stop();
  938. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  939. }
  940. /// <summary>
  941. /// 接团流程操作(增改)
  942. /// 安卓端使用 建团时添加客户名单
  943. /// </summary>
  944. /// <param name="dto"></param>
  945. /// <returns></returns>
  946. [HttpPost]
  947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  948. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  949. {
  950. #region 参数验证
  951. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  952. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  953. #region 页面操作权限验证
  954. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  955. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  956. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  957. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  958. #endregion
  959. #endregion
  960. try
  961. {
  962. //_sqlSugar.BeginTran();
  963. decimal ffrPrice = 0.00M;
  964. DateTime? visitDt = null;
  965. if (dto.Status == 2)
  966. {
  967. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  968. if (groupInfo != null)
  969. {
  970. ffrPrice = groupInfo.PaymentMoney;
  971. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  972. }
  973. }
  974. var _dto = new GroupOperationDto();
  975. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  976. var groupData = await _groupRepository.GroupOperation(_dto);
  977. if (groupData.Code != 0)
  978. {
  979. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  980. }
  981. int diId = 0;
  982. //添加时 默认加入团组汇率
  983. if (dto.Status == 1) //添加
  984. {
  985. diId = groupData.Data;
  986. //添加默认币种
  987. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  988. //默认分配权限
  989. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  990. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  991. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  992. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  993. if (userIds.Count > 0)
  994. {
  995. userIds.Add(208);
  996. //创建团组管控
  997. GroupStepForDelegation.CreateWorkStep(diId);
  998. //发送消息
  999. string groupName = dto.TeamName;
  1000. string createGroupUser = string.Empty;
  1001. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1002. if (userInfo != null) createGroupUser = userInfo.CnName;
  1003. string title = $"系统通知";
  1004. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1005. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1006. }
  1007. #region 应用推送
  1008. try
  1009. {
  1010. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1011. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1012. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1013. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1014. {
  1015. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1016. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1017. }
  1018. }
  1019. catch (Exception ex)
  1020. {
  1021. }
  1022. #endregion
  1023. //默认创建倒推表
  1024. await _invertedListRep._Create(dto.UserId, diId);
  1025. }
  1026. if (dto.Status == 2)
  1027. {
  1028. diId = dto.Id;
  1029. if (diId == 0)
  1030. {
  1031. //_sqlSugar.RollbackTran();
  1032. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1033. }
  1034. }
  1035. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1036. if (viewData.Code != 0)
  1037. {
  1038. //_sqlSugar.RollbackTran();
  1039. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1040. }
  1041. #region 团组操作默认添加/修改收款账单
  1042. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1043. {
  1044. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1045. .Where(x => x.IsDel == 0 &&
  1046. x.Diid == diId &&
  1047. x.Remark.Equals("预付款")
  1048. )
  1049. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1050. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1051. .FirstAsync();
  1052. ffrInfo = new Fin_ForeignReceivables()
  1053. {
  1054. Diid = diId,
  1055. PriceName = dto.ClientUnit,
  1056. Price = dto.PaymentMoney,
  1057. Count = 1,
  1058. Unit = $"元",
  1059. ItemSumPrice = dto.PaymentMoney,
  1060. Rate = 1.0000M,
  1061. Currency = 836,
  1062. AddingWay = 0,
  1063. CreateUserId = dto.UserId,
  1064. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1065. Remark = $"预付款"
  1066. };
  1067. if (ffrInfo == null) //Add
  1068. {
  1069. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1070. }
  1071. else //修改
  1072. {
  1073. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1074. .UpdateColumns(x => new
  1075. {
  1076. x.PriceName,
  1077. x.Price,
  1078. x.ItemSumPrice,
  1079. x.CreateTime,
  1080. x.CreateUserId
  1081. })
  1082. .WhereColumns(x => x.Id)
  1083. .ExecuteCommandAsync();
  1084. }
  1085. }
  1086. #endregion
  1087. #region 签证人员团组时间通知
  1088. #region 计算出访起止时间
  1089. var startTime = new DateTime();
  1090. var endTime = new DateTime();
  1091. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1092. {
  1093. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1094. }
  1095. #endregion
  1096. if (diId > 0)
  1097. {
  1098. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1099. }
  1100. #endregion
  1101. //_sqlSugar.CommitTran();
  1102. return Ok(JsonView(true, "添加成功"));
  1103. }
  1104. catch (Exception ex)
  1105. {
  1106. _sqlSugar.RollbackTran();
  1107. return Ok(JsonView(false, ex.Message));
  1108. }
  1109. }
  1110. /// <summary>
  1111. /// 接团流程操作(增改)
  1112. /// 安卓端使用 建团时添加客户名单
  1113. /// </summary>
  1114. /// <param name="dto"></param>
  1115. /// <returns></returns>
  1116. [HttpPost]
  1117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1118. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1119. {
  1120. #region 参数验证
  1121. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1123. #region 页面操作权限验证
  1124. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1125. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1126. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1127. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1128. #endregion
  1129. #endregion
  1130. _sqlSugar.BeginTran();
  1131. decimal ffrPrice = 0.00M;
  1132. DateTime? visitDt = null;
  1133. if (dto.Status == 2)
  1134. {
  1135. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1136. if (groupInfo != null)
  1137. {
  1138. ffrPrice = groupInfo.PaymentMoney;
  1139. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1140. }
  1141. }
  1142. var _dto = new GroupOperationDto();
  1143. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1144. var groupData = await _groupRepository.GroupOperation(_dto);
  1145. if (groupData.Code != 0)
  1146. {
  1147. _sqlSugar.RollbackTran();
  1148. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1149. }
  1150. try
  1151. {
  1152. int diId = 0;
  1153. //添加时 默认加入团组汇率
  1154. if (dto.Status == 1) //添加
  1155. {
  1156. diId = groupData.Data;
  1157. //添加默认币种
  1158. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1159. //默认分配权限
  1160. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1161. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1162. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1163. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1164. if (userIds.Count > 0)
  1165. {
  1166. userIds.Add(208);
  1167. //创建团组管控
  1168. GroupStepForDelegation.CreateWorkStep(diId);
  1169. //发送消息
  1170. string groupName = dto.TeamName;
  1171. string createGroupUser = string.Empty;
  1172. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1173. if (userInfo != null) createGroupUser = userInfo.CnName;
  1174. string title = $"系统通知";
  1175. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1176. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1177. }
  1178. #region 应用推送
  1179. try
  1180. {
  1181. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1182. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1183. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1184. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1185. {
  1186. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1187. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1188. }
  1189. }
  1190. catch (Exception ex)
  1191. {
  1192. _sqlSugar.CommitTran();
  1193. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1194. }
  1195. #endregion
  1196. //默认创建倒推表
  1197. await _invertedListRep._Create(dto.UserId, diId);
  1198. }
  1199. else if (dto.Status == 2)
  1200. {
  1201. diId = dto.Id;
  1202. if (diId == 0)
  1203. {
  1204. _sqlSugar.RollbackTran();
  1205. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1206. }
  1207. }
  1208. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1209. if (viewData.Code != 0)
  1210. {
  1211. _sqlSugar.RollbackTran();
  1212. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1213. }
  1214. #region 团组操作默认添加/修改收款账单
  1215. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1216. {
  1217. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1218. .Where(x => x.IsDel == 0 &&
  1219. x.Diid == diId &&
  1220. x.Remark.Equals("预付款")
  1221. )
  1222. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1223. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1224. .FirstAsync();
  1225. ffrInfo = new Fin_ForeignReceivables()
  1226. {
  1227. Diid = diId,
  1228. PriceName = dto.ClientUnit,
  1229. Price = dto.PaymentMoney,
  1230. Count = 1,
  1231. Unit = $"元",
  1232. ItemSumPrice = dto.PaymentMoney,
  1233. Rate = 1.0000M,
  1234. Currency = 836,
  1235. AddingWay = 0,
  1236. CreateUserId = dto.UserId,
  1237. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1238. Remark = $"预付款"
  1239. };
  1240. if (ffrInfo == null) //Add
  1241. {
  1242. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1243. }
  1244. else //修改
  1245. {
  1246. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1247. .UpdateColumns(x => new
  1248. {
  1249. x.PriceName,
  1250. x.Price,
  1251. x.ItemSumPrice,
  1252. x.CreateTime,
  1253. x.CreateUserId
  1254. })
  1255. .WhereColumns(x => x.Id)
  1256. .ExecuteCommandAsync();
  1257. }
  1258. }
  1259. #endregion
  1260. #region 签证人员团组时间通知
  1261. #region 计算出访起止时间
  1262. var startTime = new DateTime();
  1263. var endTime = new DateTime();
  1264. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1265. {
  1266. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1267. }
  1268. #endregion
  1269. if (diId > 0)
  1270. {
  1271. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1272. }
  1273. #endregion
  1274. _sqlSugar.CommitTran();
  1275. return Ok(JsonView(true));
  1276. }
  1277. catch (Exception ex)
  1278. {
  1279. _sqlSugar.RollbackTran();
  1280. return Ok(JsonView(false, ex.Message));
  1281. }
  1282. }
  1283. /// <summary>
  1284. /// 接团信息 操作(删除)
  1285. /// </summary>
  1286. /// <param name="dto"></param>
  1287. /// <returns></returns>
  1288. [HttpPost]
  1289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1290. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1291. {
  1292. var diId = dto.Id;
  1293. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1294. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1295. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1296. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1297. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1298. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1299. #endregion
  1300. var groupData = await _groupRepository.GroupDel(dto);
  1301. if (groupData.Code != 0)
  1302. {
  1303. return Ok(JsonView(false, groupData.Msg));
  1304. }
  1305. return Ok(JsonView(true));
  1306. }
  1307. /// <summary>
  1308. /// 获取团组销售报价号
  1309. /// 团组添加时 使用
  1310. /// </summary>
  1311. /// <returns></returns>
  1312. [HttpPost]
  1313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1314. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1315. {
  1316. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1317. if (groupData.Code != 0)
  1318. {
  1319. return Ok(JsonView(false, groupData.Msg));
  1320. }
  1321. object salesQuoteNo = new
  1322. {
  1323. SalesQuoteNo = groupData.Data
  1324. };
  1325. return Ok(JsonView(salesQuoteNo));
  1326. }
  1327. /// <summary>
  1328. /// 设置确认出团
  1329. /// </summary>
  1330. /// <param name="dto"></param>
  1331. /// <returns></returns>
  1332. [HttpPost]
  1333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1334. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1335. {
  1336. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1337. if (groupData.Code != 0)
  1338. {
  1339. return Ok(JsonView(false, groupData.Msg));
  1340. }
  1341. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1342. #region OA消息推送
  1343. try
  1344. {
  1345. string groupName = groupInfo.TeamName;
  1346. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1347. string title = $"系统通知";
  1348. string content = $"团组[{groupName}]已确认出团!";
  1349. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1350. }
  1351. catch (Exception ex)
  1352. {
  1353. }
  1354. #endregion
  1355. #region 应用推送
  1356. try
  1357. {
  1358. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1359. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1360. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1361. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1362. {
  1363. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1364. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1365. }
  1366. }
  1367. catch (Exception ex)
  1368. {
  1369. }
  1370. #endregion
  1371. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1372. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1373. }
  1374. /// <summary>
  1375. /// 获取团组名称data And 签证国别Data
  1376. /// </summary>
  1377. /// <param name="dto"></param>
  1378. /// <returns></returns>
  1379. [HttpPost]
  1380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1381. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1382. {
  1383. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1384. if (groupData.Code != 0)
  1385. {
  1386. return Ok(JsonView(false, groupData.Msg));
  1387. }
  1388. return Ok(JsonView(groupData.Data));
  1389. }
  1390. /// <summary>
  1391. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1392. /// </summary>
  1393. /// <returns></returns>
  1394. [HttpPost]
  1395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1396. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1397. {
  1398. try
  1399. {
  1400. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1401. if (groupData.Code != 0)
  1402. {
  1403. return Ok(JsonView(false, groupData.Msg));
  1404. }
  1405. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1406. }
  1407. catch (Exception ex)
  1408. {
  1409. return Ok(JsonView(false, "程序错误!"));
  1410. throw;
  1411. }
  1412. }
  1413. /// <summary>
  1414. /// 团组清单 Excel
  1415. /// </summary>
  1416. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1417. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1418. /// <returns></returns>
  1419. [HttpGet]
  1420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1421. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1422. {
  1423. DateTime _beginDt, _endDt;
  1424. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1425. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1426. if (!beginBool && !endBool)
  1427. {
  1428. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1429. }
  1430. string sql = string.Format(@"
  1431. SELECT
  1432. ROW_NUMBER,
  1433. Id,
  1434. SalesQuoteNo,
  1435. TourCode,
  1436. TeamTypeId,
  1437. TeamType,
  1438. TeamLevId,
  1439. TeamLev,
  1440. TeamName,
  1441. ClientName,
  1442. ClientUnit,
  1443. VisitDate,
  1444. VisitDays,
  1445. VisitPNumber,
  1446. JietuanOperatorId,
  1447. JietuanOperator,
  1448. IsSure,
  1449. CreateUserName,
  1450. IsBid
  1451. FROM
  1452. (
  1453. SELECT
  1454. ROW_NUMBER() OVER(
  1455. ORDER BY
  1456. gdi.CreateTime Desc
  1457. ) AS ROW_NUMBER,
  1458. gdi.Id,
  1459. SalesQuoteNo,
  1460. TourCode,
  1461. ssd.Id TeamTypeId,
  1462. ssd.Name TeamType,
  1463. ssd1.Id TeamLevId,
  1464. ssd1.Name TeamLev,
  1465. TeamName,
  1466. ClientName,
  1467. ClientUnit,
  1468. VisitDate,
  1469. VisitDays,
  1470. VisitPNumber,
  1471. JietuanOperator JietuanOperatorId,
  1472. su.CnName JietuanOperator,
  1473. IsSure,
  1474. gdi.CreateTime,
  1475. su1.CnName As CreateUserName,
  1476. gdi.IsBid
  1477. FROM
  1478. Grp_DelegationInfo gdi
  1479. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1480. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1481. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1482. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1483. WHERE
  1484. gdi.IsDel = 0
  1485. AND gdi.IsBid = 0
  1486. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1487. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1488. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1489. #region 处理所属部门
  1490. /*
  1491. * 1.sq 和 gyy 等显示 市场部
  1492. * 2.王鸽和主管及张总还有管理员号统一国交部
  1493. * 2-1. 4 管理员 ,21 张海麟
  1494. */
  1495. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1496. List<int> userIds1 = new List<int>() { 4, 21 };
  1497. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1498. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1499. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1500. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1501. .ToListAsync();
  1502. var droupIds = groupList.Select(it => it.Id).ToList();
  1503. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1504. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1505. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1506. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1507. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1508. {
  1509. DiId = tcl.DiId,
  1510. LastName = dc.LastName,
  1511. FirstName = dc.FirstName,
  1512. Sex = dc.Sex,
  1513. Birthday = dc.BirthDay,
  1514. Company = cc.CompanyFullName,
  1515. Job = dc.Job,
  1516. CreateTime = tcl.CreateTime,
  1517. })
  1518. .ToList();
  1519. foreach (var item in groupList)
  1520. {
  1521. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1522. string groupFirstName = "";
  1523. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1524. if (currDatas.Any())
  1525. {
  1526. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1527. }
  1528. item.GroupFirst = groupFirstName;
  1529. }
  1530. #endregion
  1531. #region Excel
  1532. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1533. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1534. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1535. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1536. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1537. //载入模板
  1538. WorkbookDesigner designer = new WorkbookDesigner();
  1539. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1540. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1541. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1542. dt.TableName = "GroupList";
  1543. designer.SetDataSource(dt);
  1544. designer.Process();
  1545. if (!Directory.Exists(savePath))
  1546. {
  1547. Directory.CreateDirectory(savePath);
  1548. }
  1549. string serverPath = $"{savePath}{fileName}";
  1550. designer.Workbook.Save(serverPath);
  1551. string rst = $"{servicePath}{ftpPath}{fileName}";
  1552. #endregion
  1553. return Ok(JsonView(true, "操作成功!", rst));
  1554. }
  1555. #endregion
  1556. #region 团组&签证
  1557. /// <summary>
  1558. /// 根据团组Id获取签证客户信息List
  1559. /// </summary>
  1560. /// <param name="dto">请求dto</param>
  1561. /// <returns></returns>
  1562. [HttpPost]
  1563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1564. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1565. {
  1566. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1567. if (groupData.Code != 0)
  1568. {
  1569. return Ok(JsonView(false, groupData.Msg));
  1570. }
  1571. return Ok(JsonView(groupData.Data));
  1572. }
  1573. /// <summary>
  1574. /// IOS获取团组签证拍照上传进度01(团组列表)
  1575. /// </summary>
  1576. /// <param name="dto">请求dto</param>
  1577. /// <returns></returns>
  1578. [HttpPost]
  1579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1580. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1581. {
  1582. if (dto == null)
  1583. {
  1584. return Ok(JsonView(false, "参数为空"));
  1585. }
  1586. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1587. return Ok(JsonView(visaList));
  1588. }
  1589. /// <summary>
  1590. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1591. /// </summary>
  1592. /// <returns></returns>
  1593. [HttpPost]
  1594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1595. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1596. {
  1597. if (dto == null)
  1598. {
  1599. return Ok(JsonView(false, "请求错误:"));
  1600. }
  1601. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1602. return Ok(JsonView(list));
  1603. }
  1604. /// <summary>
  1605. /// IOS获取团组签证拍照上传进度03(相册)
  1606. /// </summary>
  1607. /// <returns></returns>
  1608. [HttpPost]
  1609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1610. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1611. {
  1612. if (dto == null)
  1613. {
  1614. return Ok(JsonView(false, "请求错误:"));
  1615. }
  1616. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1617. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1618. list.ForEach(s => s.url = url);
  1619. return Ok(JsonView(list));
  1620. }
  1621. /// <summary>
  1622. /// IOS获取团组签证拍照上传进度04(图片上传)
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1629. {
  1630. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1631. //if (!string.IsNullOrEmpty(result))
  1632. //{
  1633. //}
  1634. //else {
  1635. // return Ok(JsonView(false, "上传失败"));
  1636. //}
  1637. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1638. int sucNum = 0;
  1639. try
  1640. {
  1641. foreach (var item in dto.base64DataList)
  1642. {
  1643. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1644. string result = DecodeBase64ToImage(item, imageName);
  1645. if (!string.IsNullOrEmpty(result))
  1646. {
  1647. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1648. pic.CreateUserId = dto.CreateUserId;
  1649. pic.PicName = imageName;
  1650. pic.PicPath = result;
  1651. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1652. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1653. if (insertResult > 0)
  1654. {
  1655. sucNum++;
  1656. }
  1657. }
  1658. }
  1659. }
  1660. catch (Exception ex)
  1661. {
  1662. return Ok(JsonView(false, ex.Message));
  1663. }
  1664. string msg = string.Format(@"成功上传{0}张", sucNum);
  1665. return Ok(JsonView(true, msg));
  1666. }
  1667. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1668. {
  1669. string filename = "";//声明一个string类型的相对路径
  1670. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1671. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1672. try//会有异常抛出,try,catch一下
  1673. {
  1674. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1675. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1676. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1677. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1678. //文件名称
  1679. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1680. //上传的文件的路径
  1681. string filePath = "";
  1682. if (!Directory.Exists(fileDir))
  1683. {
  1684. Directory.CreateDirectory(fileDir);
  1685. }
  1686. //上传的文件的路径
  1687. filePath = fileDir + filename;
  1688. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1689. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1690. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1691. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1692. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1693. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1694. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1695. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1696. bitmap.Dispose();
  1697. }
  1698. catch (Exception e)
  1699. {
  1700. string massage = e.Message;
  1701. Logs("IOS图片上传Error:" + massage);
  1702. //filename = e.Message;
  1703. }
  1704. return filename;//返回相对路径
  1705. }
  1706. /// <summary>
  1707. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1708. /// </summary>
  1709. /// <param name="dto"></param>
  1710. /// <returns></returns>
  1711. [HttpPost]
  1712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1713. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1714. {
  1715. if (dto == null)
  1716. {
  1717. return Ok(JsonView(false, "请求错误:"));
  1718. }
  1719. string msg = "参数错误";
  1720. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1721. {
  1722. try
  1723. {
  1724. //_delegationVisaRep.BeginTran();
  1725. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1726. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1727. .Where(s => s.Id == dto.visaProgressCustomerId)
  1728. .ExecuteCommandAsync();
  1729. if (updCount > 0 && dto.publishCode == 1)
  1730. {
  1731. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1732. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1733. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1734. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1735. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1736. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1737. if (groupData == null)
  1738. {
  1739. _delegationVisaRep.RollbackTran();
  1740. }
  1741. string title = string.Format(@"[签证进度更新]");
  1742. string content = string.Format(@"测试文本");
  1743. bool rst = await _message.AddMsg(new MessageDto()
  1744. {
  1745. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1746. IssuerId = dto.publisher,
  1747. Title = title,
  1748. Content = content,
  1749. ReleaseTime = DateTime.Now,
  1750. UIdList = new List<int> {
  1751. 234
  1752. }
  1753. });
  1754. if (rst)
  1755. {
  1756. return Ok(JsonView(true, "发送通知成功"));
  1757. }
  1758. }
  1759. //_delegationVisaRep.CommitTran();
  1760. }
  1761. catch (Exception)
  1762. {
  1763. //_delegationVisaRep.RollbackTran();
  1764. }
  1765. }
  1766. return Ok(JsonView(true, msg));
  1767. }
  1768. #endregion
  1769. #region 团组任务分配
  1770. /// <summary>
  1771. /// 团组任务分配初始化
  1772. /// </summary>
  1773. /// <returns></returns>
  1774. [HttpPost]
  1775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1776. public async Task<IActionResult> GetTaskAssignmen()
  1777. {
  1778. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1779. if (groupData.Code != 0)
  1780. {
  1781. return Ok(JsonView(false, groupData.Msg));
  1782. }
  1783. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1784. }
  1785. /// <summary>
  1786. /// 团组任务分配查询
  1787. /// </summary>
  1788. /// <param name="dto"></param>
  1789. /// <returns></returns>
  1790. [HttpPost]
  1791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1792. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1793. {
  1794. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1795. if (groupData.Code != 0)
  1796. {
  1797. return Ok(JsonView(false, groupData.Msg));
  1798. }
  1799. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1800. }
  1801. /// <summary>
  1802. /// 团组任务分配操作
  1803. /// </summary>
  1804. /// <param name="dto"></param>
  1805. /// <returns></returns>
  1806. [HttpPost]
  1807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1808. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1809. {
  1810. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1811. if (groupData.Code != 0)
  1812. {
  1813. return Ok(JsonView(false, groupData.Msg));
  1814. }
  1815. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1816. }
  1817. /// <summary>
  1818. /// 团组任务分配
  1819. /// 批量分配
  1820. /// 查询团组
  1821. /// </summary>
  1822. /// <param name="dto"></param>
  1823. /// <returns></returns>
  1824. [HttpPost]
  1825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1826. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1827. {
  1828. //参数验证
  1829. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1830. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1831. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1832. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1833. }
  1834. /// <summary>
  1835. /// 团组任务分配
  1836. /// 批量分配
  1837. /// </summary>
  1838. /// <param name="dto"></param>
  1839. /// <returns></returns>
  1840. [HttpPost]
  1841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1842. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1843. {
  1844. //参数验证
  1845. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1846. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1847. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1848. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1849. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1850. }
  1851. #endregion
  1852. #region 团组费用审核
  1853. /// <summary>
  1854. /// 费用审核
  1855. /// 团组列表 Page
  1856. /// </summary>
  1857. /// <param name="_dto">团组列表请求dto</param>
  1858. /// <returns></returns>
  1859. [HttpPost]
  1860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1861. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1862. {
  1863. #region 参数验证
  1864. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1865. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1866. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1867. #region 页面操作权限验证
  1868. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1869. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1870. #endregion
  1871. #endregion
  1872. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1873. {
  1874. string sqlWhere = string.Empty;
  1875. if (_dto.IsSure == 0) //未完成
  1876. {
  1877. sqlWhere += string.Format(@" And IsSure = 0");
  1878. }
  1879. else if (_dto.IsSure == 1) //已完成
  1880. {
  1881. sqlWhere += string.Format(@" And IsSure = 1");
  1882. }
  1883. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1884. {
  1885. string tj = _dto.SearchCriteria;
  1886. 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}%')",
  1887. tj, tj, tj, tj, tj);
  1888. }
  1889. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1890. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1891. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1892. From (
  1893. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1894. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1895. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1896. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1897. From Grp_DelegationInfo gdi
  1898. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1899. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1900. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1901. Where gdi.IsDel = 0 {0}
  1902. ) temp ", sqlWhere);
  1903. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1904. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1905. var _view = new
  1906. {
  1907. PageFuncAuth = pageFunAuthView,
  1908. Data = _DelegationList
  1909. };
  1910. return Ok(JsonView(true, "查询成功!", _view, total));
  1911. }
  1912. else
  1913. {
  1914. return Ok(JsonView(false, "查询失败"));
  1915. }
  1916. }
  1917. /// <summary>
  1918. /// 获取团组费用审核
  1919. /// </summary>
  1920. /// <param name="_dto"></param>
  1921. /// <returns></returns>
  1922. [HttpPost]
  1923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1924. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1925. {
  1926. try
  1927. {
  1928. #region 参数验证
  1929. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1930. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1931. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1932. #region 页面操作权限验证
  1933. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1934. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1935. #endregion
  1936. #endregion
  1937. var _view = new Grp_CreditCardPaymentView();
  1938. var clientNameList = getSimplClientList(_dto.DiId);
  1939. #region 费用清单
  1940. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1941. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1942. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1943. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1944. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1945. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1946. /*
  1947. * 76://酒店预订
  1948. */
  1949. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1950. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1951. /*
  1952. * 79://车/导游地接
  1953. */
  1954. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1955. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1956. /*
  1957. * 80: //签证
  1958. */
  1959. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1960. /*
  1961. *81: //邀请/公务活动
  1962. */
  1963. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1964. /*
  1965. * 82: //团组客户保险
  1966. */
  1967. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1968. /*
  1969. * Lable = 85 机票预订
  1970. */
  1971. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1972. /*
  1973. * 85 机票预定
  1974. */
  1975. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1976. /*
  1977. * 98 其他款项
  1978. */
  1979. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1980. /*
  1981. * 285:收款退还
  1982. */
  1983. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1984. /*
  1985. * 1015: //超支费用
  1986. */
  1987. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1988. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1989. /*
  1990. * 币种信息
  1991. */
  1992. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1993. /*
  1994. * 车/导游地接 费用类型
  1995. */
  1996. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1997. /*
  1998. * 车/导游地接 费用类型
  1999. */
  2000. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2001. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2002. /*
  2003. * 用户信息
  2004. */
  2005. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2006. /*
  2007. * 费用模块
  2008. */
  2009. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2010. string priceModule = string.Empty;
  2011. if (sdPriceName != null)
  2012. {
  2013. priceModule = sdPriceName.Name;
  2014. }
  2015. /*
  2016. * 成本信息
  2017. */
  2018. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2019. decimal _groupRate = 0.0000M;
  2020. string _groupCurrencyCode = "-";
  2021. if (groupCost != null)
  2022. {
  2023. _groupRate = groupCost.Rate;
  2024. if (int.TryParse(groupCost.Currency, out int _currency))
  2025. {
  2026. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2027. }
  2028. else _groupCurrencyCode = groupCost.Currency;
  2029. }
  2030. string costContentSql = $"Select * From Grp_GroupCost";
  2031. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2032. //处理日期为空的天数
  2033. for (int i = 0; i < groupCostDetails.Count; i++)
  2034. if (i != 0)
  2035. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2036. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2037. /*
  2038. * 处理详情数据
  2039. */
  2040. foreach (var entity in entityList)
  2041. {
  2042. var _detail = new Grp_CreditCardPaymentDetailView();
  2043. _detail.Id = entity.Id;
  2044. _detail.PriceName = priceModule;
  2045. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2046. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2047. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2048. //处理金额
  2049. if (entity.CTable == 1015)
  2050. {
  2051. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2052. if (czInfo != null)
  2053. {
  2054. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2055. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2056. }
  2057. }
  2058. /*
  2059. * 应付款金额
  2060. */
  2061. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2062. string PaymentCurrency_WaitPay = "Unknown";
  2063. string hotelCurrncyCode = "Unknown";
  2064. string hotelCurrncyName = "Unknown";
  2065. if (sdPaymentCurrency_WaitPay != null)
  2066. {
  2067. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2068. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2069. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2070. if (hotelCurrncyCode.Equals("CNY"))
  2071. {
  2072. entity.DayRate = 1.0000M;
  2073. }
  2074. }
  2075. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2076. /*
  2077. * 此次付款金额
  2078. */
  2079. decimal CurrPayStr = 0.00M,
  2080. OriginalCurrPay = 0.00M;
  2081. if (entity.PayPercentage == 0)
  2082. {
  2083. if (entity.PayThenMoney != 0)
  2084. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2085. }
  2086. else
  2087. {
  2088. if (entity.PayMoney != 0)
  2089. {
  2090. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2091. }
  2092. }
  2093. //if (_dto.Label == 79)
  2094. //{
  2095. // string original = string.Empty;
  2096. // if (hotelCurrncyCode.Equals("CNY"))
  2097. // {
  2098. // OriginalCurrPay = CurrPayStr;
  2099. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2100. // }
  2101. // else
  2102. // {
  2103. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2104. // //760 EUR(7600.00 CNY)
  2105. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2106. // }
  2107. //}
  2108. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2109. string original = string.Empty;
  2110. if (hotelCurrncyCode.Equals("CNY"))
  2111. {
  2112. OriginalCurrPay = CurrPayStr;
  2113. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2114. }
  2115. else
  2116. {
  2117. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2118. //760 EUR(7600.00 CNY)
  2119. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2120. }
  2121. /*
  2122. * 剩余尾款
  2123. */
  2124. decimal BalanceStr = 0;
  2125. if (CurrPayStr != 0)
  2126. {
  2127. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2128. BalanceStr = 0;
  2129. else
  2130. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2131. }
  2132. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2133. /*
  2134. * Bus名称
  2135. */
  2136. _detail.BusName = "待增加";
  2137. /*
  2138. *费用所属
  2139. */
  2140. switch (entity.CTable)
  2141. {
  2142. case 76://酒店预订
  2143. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2144. if (hotelReservations != null)
  2145. {
  2146. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2147. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2148. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2149. string roomFeeStr = "", roomFeestr1 = "";
  2150. //是否比较房型价格
  2151. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2152. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2153. roomFeeStr += $"<br/>";
  2154. var roomTotal = 0.00M;
  2155. if (hotelReservations.SingleRoomPrice > 0)
  2156. {
  2157. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2158. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2159. //__isSingle = true;
  2160. roomTotal += fee;
  2161. }
  2162. if (hotelReservations.DoubleRoomPrice > 0)
  2163. {
  2164. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2165. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2166. // __isDouble = true;
  2167. roomTotal += fee;
  2168. }
  2169. if (hotelReservations.SuiteRoomPrice > 0)
  2170. {
  2171. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2172. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2173. //__isSuite = true;
  2174. roomTotal += fee;
  2175. }
  2176. if (hotelReservations.OtherRoomPrice > 0)
  2177. {
  2178. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2179. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2180. //__isOther = true;
  2181. roomTotal += fee;
  2182. }
  2183. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2184. else roomFeeStr += " 0.00 * 0";
  2185. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2186. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2187. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2188. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2189. /*
  2190. * 费用类型
  2191. * 1:房费
  2192. * 2:早餐
  2193. * 3:地税
  2194. * 4:城市税
  2195. * </summary>
  2196. */
  2197. //地税
  2198. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2199. if (governmentRentData != null)
  2200. {
  2201. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2202. governmentRentFee = governmentRentData.Price;
  2203. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2204. if (governmentRentCurrData != null)
  2205. {
  2206. governmentRentCode = governmentRentCurrData.Name;
  2207. governmentRentName = $"({governmentRentCurrData.Remark})";
  2208. }
  2209. }
  2210. //城市税
  2211. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2212. if (cityTaxData != null)
  2213. {
  2214. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2215. cityTaxFee = cityTaxData.Price;
  2216. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2217. if (cityTaxCurrData != null)
  2218. {
  2219. cityTaxCode = cityTaxCurrData.Name;
  2220. cityTaxName = $"({cityTaxCurrData.Remark})";
  2221. }
  2222. }
  2223. //酒店早餐
  2224. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2225. if (breakfastData != null)
  2226. {
  2227. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2228. breakfastFee = breakfastData.Price;
  2229. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2230. if (breakfastCurrData != null)
  2231. {
  2232. breakfastCode = breakfastCurrData.Name;
  2233. breakfastName = $"({breakfastCurrData.Remark})";
  2234. }
  2235. }
  2236. //房间费用
  2237. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2238. if (roomData != null)
  2239. {
  2240. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2241. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2242. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2243. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2244. roomFee = roomData.Price;
  2245. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2246. if (roomCurrData != null)
  2247. {
  2248. roomCode = roomCurrData.Name;
  2249. roomName = $"({roomCurrData.Remark})";
  2250. }
  2251. }
  2252. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2253. string hotelCostStr = "";
  2254. decimal hotelCsotTotal = 0.00M;
  2255. if (groupCost != null)
  2256. {
  2257. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2258. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2259. }
  2260. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2261. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2262. string hotelCost_day = "";
  2263. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2264. foreach (var item in hotelCostDetails1)
  2265. {
  2266. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2267. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2268. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2269. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2270. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2271. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2272. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2273. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2274. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2275. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2276. hotelCost_day += @$"<br/>";
  2277. }
  2278. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2279. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2280. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2281. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2282. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2283. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2284. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2285. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2286. $"房间说明: {hotelReservations.Remark} <br/>" +
  2287. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2288. $"{hotelBreakfastStr}" +
  2289. $"{hotelGovernmentRentStr}" +
  2290. $"{hotelCityTaxStr}";
  2291. _detail.PriceNameContent = hotelReservations.HotelName;
  2292. }
  2293. break;
  2294. case 79://车/导游地接
  2295. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2296. if (touristGuideGroundReservations != null)
  2297. {
  2298. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2299. {
  2300. _detail.BusName = touristGuideGroundReservations.BusName;
  2301. }
  2302. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2303. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2304. //if (isInt)
  2305. //{
  2306. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2307. // if (cityInfo != null)
  2308. // {
  2309. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2310. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2311. // if (carFeeItem != null)
  2312. // {
  2313. // nameContent += $@"({carFeeItem.Name})";
  2314. // }
  2315. // _detail.PriceNameContent = nameContent;
  2316. // }
  2317. //}
  2318. //else
  2319. //{
  2320. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2321. //}
  2322. var touristGuideGroundReservationsContents =
  2323. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2324. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2325. foreach (var item in touristGuideGroundReservationsContents)
  2326. {
  2327. string typeName = "Unknown";
  2328. string carCurrencyCode = "Unknown";
  2329. string carCurrencyName = "Unknown";
  2330. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2331. if (carTypeData != null) typeName = carTypeData.Name;
  2332. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2333. if (currencyData != null)
  2334. {
  2335. carCurrencyCode = currencyData.Name;
  2336. carCurrencyName = currencyData.Remark;
  2337. }
  2338. //op、成本 币种是否一致
  2339. bool IsCurrencyAgreement = false;
  2340. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2341. string opCostStr = string.Empty;
  2342. decimal opCostTypePrice = 0.00M;
  2343. #region 处理成本各项费用
  2344. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2345. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2346. if (opCost.Count > 0)
  2347. {
  2348. switch (item.SId)
  2349. {
  2350. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2351. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2352. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2353. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2354. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2355. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2356. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2357. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2358. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2359. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2360. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2361. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2362. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2363. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2364. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2365. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2366. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2367. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2368. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2369. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2370. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2371. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2372. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2373. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2374. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2375. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2376. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2377. }
  2378. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2379. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2380. }
  2381. #endregion
  2382. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2383. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2384. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2385. $"{opTypeStr} {opCostStr}<br/>" +
  2386. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2387. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2388. }
  2389. _detail.PriceMsgContent = priceMsg;
  2390. }
  2391. break;
  2392. case 80: //签证
  2393. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2394. if (visaInfo != null)
  2395. {
  2396. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2397. _detail.PriceNameContent = visaInfo.VisaDescription;
  2398. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2399. }
  2400. break;
  2401. case 81: //邀请/公务活动
  2402. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2403. if (_ioa != null)
  2404. {
  2405. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2406. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2407. sendCurrName = "Unknown", //快递费用币种 Name
  2408. sendCurrCode = "Unknown", //快递费用币种 Code
  2409. eventsCurrName = "Unknown", //公务活动费币种 Name
  2410. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2411. translateCurrName = "Unknown", //公务翻译费 Name
  2412. translateCurrCode = "Unknown"; //公务翻译费 Code
  2413. #region 处理费用币种
  2414. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2415. if (inviteCurrData != null)
  2416. {
  2417. inviteCurrName = inviteCurrData.Remark;
  2418. inviteCurrCode = inviteCurrData.Name;
  2419. }
  2420. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2421. if (sendCurrData != null)
  2422. {
  2423. sendCurrName = sendCurrData.Remark;
  2424. sendCurrCode = sendCurrData.Name;
  2425. }
  2426. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2427. if (eventsCurrData != null)
  2428. {
  2429. eventsCurrName = eventsCurrData.Remark;
  2430. eventsCurrCode = eventsCurrData.Name;
  2431. }
  2432. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2433. if (translateCurrData != null)
  2434. {
  2435. translateCurrName = translateCurrData.Remark;
  2436. translateCurrCode = translateCurrData.Name;
  2437. }
  2438. #endregion
  2439. _detail.PriceNameContent = _ioa.InviterArea;
  2440. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2441. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2442. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2443. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2444. $@"备注:" + _ioa.Remark + "<br/>";
  2445. }
  2446. break;
  2447. case 82: //团组客户保险
  2448. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2449. if (customers != null)
  2450. {
  2451. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2452. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2453. }
  2454. break;
  2455. case 85: //机票预订
  2456. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2457. if (jpRes != null)
  2458. {
  2459. string FlightsDescription = jpRes.FlightsDescription;
  2460. string PriceDescription = jpRes.PriceDescription;
  2461. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2462. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2463. }
  2464. break;
  2465. case 98://其他款项
  2466. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2467. if (gdpRes != null)
  2468. {
  2469. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2470. _detail.PriceNameContent = gdpRes.PriceName;
  2471. }
  2472. break;
  2473. case 285://收款退还
  2474. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2475. if (refundAndOtherMoney != null)
  2476. {
  2477. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2478. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2479. }
  2480. break;
  2481. case 751://酒店早餐
  2482. break;
  2483. case 1015://超支费用
  2484. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2485. if (groupExtraCost != null)
  2486. {
  2487. _detail.PriceNameContent = groupExtraCost.PriceName;
  2488. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2489. }
  2490. break;
  2491. default:
  2492. break;
  2493. }
  2494. /*
  2495. * 申请人
  2496. */
  2497. string operatorName = " - ";
  2498. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2499. if (_opUser != null)
  2500. {
  2501. operatorName = _opUser.CnName;
  2502. }
  2503. _detail.OperatorName = operatorName;
  2504. /*
  2505. * 审核人
  2506. */
  2507. string auditOperatorName = "Unknown";
  2508. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2509. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2510. else
  2511. {
  2512. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2513. if (_adUser != null)
  2514. {
  2515. auditOperatorName = _adUser.CnName;
  2516. }
  2517. }
  2518. _detail.AuditOperatorName = auditOperatorName;
  2519. /*
  2520. * 超预算比例
  2521. */
  2522. string overBudgetStr = "";
  2523. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2524. else if (entity.ExceedBudget == 0)
  2525. {
  2526. if (entity.CTable == 76 || entity.CTable == 79)
  2527. {
  2528. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2529. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2530. }
  2531. else
  2532. {
  2533. overBudgetStr = "未超预算";
  2534. }
  2535. }
  2536. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2537. _detail.OverBudget = overBudgetStr;
  2538. decimal auditFee = 0.00M; //已审核金额 人名币
  2539. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2540. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2541. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2542. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2543. {
  2544. auditedFeeOriginal = entity.PayMoney;
  2545. auditFee = CurrPayStr;
  2546. }
  2547. else if (entity.IsAuditGM == 0)
  2548. {
  2549. unAuditFeeCNY = CurrPayStr;
  2550. unAuditFeeOriginal = OriginalCurrPay;
  2551. OriginalCurrPay = 0.00M;
  2552. }
  2553. /*
  2554. * 费用总计
  2555. */
  2556. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2557. {
  2558. CurrencyId = entity.PaymentCurrency,
  2559. CurrencyName = PaymentCurrency_WaitPay,
  2560. AmountPayable = entity.PayMoney,
  2561. ThisPayment = OriginalCurrPay,
  2562. BalancePayment = BalanceStr,
  2563. AuditedFunds = auditFee,
  2564. AuditedFundsOriginal = auditedFeeOriginal,
  2565. UnAuditFundsCNY = unAuditFeeCNY,
  2566. UnAuditFundsOriginal = unAuditFeeOriginal
  2567. });
  2568. _detail.IsAuditGM = entity.IsAuditGM;
  2569. detailList.Add(_detail);
  2570. }
  2571. #endregion
  2572. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2573. /*
  2574. * 下方描述处理
  2575. */
  2576. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2577. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2578. if (ccpCurrencyPrice != null)
  2579. {
  2580. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2581. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2582. }
  2583. else
  2584. {
  2585. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2586. }
  2587. string amountPayableStr = string.Format(@"应付款总金额: ");
  2588. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2589. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2590. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2591. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2592. foreach (var item in nonDuplicat)
  2593. {
  2594. var currencyName = item.CurrencyName;
  2595. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2596. if (strs.Count > 0)
  2597. {
  2598. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2599. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2600. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2601. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2602. //单独处理此次付款金额
  2603. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2604. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2605. //单独处理已审核费用
  2606. //if (item.CurrencyId == 836) //人民币
  2607. //{
  2608. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2609. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2610. //}
  2611. //else
  2612. //{
  2613. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2614. //}
  2615. if (currencyName.Equals("CNY"))
  2616. {
  2617. //已审核费用
  2618. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2619. //未审核费用
  2620. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2621. }
  2622. else
  2623. {
  2624. //已审核费用
  2625. 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"));
  2626. //未审核费用
  2627. 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"));
  2628. }
  2629. }
  2630. }
  2631. _view.TotalStr1 = amountPayableStr[..^1];
  2632. _view.TotalStr2 = thisPaymentStr[..^1];
  2633. _view.TotalStr3 = balancePaymentStr[..^1];
  2634. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2635. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2636. var _view1 = new
  2637. {
  2638. PageFuncAuth = pageFunAuthView,
  2639. Data = _view
  2640. };
  2641. return Ok(JsonView(_view1));
  2642. }
  2643. catch (Exception ex)
  2644. {
  2645. return Ok(JsonView(false, ex.Message));
  2646. }
  2647. }
  2648. /// <summary>
  2649. /// 费用审核
  2650. /// 修改团组费用审核状态
  2651. /// </summary>
  2652. /// <param name="_dto">参数Json字符串</param>
  2653. /// <returns></returns>
  2654. [HttpPost]
  2655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2656. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2657. {
  2658. #region 参数验证
  2659. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2660. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2661. #endregion
  2662. #region 页面操作权限验证
  2663. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2664. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2665. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2666. #endregion
  2667. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2668. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2669. DateTime dtNow = DateTime.Now;
  2670. _groupRepository.BeginTran();
  2671. int rst = 0;
  2672. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2673. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2674. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2675. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2676. List<dynamic> msgDatas = new List<dynamic>();
  2677. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2678. foreach (var item in idList)
  2679. {
  2680. int CreditId = int.Parse(item);
  2681. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2682. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2683. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2684. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2685. .Where(s => s.Id == CreditId)
  2686. .ExecuteCommandAsync();
  2687. if (result < 1)
  2688. {
  2689. rst = -1;
  2690. _groupRepository.RollbackTran();
  2691. return Ok(JsonView(false, "操作失败并回滚!"));
  2692. }
  2693. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2694. if (creditData != null)
  2695. {
  2696. #region 应用通知配置
  2697. try
  2698. {
  2699. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2700. }
  2701. catch (Exception ex)
  2702. {
  2703. }
  2704. #endregion
  2705. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2706. string groupNameStr = string.Empty;
  2707. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2708. if (groupData != null) groupNameStr = groupData.TeamName;
  2709. string creditTypeStr = string.Empty;
  2710. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2711. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2712. string creditCurrency = string.Empty;
  2713. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2714. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2715. if (creditCurrency.Equals("CNY"))
  2716. {
  2717. creditData.DayRate = 1.0000M;
  2718. }
  2719. if (creditData.PayPercentage == 0.00M)
  2720. {
  2721. creditData.PayPercentage = 100M;
  2722. }
  2723. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2724. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2725. string msgContent = "";
  2726. if (creditCurrency.Equals("CNY"))
  2727. {
  2728. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2729. }
  2730. else
  2731. {
  2732. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2733. }
  2734. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2735. }
  2736. }
  2737. if (rst == 0)
  2738. {
  2739. _groupRepository.CommitTran();
  2740. foreach (var item in msgDatas)
  2741. {
  2742. //发送消息
  2743. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2744. }
  2745. #region 应用推送
  2746. try
  2747. {
  2748. foreach (var ccpId in dic_ccp_user.Keys)
  2749. {
  2750. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2751. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2752. }
  2753. }
  2754. catch (Exception)
  2755. {
  2756. }
  2757. #endregion
  2758. return Ok(JsonView(true, "操作成功!"));
  2759. }
  2760. return Ok(JsonView(false, "操作失败!"));
  2761. }
  2762. #endregion
  2763. #region 机票费用录入
  2764. /// <summary>
  2765. /// 机票录入当前登录人可操作团组
  2766. /// </summary>
  2767. /// <param name="dto"></param>
  2768. /// <returns></returns>
  2769. [HttpPost]
  2770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2771. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2772. {
  2773. try
  2774. {
  2775. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2776. if (groupData.Code != 0)
  2777. {
  2778. return Ok(JsonView(false, groupData.Msg));
  2779. }
  2780. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2781. }
  2782. catch (Exception ex)
  2783. {
  2784. return Ok(JsonView(false, "程序错误!"));
  2785. throw;
  2786. }
  2787. }
  2788. /// <summary>
  2789. /// 机票费用录入列表
  2790. /// </summary>
  2791. /// <param name="dto"></param>
  2792. /// <returns></returns>
  2793. [HttpPost]
  2794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2795. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2796. {
  2797. try
  2798. {
  2799. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2800. if (groupData.Code != 0)
  2801. {
  2802. return Ok(JsonView(false, groupData.Msg));
  2803. }
  2804. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2805. }
  2806. catch (Exception ex)
  2807. {
  2808. return Ok(JsonView(false, ex.Message));
  2809. throw;
  2810. }
  2811. }
  2812. /// <summary>
  2813. /// 根据id查询费用录入信息
  2814. /// </summary>
  2815. /// <param name="dto"></param>
  2816. /// <returns></returns>
  2817. [HttpPost]
  2818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2819. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2820. {
  2821. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2822. if (groupData.Code != 0)
  2823. {
  2824. return Ok(JsonView(false, groupData.Msg));
  2825. }
  2826. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2827. }
  2828. /// <summary>
  2829. /// 机票费用录入操作(Status:1.新增,2.修改)
  2830. /// </summary>
  2831. /// <param name="dto"></param>
  2832. /// <returns></returns>
  2833. [HttpPost]
  2834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2835. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2836. {
  2837. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2838. if (groupData.Code != 0)
  2839. {
  2840. return Ok(JsonView(false, groupData.Msg));
  2841. }
  2842. #region 应用推送
  2843. try
  2844. {
  2845. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2846. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2847. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2848. //2024-10-21 新增LZ UID
  2849. var userIds = new List<int>() { 21 };
  2850. string title = $"系统通知";
  2851. string content = "";
  2852. var diId = dto.AirTicketResOpData.DiId;
  2853. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2854. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2855. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2856. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2857. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2858. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2859. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2860. }
  2861. catch (Exception ex)
  2862. {
  2863. }
  2864. #endregion
  2865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2866. }
  2867. /// <summary>
  2868. /// 根据舱位类型查询接团客户名单信息
  2869. /// </summary>
  2870. /// <param name="dto"></param>
  2871. /// <returns></returns>
  2872. [HttpPost]
  2873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2874. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2875. {
  2876. try
  2877. {
  2878. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2879. if (crm_Groups.Count != 0)
  2880. {
  2881. List<dynamic> Customer = new List<dynamic>();
  2882. foreach (var item in crm_Groups)
  2883. {
  2884. var data = new
  2885. {
  2886. Id = item.Id,
  2887. Pinyin = item.Pinyin,
  2888. Name = item.LastName + item.FirstName
  2889. };
  2890. Customer.Add(data);
  2891. }
  2892. return Ok(JsonView(true, "查询成功!", Customer));
  2893. }
  2894. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2895. }
  2896. catch (Exception ex)
  2897. {
  2898. return Ok(JsonView(false, "程序错误!"));
  2899. throw;
  2900. }
  2901. }
  2902. /// <summary>
  2903. /// 根据团号获取客户信息
  2904. /// </summary>
  2905. /// <param name="dto"></param>
  2906. /// <returns></returns>
  2907. [HttpPost]
  2908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2909. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2910. {
  2911. var jw = JsonView(false);
  2912. if (dto.DIID < 1)
  2913. {
  2914. jw.Msg += "请输入正确的diid";
  2915. return Ok(jw);
  2916. }
  2917. var arr = getSimplClientList(dto.DIID);
  2918. jw = JsonView(true, "获取成功!", arr);
  2919. return Ok(jw);
  2920. }
  2921. private List<SimplClientInfo> getSimplClientList(int diId)
  2922. {
  2923. 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);
  2924. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2925. foreach (var item in arr)
  2926. {
  2927. EncryptionProcessor.DecryptProperties(item);
  2928. }
  2929. return arr;
  2930. }
  2931. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2932. {
  2933. string result = origin;
  2934. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2935. {
  2936. string[] temparr = origin.Split(',');
  2937. string fistrStr = temparr[0];
  2938. int count = temparr.Count();
  2939. int tempId;
  2940. bool success = int.TryParse(fistrStr, out tempId);
  2941. if (success)
  2942. {
  2943. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2944. if (tempInfo != null)
  2945. {
  2946. if (count > 1)
  2947. {
  2948. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2949. }
  2950. else
  2951. {
  2952. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2953. }
  2954. }
  2955. }
  2956. }
  2957. return result;
  2958. }
  2959. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2960. {
  2961. string result = origin;
  2962. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2963. {
  2964. string[] temparr = origin.Split(',');
  2965. result = "";
  2966. foreach (var item in temparr)
  2967. {
  2968. int tempId;
  2969. bool success = int.TryParse(item, out tempId);
  2970. if (success)
  2971. {
  2972. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2973. if (tempInfo != null)
  2974. {
  2975. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2976. }
  2977. }
  2978. }
  2979. }
  2980. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2981. return result;
  2982. }
  2983. /// <summary>
  2984. /// 机票费用录入,删除
  2985. /// </summary>
  2986. /// <param name="dto"></param>
  2987. /// <returns></returns>
  2988. [HttpPost]
  2989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2990. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2991. {
  2992. try
  2993. {
  2994. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2995. if (res)
  2996. {
  2997. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2998. {
  2999. IsDel = 1,
  3000. DeleteUserId = dto.DeleteUserId,
  3001. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3002. }).ExecuteCommandAsync();
  3003. return Ok(JsonView(true, "删除成功!"));
  3004. }
  3005. return Ok(JsonView(false, "删除失败!"));
  3006. }
  3007. catch (Exception ex)
  3008. {
  3009. return Ok(JsonView(false, "程序错误!"));
  3010. throw;
  3011. }
  3012. }
  3013. /// <summary>
  3014. /// 导出机票录入报表
  3015. /// </summary>
  3016. /// <param name="dto"></param>
  3017. /// <returns></returns>
  3018. [HttpPost]
  3019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3020. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3021. {
  3022. try
  3023. {
  3024. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3025. if (groupData.Code != 0)
  3026. {
  3027. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3028. }
  3029. else
  3030. {
  3031. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3032. if (AirTicketReservations.Count != 0)
  3033. {
  3034. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3035. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3036. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3037. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3038. WorkbookDesigner designer = new WorkbookDesigner();
  3039. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3040. decimal countCost = 0;
  3041. foreach (var item in AirTicketReservations)
  3042. {
  3043. #region 处理客人姓名
  3044. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3045. item.ClientName = clientNames;
  3046. #endregion
  3047. if (item.BankType == "其他")
  3048. {
  3049. item.BankNo = "--";
  3050. }
  3051. else
  3052. {
  3053. if (!string.IsNullOrEmpty(item.BankType))
  3054. {
  3055. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3056. }
  3057. }
  3058. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3059. item.Price = System.Decimal.Round(item.Price, 2);
  3060. countCost += Convert.ToDecimal(item.Price);
  3061. }
  3062. designer.SetDataSource("Export", AirTicketReservations);
  3063. designer.SetDataSource("ExportDiCode", diCode);
  3064. designer.SetDataSource("ExportDiName", diName);
  3065. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3066. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3067. designer.Process();
  3068. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3069. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3070. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3071. return Ok(JsonView(true, "成功", url = rst));
  3072. }
  3073. else
  3074. {
  3075. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3076. }
  3077. }
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3082. throw;
  3083. }
  3084. }
  3085. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3086. /// <summary>
  3087. /// 行程单导出
  3088. /// </summary>
  3089. /// <param name="dto"></param>
  3090. /// <returns></returns>
  3091. [HttpPost]
  3092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3093. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3094. {
  3095. try
  3096. {
  3097. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3098. if (groupData.Code != 0)
  3099. {
  3100. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3101. }
  3102. else
  3103. {
  3104. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3105. if (dto.Language == "CN")
  3106. {
  3107. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3108. DocumentBuilder builder = new DocumentBuilder(doc);
  3109. int tableIndex = 0;//表格索引
  3110. //得到文档中的第一个表格
  3111. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3112. foreach (var item in _AirTicketReservations)
  3113. {
  3114. #region 处理固定数据
  3115. string[] FlightsCode = item.FlightsCode.Split('/');
  3116. if (FlightsCode.Length != 0)
  3117. {
  3118. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3119. if (_AirCompany != null)
  3120. {
  3121. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3122. }
  3123. else
  3124. {
  3125. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3126. }
  3127. }
  3128. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3129. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3130. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3131. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3132. string name = "";
  3133. foreach (string clientName in nameArray)
  3134. {
  3135. if (!name.Contains(clientName))
  3136. {
  3137. name += clientName + ",";
  3138. }
  3139. }
  3140. if (!string.IsNullOrWhiteSpace(name))
  3141. {
  3142. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3143. }
  3144. else
  3145. {
  3146. table.Range.Bookmarks["ClientName"].Text = "--";
  3147. }
  3148. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3149. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3150. table.Range.Bookmarks["JointTicket"].Text = "--";
  3151. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3152. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3153. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3154. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3155. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3156. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3157. #endregion
  3158. #region 循环数据处理
  3159. List<AirInfo> airs = new List<AirInfo>();
  3160. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3161. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3162. for (int i = 0; i < FlightsCode.Length; i++)
  3163. {
  3164. AirInfo air = new AirInfo();
  3165. string[] tempstr = DayArray[i]
  3166. .Replace("\r\n", string.Empty)
  3167. .Replace("\\r\\n", string.Empty)
  3168. .TrimStart().TrimEnd()
  3169. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3170. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3171. string starCity = "";
  3172. if (star_Three != null)
  3173. {
  3174. starCity = star_Three.AirPort;
  3175. }
  3176. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3177. string EndCity = "";
  3178. if (End_Three != null)
  3179. {
  3180. EndCity = End_Three.AirPort;
  3181. }
  3182. air.Destination = starCity + "/" + EndCity;
  3183. air.Flight = FlightsCode[i];
  3184. air.SeatingClass = item.CTypeName;
  3185. string dateTime = tempstr[2];
  3186. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3187. air.FlightDate = DateTemp;
  3188. air.DepartureTime = tempstr[5];
  3189. air.LandingTime = tempstr[6];
  3190. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3191. air.TicketStatus = "--";
  3192. air.Luggage = "--";
  3193. air.DepartureTerminal = "--";
  3194. air.LandingTerminal = "--";
  3195. airs.Add(air);
  3196. }
  3197. int row = 13;
  3198. for (int i = 0; i < airs.Count; i++)
  3199. {
  3200. if (airs.Count > 2)
  3201. {
  3202. for (int j = 0; j < airs.Count - 2; j++)
  3203. {
  3204. var CopyRow = table.Rows[12].Clone(true);
  3205. table.Rows.Add(CopyRow);
  3206. }
  3207. }
  3208. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3209. int index = 0;
  3210. foreach (PropertyInfo property in properties)
  3211. {
  3212. string value = property.GetValue(airs[i]).ToString();
  3213. Cell ishcel0 = table.Rows[row].Cells[index];
  3214. Paragraph p = new Paragraph(doc);
  3215. string s = value;
  3216. p.AppendChild(new Run(doc, s));
  3217. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3218. ishcel0.AppendChild(p);
  3219. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3220. index++;
  3221. }
  3222. row++;
  3223. }
  3224. #endregion
  3225. Paragraph lastParagraph = new Paragraph(doc);
  3226. //第一个表格末尾加段落
  3227. table.ParentNode.InsertAfter(lastParagraph, table);
  3228. //复制第一个表格
  3229. Table cloneTable = (Table)table.Clone(true);
  3230. //在文档末尾段落后面加入复制的表格
  3231. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3232. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3233. {
  3234. int rownewsIndex = 13;
  3235. for (int i = 0; i < 2; i++)
  3236. {
  3237. var CopyRow = table.Rows[12].Clone(true);
  3238. table.Rows.RemoveAt(13);
  3239. table.Rows.Add(CopyRow);
  3240. rownewsIndex++;
  3241. }
  3242. }
  3243. else
  3244. {
  3245. table.Rows.RemoveAt(12);
  3246. }
  3247. cloneTable.Rows.RemoveAt(12);
  3248. }
  3249. if (_AirTicketReservations.Count != 0)
  3250. {
  3251. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3252. if (FlightsCode.Length != 0)
  3253. {
  3254. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3255. if (_AirCompany != null)
  3256. {
  3257. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3258. }
  3259. else
  3260. {
  3261. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3262. }
  3263. }
  3264. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3265. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3266. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3267. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3268. string name = "";
  3269. foreach (string clientName in nameArray)
  3270. {
  3271. if (!name.Contains(clientName))
  3272. {
  3273. name += clientName + ",";
  3274. }
  3275. }
  3276. if (!string.IsNullOrWhiteSpace(name))
  3277. {
  3278. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3279. }
  3280. else
  3281. {
  3282. table.Range.Bookmarks["ClientName"].Text = "--";
  3283. }
  3284. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3285. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3286. table.Range.Bookmarks["JointTicket"].Text = "--";
  3287. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3288. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3289. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3290. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3291. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3292. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3293. }
  3294. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3295. //保存合并后的文档
  3296. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3297. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3298. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3299. return Ok(JsonView(true, "成功!", rst));
  3300. }
  3301. else
  3302. {
  3303. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3304. DocumentBuilder builder = new DocumentBuilder(doc);
  3305. int tableIndex = 0;//表格索引
  3306. //得到文档中的第一个表格
  3307. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3308. List<string> texts = new List<string>();
  3309. foreach (var item in _AirTicketReservations)
  3310. {
  3311. string[] FlightsCode = item.FlightsCode.Split('/');
  3312. if (FlightsCode.Length != 0)
  3313. {
  3314. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3315. if (_AirCompany != null)
  3316. {
  3317. if (!transDic.ContainsKey(_AirCompany.CnName))
  3318. {
  3319. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3320. }
  3321. }
  3322. else
  3323. {
  3324. if (!transDic.ContainsKey("--"))
  3325. {
  3326. transDic.Add("--", "--");
  3327. }
  3328. }
  3329. }
  3330. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3331. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3332. string name = "";
  3333. foreach (string clientName in nameArray)
  3334. {
  3335. name += clientName + ",";
  3336. }
  3337. if (!texts.Contains(name))
  3338. {
  3339. texts.Add(name);
  3340. }
  3341. List<AirInfo> airs = new List<AirInfo>();
  3342. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3343. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3344. for (int i = 0; i < FlightsCode.Length; i++)
  3345. {
  3346. AirInfo air = new AirInfo();
  3347. string[] tempstr = DayArray[i]
  3348. .Replace("\r\n", string.Empty)
  3349. .Replace("\\r\\n", string.Empty)
  3350. .TrimStart().TrimEnd()
  3351. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3352. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3353. if (star_Three != null)
  3354. {
  3355. if (!transDic.ContainsKey(star_Three.AirPort))
  3356. {
  3357. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3358. }
  3359. }
  3360. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3361. if (End_Three != null)
  3362. {
  3363. if (!transDic.ContainsKey(End_Three.AirPort))
  3364. {
  3365. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3366. }
  3367. }
  3368. if (!texts.Contains(item.CTypeName))
  3369. {
  3370. texts.Add(item.CTypeName);
  3371. }
  3372. }
  3373. }
  3374. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3375. if (transData.Count > 0)
  3376. {
  3377. foreach (TranslateResult item in transData)
  3378. {
  3379. if (!transDic.ContainsKey(item.Query))
  3380. {
  3381. transDic.Add(item.Query, item.Translation);
  3382. }
  3383. }
  3384. }
  3385. foreach (var item in _AirTicketReservations)
  3386. {
  3387. #region 处理固定数据
  3388. string[] FlightsCode = item.FlightsCode.Split('/');
  3389. if (FlightsCode.Length != 0)
  3390. {
  3391. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3392. if (_AirCompany != null)
  3393. {
  3394. string str = "--";
  3395. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3396. if (!string.IsNullOrEmpty(translateResult))
  3397. {
  3398. str = translateResult;
  3399. str = _airTicketResRep.Processing(str);
  3400. }
  3401. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3402. }
  3403. else
  3404. {
  3405. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3406. }
  3407. }
  3408. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3409. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3410. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3411. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3412. string names = "";
  3413. foreach (string clientName in nameArray)
  3414. {
  3415. names += clientName + ",";
  3416. }
  3417. if (!string.IsNullOrWhiteSpace(names))
  3418. {
  3419. string str = "--";
  3420. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3421. if (!string.IsNullOrEmpty(translateResult))
  3422. {
  3423. str = translateResult;
  3424. str = _airTicketResRep.Processing(str);
  3425. }
  3426. table.Range.Bookmarks["ClientName"].Text = str;
  3427. }
  3428. else
  3429. {
  3430. table.Range.Bookmarks["ClientName"].Text = "--";
  3431. }
  3432. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3433. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3434. table.Range.Bookmarks["JointTicket"].Text = "--";
  3435. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3436. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3437. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3438. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3439. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3440. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3441. #endregion
  3442. #region 循环数据处理
  3443. List<AirInfo> airs = new List<AirInfo>();
  3444. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3445. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3446. for (int i = 0; i < FlightsCode.Length; i++)
  3447. {
  3448. AirInfo air = new AirInfo();
  3449. string[] tempstr = DayArray[i]
  3450. .Replace("\r\n", string.Empty)
  3451. .Replace("\\r\\n", string.Empty)
  3452. .TrimStart().TrimEnd()
  3453. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3454. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3455. string starCity = "";
  3456. if (star_Three != null)
  3457. {
  3458. string str2 = "--";
  3459. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3460. if (!string.IsNullOrEmpty(translateResult2))
  3461. {
  3462. str2 = translateResult2;
  3463. str2 = _airTicketResRep.Processing(str2);
  3464. }
  3465. starCity = str2;
  3466. }
  3467. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3468. string EndCity = "";
  3469. if (End_Three != null)
  3470. {
  3471. string str1 = "--";
  3472. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3473. if (!string.IsNullOrEmpty(translateResult1))
  3474. {
  3475. str1 = translateResult1;
  3476. str1 = _airTicketResRep.Processing(str1);
  3477. }
  3478. EndCity = str1;
  3479. }
  3480. air.Destination = starCity + "/" + EndCity;
  3481. air.Flight = FlightsCode[i];
  3482. string str = "--";
  3483. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3484. if (!string.IsNullOrEmpty(translateResult))
  3485. {
  3486. str = translateResult;
  3487. str = _airTicketResRep.Processing(str);
  3488. }
  3489. air.SeatingClass = str;
  3490. string dateTime = tempstr[2];
  3491. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3492. air.FlightDate = DateTemp;
  3493. air.DepartureTime = tempstr[5];
  3494. air.LandingTime = tempstr[6];
  3495. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3496. air.TicketStatus = "--";
  3497. air.Luggage = "--";
  3498. air.DepartureTerminal = "--";
  3499. air.LandingTerminal = "--";
  3500. airs.Add(air);
  3501. }
  3502. int row = 13;
  3503. for (int i = 0; i < airs.Count; i++)
  3504. {
  3505. if (airs.Count > 2)
  3506. {
  3507. for (int j = 0; j < airs.Count - 2; j++)
  3508. {
  3509. var CopyRow = table.Rows[12].Clone(true);
  3510. table.Rows.Add(CopyRow);
  3511. }
  3512. }
  3513. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3514. int index = 0;
  3515. foreach (PropertyInfo property in properties)
  3516. {
  3517. string value = property.GetValue(airs[i]).ToString();
  3518. Cell ishcel0 = table.Rows[row].Cells[index];
  3519. Paragraph p = new Paragraph(doc);
  3520. string s = value;
  3521. p.AppendChild(new Run(doc, s));
  3522. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3523. ishcel0.AppendChild(p);
  3524. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3525. //ishcel0.CellFormat.VerticalAlignment=
  3526. index++;
  3527. }
  3528. row++;
  3529. }
  3530. #endregion
  3531. Paragraph lastParagraph = new Paragraph(doc);
  3532. //第一个表格末尾加段落
  3533. table.ParentNode.InsertAfter(lastParagraph, table);
  3534. //复制第一个表格
  3535. Table cloneTable = (Table)table.Clone(true);
  3536. //在文档末尾段落后面加入复制的表格
  3537. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3538. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3539. {
  3540. int rownewsIndex = 13;
  3541. for (int i = 0; i < 2; i++)
  3542. {
  3543. var CopyRow = table.Rows[12].Clone(true);
  3544. table.Rows.RemoveAt(13);
  3545. table.Rows.Add(CopyRow);
  3546. rownewsIndex++;
  3547. }
  3548. }
  3549. else
  3550. {
  3551. table.Rows.RemoveAt(12);
  3552. }
  3553. cloneTable.Rows.RemoveAt(12);
  3554. }
  3555. if (_AirTicketReservations.Count != 0)
  3556. {
  3557. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3558. if (FlightsCode.Length != 0)
  3559. {
  3560. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3561. if (_AirCompany != null)
  3562. {
  3563. string str = "--";
  3564. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3565. if (!string.IsNullOrEmpty(translateResult))
  3566. {
  3567. str = translateResult;
  3568. str = _airTicketResRep.Processing(str);
  3569. }
  3570. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3571. }
  3572. else
  3573. {
  3574. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3575. }
  3576. }
  3577. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3578. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3579. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3580. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3581. string names = "";
  3582. foreach (string clientName in nameArray)
  3583. {
  3584. names += clientName + ",";
  3585. }
  3586. if (!string.IsNullOrWhiteSpace(names))
  3587. {
  3588. string str = "--";
  3589. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3590. if (!string.IsNullOrEmpty(translateResult))
  3591. {
  3592. str = translateResult;
  3593. str = _airTicketResRep.Processing(str);
  3594. }
  3595. table.Range.Bookmarks["ClientName"].Text = str;
  3596. }
  3597. else
  3598. {
  3599. table.Range.Bookmarks["ClientName"].Text = "--";
  3600. }
  3601. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3602. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3603. table.Range.Bookmarks["JointTicket"].Text = "--";
  3604. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3605. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3606. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3607. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3608. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3609. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3610. }
  3611. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3612. //保存合并后的文档
  3613. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3614. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3615. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3616. return Ok(JsonView(true, "成功!", rst));
  3617. }
  3618. }
  3619. }
  3620. catch (Exception ex)
  3621. {
  3622. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3623. throw;
  3624. }
  3625. }
  3626. #endregion
  3627. #region 团组增减款项 --> 其他款项
  3628. /// <summary>
  3629. /// 团组增减款项下拉框绑定
  3630. /// </summary>
  3631. /// <param name="dto"></param>
  3632. /// <returns></returns>
  3633. [HttpPost]
  3634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3635. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3636. {
  3637. #region 参数验证
  3638. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3639. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3640. #endregion
  3641. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3642. }
  3643. /// <summary>
  3644. /// 根据团组Id查询团组增减款项
  3645. /// </summary>
  3646. /// <param name="dto"></param>
  3647. /// <returns></returns>
  3648. [HttpPost]
  3649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3650. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3651. {
  3652. #region 参数验证
  3653. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3654. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3655. #endregion
  3656. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3657. }
  3658. /// <summary>
  3659. /// 团组增减款项操作(Status:1.新增,2.修改)
  3660. /// </summary>
  3661. /// <param name="dto"></param>
  3662. /// <returns></returns>
  3663. [HttpPost]
  3664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3665. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3666. {
  3667. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3668. if (groupData.Code != 200)
  3669. {
  3670. return Ok(JsonView(false, groupData.Msg));
  3671. }
  3672. #region 应用推送
  3673. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3674. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3675. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3676. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3677. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3678. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3679. //自动审核
  3680. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3681. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3682. //2024-10-21 新增LZ UID
  3683. var userIds = new List<int>() { 21 };
  3684. string title = $"系统通知";
  3685. string content = "";
  3686. var diId = dto.DiId;
  3687. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3688. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3689. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3690. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3691. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3692. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3693. #endregion
  3694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3695. }
  3696. /// <summary>
  3697. /// 团组增减款项操作 删除
  3698. /// </summary>
  3699. /// <param name="dto"></param>
  3700. /// <returns></returns>
  3701. [HttpPost]
  3702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3703. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3704. {
  3705. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3706. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3707. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3708. if (res.Code == 0)
  3709. {
  3710. return Ok(JsonView(true, "删除成功!"));
  3711. }
  3712. return Ok(JsonView(false, "删除失败!"));
  3713. }
  3714. /// <summary>
  3715. /// 根据团组增减款项Id查询
  3716. /// </summary>
  3717. /// <param name="dto"></param>
  3718. /// <returns></returns>
  3719. [HttpPost]
  3720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3721. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3722. {
  3723. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3724. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3725. }
  3726. /// <summary>
  3727. /// 查询供应商名称
  3728. /// </summary>
  3729. /// <param name="dto"></param>
  3730. /// <returns></returns>
  3731. [HttpPost]
  3732. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3733. {
  3734. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3735. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3736. ?? new List<Grp_DecreasePayments>();
  3737. dbResult = dbResult.Distinct(new
  3738. ProductComparer()).ToList();
  3739. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3740. {
  3741. x.Id,
  3742. x.SupplierAddress,
  3743. x.SupplierArea,
  3744. x.SupplierContact,
  3745. x.SupplierContactNumber,
  3746. x.SupplierEmail,
  3747. x.SupplierName,
  3748. x.SupplierSocialAccount,
  3749. x.SupplierTypeId,
  3750. }).ToList());
  3751. return Ok(jw);
  3752. }
  3753. /// <summary>
  3754. /// 团组增减款项 OTA匹配
  3755. /// </summary>
  3756. /// <param name="file"></param>
  3757. /// <returns></returns>
  3758. [HttpPost]
  3759. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3760. {
  3761. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3762. string fileName = file.FileName;
  3763. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3764. {
  3765. return Ok(JsonView(false, "请上传Excel文件!"));
  3766. }
  3767. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3768. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3769. if (!Directory.Exists(path))
  3770. {
  3771. Directory.CreateDirectory(path);
  3772. }
  3773. var filePath = @$"{path}/{fileName}";
  3774. //保存文件
  3775. using (FileStream fs = System.IO.File.Create(filePath))
  3776. {
  3777. file.CopyTo(fs);
  3778. fs.Flush();
  3779. }
  3780. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3781. //读取ExcelFile
  3782. DataTable dt = ConvertExcelToDataTable(filePath);
  3783. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3784. dt.TableName = "TB";
  3785. //修改table列名
  3786. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3787. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3788. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3789. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3790. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3791. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3792. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3793. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3794. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3795. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3796. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3797. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3798. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3799. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3800. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3801. var otaOrderNos = new List<string>();
  3802. foreach (DataRow item in dt.Rows)
  3803. {
  3804. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3805. }
  3806. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3807. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3808. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3809. .Select((dp, di) => new
  3810. {
  3811. dp.PriceName,
  3812. dp.OTAOrderNo,
  3813. dp.FeeTotal,
  3814. di.TeamName,
  3815. })
  3816. .ToListAsync();
  3817. foreach (DataRow item in dt.Rows)
  3818. {
  3819. var otaOrderNo = item["OTAOrderNo"].ToString();
  3820. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3821. if (oaData == null) continue;
  3822. item["GroupName"] = oaData.TeamName;
  3823. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3824. }
  3825. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3826. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3827. List<DataTable> datas = new List<DataTable>();
  3828. datas.Add(dt);
  3829. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3830. return Ok(JsonView(true, "操作成功", new { url = url }));
  3831. }
  3832. #region
  3833. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3834. {
  3835. // 创建Workbook对象
  3836. Workbook workbook = new Workbook(excelFilePath);
  3837. // 获取第一个工作表
  3838. Worksheet worksheet = workbook.Worksheets[0];
  3839. // 将工作表转换为DataTable
  3840. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3841. return dataTable;
  3842. }
  3843. #endregion
  3844. #endregion
  3845. #region 文件上传、删除
  3846. /// <summary>
  3847. /// region 文件上传 可以带参数
  3848. /// </summary>
  3849. /// <param name="file"></param>
  3850. /// <returns></returns>
  3851. [HttpPost]
  3852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3853. public async Task<IActionResult> UploadProject(IFormFile file)
  3854. {
  3855. //var TypeName = Request.Headers["TypeName"].ToString();
  3856. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3857. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3858. ////文件名称
  3859. //string projectFileName = file.FileName;
  3860. ////上传的文件的路径
  3861. //string filePath = $"{fileDir}/{projectFileName}";
  3862. //if (TypeName == "A")//A代表团组增减款项
  3863. //{
  3864. // filePath = fileDir + $@"\团组增减款项相关文件";
  3865. // if (!Directory.Exists(filePath))
  3866. // {
  3867. // Directory.CreateDirectory(filePath);
  3868. // }
  3869. // //上传的文件的路径
  3870. // filePath += $@"\{projectFileName}";
  3871. //}
  3872. //else if (TypeName == "B")//B代表商邀相关文件
  3873. //{
  3874. // //上传的文件的路径
  3875. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3876. // if (!Directory.Exists(filePath))
  3877. // {
  3878. // Directory.CreateDirectory(filePath);
  3879. // }
  3880. // //上传的文件的路径
  3881. // filePath = $@"\{projectFileName}";
  3882. //}
  3883. //try
  3884. //{
  3885. // using (FileStream fs = System.IO.File.Create(filePath))
  3886. // {
  3887. // file.CopyTo(fs);
  3888. // fs.Flush();
  3889. // }
  3890. //}
  3891. //catch (Exception ex)
  3892. //{
  3893. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3894. //}
  3895. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3896. try
  3897. {
  3898. var TypeName = Request.Headers["TypeName"].ToString();
  3899. if (file != null)
  3900. {
  3901. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3902. //文件名称
  3903. string projectFileName = file.FileName;
  3904. //上传的文件的路径
  3905. string filePath = $"{fileDir}/{projectFileName}";
  3906. if (TypeName == "A")//A代表团组增减款项
  3907. {
  3908. if (!Directory.Exists(fileDir))
  3909. {
  3910. Directory.CreateDirectory(fileDir);
  3911. }
  3912. //上传的文件的路径
  3913. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3914. }
  3915. else if (TypeName == "B")//B代表商邀相关文件
  3916. {
  3917. if (!Directory.Exists(fileDir))
  3918. {
  3919. Directory.CreateDirectory(fileDir);
  3920. }
  3921. //上传的文件的路径
  3922. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3923. }
  3924. using (FileStream fs = System.IO.File.Create(filePath))
  3925. {
  3926. file.CopyTo(fs);
  3927. fs.Flush();
  3928. }
  3929. return Ok(JsonView(true, "上传成功!", projectFileName));
  3930. }
  3931. else
  3932. {
  3933. return Ok(JsonView(false, "上传失败!"));
  3934. }
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. return Ok(JsonView(false, "程序错误!"));
  3939. }
  3940. }
  3941. /// <summary>
  3942. /// 删除指定文件
  3943. /// </summary>
  3944. /// <param name="dto"></param>
  3945. /// <returns></returns>
  3946. [HttpPost]
  3947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3948. public async Task<IActionResult> DelFile(DelFileDto dto)
  3949. {
  3950. try
  3951. {
  3952. var TypeName = Request.Headers["TypeName"].ToString();
  3953. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3954. string filePath = "";
  3955. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3956. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3957. int id = 0;
  3958. if (TypeName == "A")
  3959. {
  3960. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3961. // 删除该文件
  3962. System.IO.File.Delete(filePath);
  3963. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3964. .Where(a => a.Id == dto.Id)
  3965. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3966. .ExecuteCommandAsync();
  3967. }
  3968. else if (TypeName == "B")
  3969. {
  3970. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3971. // 删除该文件
  3972. System.IO.File.Delete(filePath);
  3973. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3974. if (info != null)
  3975. {
  3976. string[] files = new string[] { };
  3977. if (!string.IsNullOrEmpty(info.Attachment))
  3978. {
  3979. try
  3980. {
  3981. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3982. }
  3983. catch (Exception)
  3984. {
  3985. files = new List<string>() { info.Attachment }.ToArray();
  3986. }
  3987. }
  3988. if (files.Length > 0)
  3989. {
  3990. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3991. string filePath2 = string.Empty;
  3992. if (files1.Length > 0)
  3993. {
  3994. filePath2 = JsonConvert.SerializeObject(files1);
  3995. }
  3996. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3997. .Where(a => a.Id == dto.Id)
  3998. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3999. .ExecuteCommandAsync();
  4000. }
  4001. }
  4002. }
  4003. if (id != 0)
  4004. {
  4005. return Ok(JsonView(true, "成功!"));
  4006. }
  4007. else
  4008. {
  4009. return Ok(JsonView(false, "失败!"));
  4010. }
  4011. }
  4012. catch (Exception ex)
  4013. {
  4014. return Ok(JsonView(false, "程序错误!"));
  4015. throw;
  4016. }
  4017. }
  4018. /// <summary>
  4019. /// 文件上传多个文件 可以带参数
  4020. /// </summary>
  4021. /// <param name="files"></param>
  4022. /// <returns></returns>
  4023. [HttpPost]
  4024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4025. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4026. {
  4027. try
  4028. {
  4029. var TypeName = Request.Headers["TypeName"].ToString();
  4030. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4031. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4032. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4033. var filePahts = new List<string>();
  4034. foreach (var file in files)
  4035. {
  4036. //文件名称
  4037. string projectFileName = file.FileName;
  4038. //上传的文件的路径
  4039. string filePath = $"{fileDir}/{projectFileName}";
  4040. if (TypeName == "A")//A代表团组增减款项
  4041. {
  4042. if (!Directory.Exists(fileDir))
  4043. {
  4044. Directory.CreateDirectory(fileDir);
  4045. }
  4046. //上传的文件的路径
  4047. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4048. }
  4049. else if (TypeName == "B")//B代表商邀相关文件
  4050. {
  4051. if (!Directory.Exists(fileDir))
  4052. {
  4053. Directory.CreateDirectory(fileDir);
  4054. }
  4055. //上传的文件的路径
  4056. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4057. }
  4058. using (FileStream fs = System.IO.File.Create(filePath))
  4059. {
  4060. file.CopyTo(fs);
  4061. fs.Flush();
  4062. }
  4063. filePahts.Add(projectFileName);
  4064. }
  4065. return Ok(JsonView(true, "上传成功!", filePahts));
  4066. }
  4067. catch (Exception ex)
  4068. {
  4069. return Ok(JsonView(false, "程序错误!"));
  4070. }
  4071. }
  4072. #endregion
  4073. #region 商邀费用录入
  4074. /// <summary>
  4075. /// 根据团组Id查询商邀费用列表
  4076. /// </summary>
  4077. /// <param name="dto"></param>
  4078. /// <returns></returns>
  4079. [HttpPost]
  4080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4081. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4082. {
  4083. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4084. if (groupData.Code != 0)
  4085. {
  4086. return Ok(JsonView(false, groupData.Msg));
  4087. }
  4088. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4089. }
  4090. /// <summary>
  4091. /// 商邀费用列表
  4092. /// 下载文件
  4093. /// </summary>
  4094. /// <param name="id"></param>
  4095. /// <returns></returns>
  4096. [HttpGet("{id}")]
  4097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4098. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4099. {
  4100. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4101. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4102. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4103. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4104. var filePaths = new List<string>();
  4105. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4106. try
  4107. {
  4108. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4109. }
  4110. catch (Exception ex)
  4111. {
  4112. filePaths.Add(info.Attachment);
  4113. }
  4114. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4115. for (int i = 0; i < filePaths.Count; i++)
  4116. {
  4117. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4118. }
  4119. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4120. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4121. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4122. {
  4123. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4124. {
  4125. foreach (string filePath in filePaths)
  4126. {
  4127. if (System.IO.File.Exists(filePath))
  4128. {
  4129. // 获取文件名
  4130. string fileName = Path.GetFileName(filePath);
  4131. // 将文件添加到ZIP归档中
  4132. zipArchive.CreateEntryFromFile(filePath, fileName);
  4133. }
  4134. }
  4135. }
  4136. }
  4137. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4138. }
  4139. /// <summary>
  4140. /// 商邀费用 Info Page 基础数据源
  4141. /// </summary>
  4142. /// <returns></returns>
  4143. [HttpPost]
  4144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4145. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4146. {
  4147. try
  4148. {
  4149. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4150. if (groupData.Code != 0)
  4151. {
  4152. return Ok(JsonView(false, groupData.Msg));
  4153. }
  4154. return Ok(JsonView(true, "操作成功", groupData.Data));
  4155. }
  4156. catch (Exception ex)
  4157. {
  4158. return Ok(JsonView(false, ex.Message));
  4159. throw;
  4160. }
  4161. }
  4162. /// <summary>
  4163. /// 根据商邀费用ID查询C表和商邀费用数据
  4164. /// </summary>
  4165. /// <param name="dto"></param>
  4166. /// <returns></returns>
  4167. [HttpPost]
  4168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4169. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4170. {
  4171. try
  4172. {
  4173. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4174. if (groupData.Code != 0)
  4175. {
  4176. return Ok(JsonView(false, groupData.Msg));
  4177. }
  4178. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4179. }
  4180. catch (Exception ex)
  4181. {
  4182. return Ok(JsonView(false, ex.Message));
  4183. throw;
  4184. }
  4185. }
  4186. /// <summary>
  4187. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4188. /// </summary>
  4189. /// <param name="dto"></param>
  4190. /// <returns></returns>
  4191. [HttpPost]
  4192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4193. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4194. {
  4195. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4196. if (groupData.Code != 0)
  4197. {
  4198. return Ok(JsonView(false, groupData.Msg));
  4199. }
  4200. #region 应用推送
  4201. try
  4202. {
  4203. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4204. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4205. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4206. //2024-10-21 新增LZ UID
  4207. var userIds = new List<int>() { 21 };
  4208. string title = $"系统通知";
  4209. string content = "";
  4210. var diId = dto.DiId;
  4211. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4212. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4213. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4214. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4215. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4216. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4217. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4218. }
  4219. catch (Exception ex)
  4220. {
  4221. }
  4222. #endregion
  4223. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4224. }
  4225. /// <summary>
  4226. /// 商邀删除
  4227. /// </summary>
  4228. /// <param name="dto"></param>
  4229. /// <returns></returns>
  4230. [HttpPost]
  4231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4232. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4233. {
  4234. try
  4235. {
  4236. _sqlSugar.BeginTran();
  4237. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4238. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4239. {
  4240. IsDel = 1,
  4241. DeleteUserId = dto.DeleteUserId,
  4242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4243. })
  4244. .Where(it => it.Id == dto.Id)
  4245. .ExecuteCommand();
  4246. if (res1 > 0)
  4247. {
  4248. int _diId = 0;
  4249. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4250. if (_ioaInfo != null)
  4251. {
  4252. _diId = _ioaInfo.DiId;
  4253. }
  4254. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4255. .SetColumns(a => new Grp_CreditCardPayment()
  4256. {
  4257. IsDel = 1,
  4258. DeleteUserId = dto.DeleteUserId,
  4259. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4260. })
  4261. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4262. .ExecuteCommand();
  4263. if (res2 > 0)
  4264. {
  4265. _sqlSugar.CommitTran();
  4266. return Ok(JsonView(true, "删除成功!"));
  4267. }
  4268. }
  4269. _sqlSugar.RollbackTran();
  4270. return Ok(JsonView(false, "删除失败"));
  4271. }
  4272. catch (Exception ex)
  4273. {
  4274. _sqlSugar.RollbackTran();
  4275. return Ok(JsonView(false, ex.Message));
  4276. }
  4277. }
  4278. /// <summary>
  4279. /// 团组模块文件上传
  4280. /// </summary>
  4281. /// <param name="dto"></param>
  4282. /// <returns></returns>
  4283. [HttpPost]
  4284. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4285. {
  4286. var jw = JsonView(false);
  4287. long M = 1024 * 1024;
  4288. if (dto.Files == null || dto.Files.Count == 0)
  4289. {
  4290. jw.Msg = "无文件信息!";
  4291. return Ok(jw);
  4292. }
  4293. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4294. {
  4295. jw.Msg = "文件大小超过20M!";
  4296. return Ok(jw);
  4297. }
  4298. //var nameSp = dto.File.FileName.Split(".");
  4299. //if (nameSp.Length < 2)
  4300. //{
  4301. // jw.Msg = "拓展名称有误!";
  4302. // return Ok(jw);
  4303. //}
  4304. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4305. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4306. //{
  4307. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4308. // return Ok(jw);
  4309. //}
  4310. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4311. if (Ctable == null)
  4312. {
  4313. jw.Msg = "Ctable指向有误!";
  4314. return Ok(jw);
  4315. }
  4316. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4317. if (groupInfo == null)
  4318. {
  4319. jw.Msg = "团组信息不存在!";
  4320. return Ok(jw);
  4321. }
  4322. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4323. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4324. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4325. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4326. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4327. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4328. try
  4329. {
  4330. if (!Directory.Exists(fileBase))
  4331. {
  4332. Directory.CreateDirectory(fileBase);
  4333. }
  4334. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4335. foreach (var fileStream in dto.Files)
  4336. {
  4337. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4338. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4339. {
  4340. Cid = dto.Cid,
  4341. CreateTime = DateTime.Now,
  4342. CreateUserId = dto.Userid,
  4343. Ctable = dto.Ctable,
  4344. Diid = dto.Diid,
  4345. IsDel = 0,
  4346. FilePath = saveFilePath,
  4347. FileName = fileStream.FileName
  4348. };
  4349. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4350. {
  4351. fileStream.CopyTo(fs);
  4352. fs.Flush();
  4353. }
  4354. saveArr.Add(file);
  4355. }
  4356. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4357. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4358. jw = JsonView(true, "保存成功!", new
  4359. {
  4360. count = addResult,
  4361. filesName = saveArr.Select(x => x.FileName)
  4362. });
  4363. }
  4364. catch (Exception ex)
  4365. {
  4366. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4367. {
  4368. count = 0,
  4369. filesName = new string[0],
  4370. });
  4371. }
  4372. return Ok(jw);
  4373. }
  4374. /// <summary>
  4375. /// 查询各模块已保存文件
  4376. /// </summary>
  4377. /// <param name="dto"></param>
  4378. /// <returns></returns>
  4379. [HttpPost]
  4380. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4381. {
  4382. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4383. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4384. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4385. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4386. {
  4387. expression = Expressionable.Create<Grp_GroupModelFile>()
  4388. .And(x => visaIds.Contains(x.CreateUserId));
  4389. }
  4390. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4391. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4392. .Where(expression.ToExpression())
  4393. .ToList();
  4394. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4395. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4396. {
  4397. x.FileName,
  4398. x.Id,
  4399. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4400. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4401. })));
  4402. }
  4403. /// <summary>
  4404. /// 下载该团组下的所有文件
  4405. /// </summary>
  4406. /// <param name="dto"></param>
  4407. /// <returns></returns>
  4408. [HttpPost]
  4409. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4410. {
  4411. var jw = JsonView(false);
  4412. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4413. if (groupInfo == null)
  4414. {
  4415. jw.Msg = "团组信息不存在!";
  4416. return Ok(jw);
  4417. }
  4418. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4419. var isModule = Convert.ToBoolean(dto.isModule);
  4420. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4421. IOOperatorHelper io = new IOOperatorHelper();
  4422. if (isModule)
  4423. {
  4424. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4425. foreach (var moduleArr in moduleGroup)
  4426. {
  4427. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4428. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4429. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4430. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4431. foreach (var item in moduleArr)
  4432. {
  4433. if (System.IO.File.Exists(item.FilePath))
  4434. {
  4435. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4436. {
  4437. byte[] bytes = new byte[fileStream.Length];
  4438. fileStream.Read(bytes, 0, bytes.Length);
  4439. fileStream.Close();
  4440. Stream stream = new MemoryStream(bytes);
  4441. chiZips.Add(item.FileName, stream);
  4442. }
  4443. }
  4444. }
  4445. if (chiZips.Count > 0)
  4446. {
  4447. var byts = io.ConvertZipStream(chiZips);
  4448. Stream stream = new MemoryStream(byts);
  4449. Zips.Add(key.Name + "_.zip", stream);
  4450. }
  4451. }
  4452. }
  4453. else
  4454. {
  4455. foreach (var item in dbQuery)
  4456. {
  4457. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4458. {
  4459. byte[] bytes = new byte[fileStream.Length];
  4460. fileStream.Read(bytes, 0, bytes.Length);
  4461. fileStream.Close();
  4462. Stream stream = new MemoryStream(bytes);
  4463. while (Zips.Keys.Contains(item.FileName))
  4464. {
  4465. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4466. }
  4467. Zips.Add(item.FileName, stream);
  4468. }
  4469. }
  4470. }
  4471. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4472. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4473. if (Zips.Count > 0)
  4474. {
  4475. var byts = io.ConvertZipStream(Zips);
  4476. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4477. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4478. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4479. }
  4480. else
  4481. {
  4482. jw.Msg = "暂无生成文件!";
  4483. }
  4484. return Ok(jw);
  4485. }
  4486. /// <summary>
  4487. /// 下载该团组下此模块的所有文件
  4488. /// </summary>
  4489. /// <param name="dto"></param>
  4490. /// <returns></returns>
  4491. [HttpPost]
  4492. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4493. {
  4494. var jw = JsonView(false);
  4495. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4496. if (groupInfo == null)
  4497. {
  4498. jw.Msg = "团组信息不存在!";
  4499. return Ok(jw);
  4500. }
  4501. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4502. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4503. && x.IsDel == 0);
  4504. if (key == null)
  4505. {
  4506. jw.Msg = "Ctable指向错误!";
  4507. return Ok(jw);
  4508. }
  4509. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4510. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4511. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4512. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4513. IOOperatorHelper io = new IOOperatorHelper();
  4514. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4515. foreach (var item in dbQuery)
  4516. {
  4517. if (System.IO.File.Exists(item.FilePath))
  4518. {
  4519. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4520. {
  4521. byte[] bytes = new byte[fileStream.Length];
  4522. fileStream.Read(bytes, 0, bytes.Length);
  4523. fileStream.Close();
  4524. Stream stream = new MemoryStream(bytes);
  4525. while (Zips.Keys.Contains(item.FileName))
  4526. {
  4527. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4528. }
  4529. Zips.Add(item.FileName, stream);
  4530. }
  4531. }
  4532. }
  4533. if (Zips.Count > 0)
  4534. {
  4535. var byts = io.ConvertZipStream(Zips);
  4536. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4537. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4538. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4539. }
  4540. else
  4541. {
  4542. jw.Msg = "暂无生成文件!";
  4543. }
  4544. return Ok(jw);
  4545. }
  4546. /// <summary>
  4547. /// 删除该团组下的指定文件
  4548. /// </summary>
  4549. /// <param name="dto"></param>
  4550. /// <returns></returns>
  4551. [HttpPost]
  4552. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4553. {
  4554. var jw = JsonView(false);
  4555. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4556. if (sing == null)
  4557. {
  4558. jw.Msg = "暂无";
  4559. return Ok(jw);
  4560. }
  4561. if (System.IO.File.Exists(sing.FilePath))
  4562. {
  4563. try
  4564. {
  4565. System.IO.File.Delete(sing.FilePath);
  4566. }
  4567. catch (Exception ex)
  4568. {
  4569. jw.Msg = "删除失败!" + ex.Message;
  4570. return Ok(jw);
  4571. }
  4572. }
  4573. sing.IsDel = 1;
  4574. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4575. sing.DeleteUserId = dto.UserId;
  4576. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4577. jw = JsonView(true, "删除成功!");
  4578. return Ok(jw);
  4579. }
  4580. #endregion
  4581. #region 团组英文资料
  4582. /// <summary>
  4583. /// 查询团组英文所有资料
  4584. /// </summary>
  4585. /// <param name="dto"></param>
  4586. /// <returns></returns>
  4587. [HttpPost]
  4588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4589. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4590. {
  4591. try
  4592. {
  4593. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4594. if (groupData.Code != 0)
  4595. {
  4596. return Ok(JsonView(false, groupData.Msg));
  4597. }
  4598. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4599. }
  4600. catch (Exception ex)
  4601. {
  4602. return Ok(JsonView(false, "程序错误!"));
  4603. throw;
  4604. }
  4605. }
  4606. /// <summary>
  4607. /// 团组英文资料操作(Status:1.新增,2.修改)
  4608. /// </summary>
  4609. /// <param name="dto"></param>
  4610. /// <returns></returns>
  4611. [HttpPost]
  4612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4613. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4614. {
  4615. try
  4616. {
  4617. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4618. if (groupData.Code != 0)
  4619. {
  4620. return Ok(JsonView(false, groupData.Msg));
  4621. }
  4622. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4623. }
  4624. catch (Exception ex)
  4625. {
  4626. return Ok(JsonView(false, "程序错误!"));
  4627. throw;
  4628. }
  4629. }
  4630. /// <summary>
  4631. /// 团组英文资料Id查询数据
  4632. /// </summary>
  4633. /// <param name="dto"></param>
  4634. /// <returns></returns>
  4635. [HttpPost]
  4636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4637. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4638. {
  4639. try
  4640. {
  4641. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4642. if (_DelegationEnData != null)
  4643. {
  4644. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4645. }
  4646. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4647. }
  4648. catch (Exception ex)
  4649. {
  4650. return Ok(JsonView(false, "程序错误!"));
  4651. throw;
  4652. }
  4653. }
  4654. /// <summary>
  4655. /// 团组英文资料删除
  4656. /// </summary>
  4657. /// <param name="dto"></param>
  4658. /// <returns></returns>
  4659. [HttpPost]
  4660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4661. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4662. {
  4663. try
  4664. {
  4665. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4666. if (!res)
  4667. {
  4668. return Ok(JsonView(false, "删除失败"));
  4669. }
  4670. return Ok(JsonView(true, "删除成功!"));
  4671. }
  4672. catch (Exception ex)
  4673. {
  4674. return Ok(JsonView(false, "程序错误!"));
  4675. throw;
  4676. }
  4677. }
  4678. #endregion
  4679. #region 导出邀请函
  4680. /// <summary>
  4681. /// 导出邀请函页面初始化
  4682. /// </summary>
  4683. /// <param name="dto"></param>
  4684. /// <returns></returns>
  4685. [HttpPost]
  4686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4687. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4688. {
  4689. try
  4690. {
  4691. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4692. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4693. if (dto.DiId == 0)
  4694. {
  4695. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4696. }
  4697. else
  4698. {
  4699. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4700. }
  4701. return Ok(JsonView(true, "查询成功!", new
  4702. {
  4703. deleClient = crm_Deles,
  4704. delegations = grp_Delegations
  4705. }));
  4706. }
  4707. catch (Exception ex)
  4708. {
  4709. return Ok(JsonView(false, "程序错误!"));
  4710. throw;
  4711. }
  4712. }
  4713. /// <summary>
  4714. /// 导出邀请函
  4715. /// </summary>
  4716. /// <param name="dto"></param>
  4717. /// <returns></returns>
  4718. [HttpPost]
  4719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4720. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4721. {
  4722. #region 参数验证
  4723. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4724. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4725. #endregion
  4726. try
  4727. {
  4728. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4729. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4730. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4731. From Grp_TourClientList tcl
  4732. Left Join
  4733. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4734. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4735. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4736. From Crm_DeleClient dc
  4737. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4738. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4739. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4740. Where dc.IsDel = 0) temp
  4741. On temp.DcId =tcl.ClientId
  4742. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4743. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4744. List<string> texts = new List<string>();
  4745. if (datas.Count != 0)
  4746. {
  4747. foreach (TourClientListDetailsView item in datas)
  4748. {
  4749. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4750. {
  4751. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4752. }
  4753. else
  4754. {
  4755. string name = item.LastName + item.FirstName;
  4756. texts.Add(name);
  4757. }
  4758. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4759. {
  4760. if (!transDic.ContainsKey(item.Job))
  4761. {
  4762. texts.Add(item.Job);
  4763. }
  4764. }
  4765. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4766. {
  4767. texts.Add(item.CompanyFullName);
  4768. }
  4769. }
  4770. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4771. if (transData.Count > 0)
  4772. {
  4773. foreach (TranslateResult item in transData)
  4774. {
  4775. if (!transDic.ContainsKey(item.Query))
  4776. {
  4777. transDic.Add(item.Query, item.Translation);
  4778. }
  4779. }
  4780. }
  4781. List<GuestList> list = new List<GuestList>();
  4782. foreach (TourClientListDetailsView dele in datas)
  4783. {
  4784. GuestList guestList = new GuestList();
  4785. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4786. {
  4787. guestList.Name = dele.Pinyin;
  4788. }
  4789. else
  4790. {
  4791. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4792. guestList.Name = Name;
  4793. }
  4794. if (dele.Sex == 0)
  4795. {
  4796. guestList.Sex = "Male";
  4797. }
  4798. else if (dele.Sex == 1)
  4799. {
  4800. guestList.Sex = "Female";
  4801. }
  4802. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4803. if (!string.IsNullOrEmpty(dele.Job))
  4804. {
  4805. guestList.Job = dele.Job;
  4806. }
  4807. list.Add(guestList);
  4808. }
  4809. //载入模板
  4810. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4811. DocumentBuilder builder = new DocumentBuilder(doc);
  4812. //获取word里所有表格
  4813. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4814. //获取所填表格的序数
  4815. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4816. var rowStart = tableOne.Rows[0]; //获取第1行
  4817. //循环赋值
  4818. for (int i = 0; i < list.Count; i++)
  4819. {
  4820. builder.MoveToCell(0, i + 1, 0, 0);
  4821. builder.Write(list[i].Name.ToString());
  4822. builder.MoveToCell(0, i + 1, 1, 0);
  4823. builder.Write(list[i].Sex.ToString());
  4824. builder.MoveToCell(0, i + 1, 2, 0);
  4825. builder.Write(list[i].DOB.ToString());
  4826. builder.MoveToCell(0, i + 1, 3, 0);
  4827. builder.Write(list[i].Job.ToString());
  4828. }
  4829. //删除多余行
  4830. while (tableOne.Rows.Count > list.Count + 1)
  4831. {
  4832. tableOne.Rows.RemoveAt(list.Count + 1);
  4833. }
  4834. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4835. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4836. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4837. doc.Save(filePath);
  4838. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4839. return Ok(JsonView(true, "操作成功!", Url));
  4840. }
  4841. else
  4842. {
  4843. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4844. }
  4845. }
  4846. catch (Exception ex)
  4847. {
  4848. return Ok(JsonView(false, ex.Message));
  4849. throw;
  4850. }
  4851. }
  4852. #endregion
  4853. #region 团组经理模块 出入境费用
  4854. /// <summary>
  4855. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4856. /// </summary>
  4857. /// <returns></returns>
  4858. [HttpPost]
  4859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4860. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4861. {
  4862. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4863. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4864. //SetDataInfoView
  4865. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4866. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4867. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4868. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4869. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4870. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4871. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4872. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4873. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4874. return Ok(JsonView(true, "查询成功!", new
  4875. {
  4876. GroupNameData = groupNameData.Data,
  4877. CurrencyData = _CurrencyData,
  4878. WordTypeData = _WordTypeData,
  4879. ExcelTypeData = _ExcelTypeData,
  4880. CurrencyInit = _currencyInfos,
  4881. ViewPermissionData = viewPermissionData
  4882. }));
  4883. }
  4884. /// <summary>
  4885. /// 团组模块 - 出入境费用
  4886. /// 实时汇率 tips
  4887. /// 签证费用 tips
  4888. /// 机票费用 tips
  4889. /// </summary>
  4890. /// <returns></returns>
  4891. [HttpPost]
  4892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4893. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4894. {
  4895. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4896. //默认币种显示
  4897. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4898. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4899. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4900. return Ok(JsonView(true, "查询成功!", new
  4901. {
  4902. //GroupNameData = groupNameData.Data,
  4903. visaData = visaData.Data,
  4904. airData = airData.Data,
  4905. reteInfos = reteInfos
  4906. }));
  4907. }
  4908. /// <summary>
  4909. /// 团组模块 - 出入境费用 - Info
  4910. /// </summary>
  4911. /// <returns></returns>
  4912. [HttpPost]
  4913. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4915. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4916. {
  4917. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4918. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4919. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4920. }
  4921. /// <summary>
  4922. /// 团组模块 - 出入境费用 - 设置view权限
  4923. /// </summary>
  4924. /// <returns></returns>
  4925. [HttpPost]
  4926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4927. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4928. {
  4929. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4930. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4931. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4932. var permissions = new List<Grp_EnterExitCostPermission>();
  4933. foreach (var userId in dto.UserIds)
  4934. {
  4935. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4936. }
  4937. if (permissions.Any())
  4938. {
  4939. _sqlSugar.BeginTran();
  4940. try
  4941. {
  4942. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4943. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4944. if (result < 1)
  4945. {
  4946. _sqlSugar.RollbackTran();
  4947. return Ok(JsonView(false));
  4948. }
  4949. }
  4950. catch (Exception ex)
  4951. {
  4952. _sqlSugar.RollbackTran();
  4953. return Ok(JsonView(false, ex.Message));
  4954. }
  4955. _sqlSugar.CommitTran();
  4956. return Ok(JsonView(true));
  4957. }
  4958. return Ok(JsonView(false));
  4959. }
  4960. /// <summary>
  4961. /// 团组模块 - 出入境费用 - Add And Update
  4962. /// </summary>
  4963. /// <returns></returns>
  4964. [HttpPost]
  4965. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4967. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4968. {
  4969. try
  4970. {
  4971. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4972. if (dto.DayOtherPriceData.Any())
  4973. {
  4974. var inserList = dto.DayOtherPriceData
  4975. .Where(x => x.Id == 0)
  4976. .Select(x => new Grp_DayOtherPrice
  4977. {
  4978. Cost = x.Cost,
  4979. Id = x.Id,
  4980. CreateTime = DateTime.Now,
  4981. CreateUserId = dto.UserId,
  4982. Currency = x.Currency,
  4983. Diid = x.DiId,
  4984. Index = x.Index,
  4985. IsDel = 0,
  4986. SetDataId = x.SetDataId,
  4987. SubTotal = x.SubTotal,
  4988. Remark = x.Remark
  4989. })
  4990. .ToList();
  4991. var updateList = dto.DayOtherPriceData
  4992. .Where(x => x.Id != 0)
  4993. .Select(x => new Grp_DayOtherPrice
  4994. {
  4995. Cost = x.Cost,
  4996. Id = x.Id,
  4997. CreateTime = DateTime.Now,
  4998. CreateUserId = dto.UserId,
  4999. Currency = x.Currency,
  5000. Diid = x.DiId,
  5001. Index = x.Index,
  5002. IsDel = 0,
  5003. SetDataId = x.SetDataId,
  5004. SubTotal = x.SubTotal,
  5005. Remark = x.Remark
  5006. })
  5007. .ToList();
  5008. //添加
  5009. _sqlSugar.BeginTran();
  5010. if (inserList.Any())
  5011. {
  5012. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5013. }
  5014. if (updateList.Any())
  5015. {
  5016. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5017. }
  5018. _sqlSugar.CommitTran();
  5019. }
  5020. if (data.Code != 0)
  5021. {
  5022. return Ok(JsonView(false, data.Msg));
  5023. }
  5024. //生成默认文件pdf并且通知人员
  5025. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5026. {
  5027. DiId = dto.DiId,
  5028. ExportType = 1,
  5029. SubTypeId = 1005
  5030. }, "pdf");
  5031. //发送通知
  5032. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5033. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5034. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5035. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5036. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5037. //汇率信息记录
  5038. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5039. return Ok(JsonView(true, data.Msg, data.Data));
  5040. }
  5041. catch (Exception ex)
  5042. {
  5043. return Ok(JsonView(false, ex.Message));
  5044. }
  5045. }
  5046. /// <summary>
  5047. /// 团组模块 - 出入境费用 - Confirm 费用
  5048. /// </summary>
  5049. /// <returns></returns>
  5050. [HttpPost]
  5051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5052. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5053. {
  5054. //TODO:测试完毕需把对应的用户ID更改
  5055. //1、数据表添加字段
  5056. //2、更改字段接口()
  5057. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5058. //3、确认成功 给财务发送消息
  5059. if (_view.Code == 200)
  5060. {
  5061. if (dto.Type == 1)
  5062. {
  5063. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5064. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5065. }
  5066. }
  5067. return Ok(_view);
  5068. }
  5069. /// <summary>
  5070. /// 团组模块 - 出入境费用 - File download
  5071. /// </summary>
  5072. /// <param name="dto"></param>
  5073. /// <returns></returns>
  5074. [HttpPost]
  5075. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5077. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5078. {
  5079. try
  5080. {
  5081. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5082. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5083. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5084. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5085. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5086. 3 团组成员名单 1 团组成员名单", ""));
  5087. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5088. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5089. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5090. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5091. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5092. //数据源
  5093. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5094. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5095. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5096. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5097. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5098. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5099. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5100. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5101. .Select((x, a, b) => new
  5102. {
  5103. x.Index,
  5104. itemName = a.Name,
  5105. CurrencyStr = b.Name,
  5106. x.Cost,
  5107. x.SubTotal,
  5108. x.Remark
  5109. })
  5110. .OrderBy((x) => x.Index)
  5111. .ToList(); //其他款项费用
  5112. var peiceItemCurrencys = new List<string>();
  5113. if (_DayAndCosts.Any())
  5114. {
  5115. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5116. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5117. }
  5118. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5119. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5120. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5121. {
  5122. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5123. }
  5124. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5125. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5126. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5127. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5128. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5129. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5130. .Select((tcl, dc, cc) => new ClientInfo
  5131. {
  5132. LastName = dc.LastName,
  5133. FirstName = dc.FirstName,
  5134. Sex = dc.Sex,
  5135. Birthday = dc.BirthDay,
  5136. Company = cc.CompanyFullName,
  5137. Job = dc.Job
  5138. })
  5139. .ToList();
  5140. foreach (var item in DeleClientList)
  5141. {
  5142. EncryptionProcessor.DecryptProperties(item);
  5143. }
  5144. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5145. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5146. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5147. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5148. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5149. if (dto.ExportType == 1) //明细表
  5150. {
  5151. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5152. {
  5153. //获取模板
  5154. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5155. //载入模板
  5156. Document doc = new Document(tempPath);
  5157. DocumentBuilder builder = new DocumentBuilder(doc);
  5158. //利用键值对存放数据
  5159. Dictionary<string, string> dic = new Dictionary<string, string>();
  5160. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5161. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5162. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5163. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5164. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5165. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5166. //境内费用(其他费用)
  5167. if (_EnterExitCosts.ChoiceOne == 1)
  5168. {
  5169. string row1_1 = "";
  5170. if (_EnterExitCosts.Visa > 0)
  5171. {
  5172. //insidePayTotal += _EnterExitCosts.Visa;
  5173. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5174. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5175. {
  5176. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5177. }
  5178. }
  5179. string row1_2 = "";
  5180. if (_EnterExitCosts.YiMiao > 0)
  5181. {
  5182. //insidePayTotal += _EnterExitCosts.YiMiao;
  5183. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5184. }
  5185. if (_EnterExitCosts.HeSuan > 0)
  5186. {
  5187. //insidePayTotal += _EnterExitCosts.HeSuan;
  5188. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5189. }
  5190. if (_EnterExitCosts.Service > 0)
  5191. {
  5192. //insidePayTotal += _EnterExitCosts.Service;
  5193. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5194. }
  5195. string row1_3 = "";
  5196. if (_EnterExitCosts.Safe > 0)
  5197. {
  5198. //insidePayTotal += _EnterExitCosts.Safe;
  5199. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5200. }
  5201. if (_EnterExitCosts.Ticket > 0)
  5202. {
  5203. //insidePayTotal += _EnterExitCosts.Ticket;
  5204. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5205. }
  5206. string row1 = "";
  5207. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5208. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5209. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5210. row1 += $"备注:{_EnterExitCosts.Remark}";
  5211. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5212. dic.Add("Row1Str", row1);
  5213. }
  5214. string airTotalStr = string.Empty,
  5215. airPriceStr = string.Empty;
  5216. //经济舱
  5217. if (_EnterExitCosts.SumJJC == 1)
  5218. {
  5219. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5220. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5221. }
  5222. //公务舱
  5223. if (_EnterExitCosts.SumGWC == 1)
  5224. {
  5225. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5226. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5227. }
  5228. //头等舱
  5229. if (_EnterExitCosts.SumTDC == 1)
  5230. {
  5231. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5232. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5233. }
  5234. //汇率描述
  5235. string rateStr = "";
  5236. if (peiceItemCurrencyInfos.Any())
  5237. {
  5238. rateStr = "\r\n汇率描述:";
  5239. foreach (var item in peiceItemCurrencyInfos)
  5240. {
  5241. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5242. }
  5243. }
  5244. string twoItemRemark = "备注:";
  5245. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5246. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5247. dic.Add("AirTotalStr", airTotalStr);
  5248. dic.Add("AirPriceStr", airPriceStr);
  5249. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5250. dic.Add("TwoItemRemark", twoItemRemark);
  5251. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5252. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5253. int table1Row = 0,
  5254. table2Row = 0,
  5255. table3Row = 0,
  5256. table4Row = 0,
  5257. table5Row = 0;
  5258. //住宿费
  5259. if (_EnterExitCosts.ChoiceThree == 1)
  5260. {
  5261. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5262. table1Row = dac1.Count;
  5263. #region 填充word表格内容
  5264. for (int i = 0; i < dac1.Count; i++)
  5265. {
  5266. Grp_DayAndCost dac = dac1[i];
  5267. if (dac == null) continue;
  5268. builder.MoveToCell(0, i, 0, 0);
  5269. builder.Write("第" + dac.Days.ToString() + "晚:");
  5270. builder.MoveToCell(0, i, 1, 0);
  5271. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5272. //builder.Write(dac.Place == null ? "" : dac.Place);
  5273. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5274. builder.MoveToCell(0, i, 2, 0);
  5275. builder.Write("费用标准:");
  5276. string curr = "";
  5277. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5278. if (currData != null)
  5279. {
  5280. curr = currData.Name;
  5281. }
  5282. builder.MoveToCell(0, i, 3, 0);
  5283. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5284. builder.MoveToCell(0, i, 4, 0);
  5285. builder.Write("费用小计:");
  5286. builder.MoveToCell(0, i, 5, 0);
  5287. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5288. }
  5289. #endregion
  5290. }
  5291. else dic.Add("SubZS", "0.00");
  5292. //删除多余行
  5293. while (table1.Rows.Count > table1Row)
  5294. {
  5295. table1.Rows.RemoveAt(table1Row);
  5296. }
  5297. //伙食费
  5298. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5299. if (_EnterExitCosts.ChoiceFour == 1)
  5300. {
  5301. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5302. table2Row = dac2.Count;
  5303. #region 填充word表格内容
  5304. for (int i = 0; i < dac2.Count; i++)
  5305. {
  5306. Grp_DayAndCost dac = dac2[i];
  5307. if (dac == null) continue;
  5308. builder.MoveToCell(1, i, 0, 0);
  5309. builder.Write("第" + dac.Days.ToString() + "天:");
  5310. builder.MoveToCell(1, i, 1, 0);
  5311. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5312. builder.MoveToCell(1, i, 2, 0);
  5313. builder.Write("费用标准:");
  5314. string curr = "";
  5315. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5316. if (currData != null)
  5317. {
  5318. curr = currData.Name;
  5319. }
  5320. builder.MoveToCell(1, i, 3, 0);
  5321. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5322. builder.MoveToCell(1, i, 4, 0);
  5323. builder.Write("费用小计:");
  5324. builder.MoveToCell(1, i, 5, 0);
  5325. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5326. }
  5327. #endregion
  5328. }
  5329. else dic.Add("SubHS", "0.00");
  5330. //删除多余行
  5331. while (table2.Rows.Count > table2Row)
  5332. {
  5333. table2.Rows.RemoveAt(table2Row);
  5334. }
  5335. //公杂费
  5336. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5337. if (_EnterExitCosts.ChoiceFive == 1)
  5338. {
  5339. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5340. table3Row = dac3.Count;
  5341. #region 填充word表格内容
  5342. for (int i = 0; i < dac3.Count; i++)
  5343. {
  5344. Grp_DayAndCost dac = dac3[i];
  5345. if (dac == null) continue;
  5346. builder.MoveToCell(2, i, 0, 0);
  5347. builder.Write("第" + dac.Days.ToString() + "天:");
  5348. builder.MoveToCell(2, i, 1, 0);
  5349. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5350. builder.MoveToCell(2, i, 2, 0);
  5351. builder.Write("费用标准:");
  5352. string curr = "";
  5353. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5354. if (currData != null)
  5355. {
  5356. curr = currData.Name;
  5357. }
  5358. builder.MoveToCell(2, i, 3, 0);
  5359. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5360. builder.MoveToCell(2, i, 4, 0);
  5361. builder.Write("费用小计:");
  5362. builder.MoveToCell(2, i, 5, 0);
  5363. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5364. }
  5365. //删除多余行
  5366. while (table3.Rows.Count > table3Row)
  5367. {
  5368. table3.Rows.RemoveAt(table3Row);
  5369. }
  5370. #endregion
  5371. }
  5372. else dic.Add("SubGZF", "0.00");
  5373. //删除多余行
  5374. while (table3.Rows.Count > table3Row)
  5375. {
  5376. table3.Rows.RemoveAt(table3Row);
  5377. }
  5378. //培训费
  5379. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5380. if (_EnterExitCosts.ChoiceSix == 1)
  5381. {
  5382. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5383. dic.Add("SubPX", pxStr);
  5384. table4Row = dac4.Count;
  5385. #region 填充word表格内容
  5386. for (int i = 0; i < dac4.Count; i++)
  5387. {
  5388. Grp_DayAndCost dac = dac4[i];
  5389. if (dac == null) continue;
  5390. builder.MoveToCell(3, i, 0, 0);
  5391. builder.Write("第" + dac.Days.ToString() + "天:");
  5392. builder.MoveToCell(3, i, 1, 0);
  5393. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5394. builder.MoveToCell(3, i, 2, 0);
  5395. builder.Write("费用标准:");
  5396. string curr = "";
  5397. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5398. if (currData != null)
  5399. {
  5400. curr = currData.Name;
  5401. }
  5402. builder.MoveToCell(3, i, 3, 0);
  5403. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5404. builder.MoveToCell(3, i, 4, 0);
  5405. builder.Write("费用小计:");
  5406. builder.MoveToCell(3, i, 5, 0);
  5407. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5408. }
  5409. #endregion
  5410. }
  5411. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5412. //删除多余行
  5413. while (table4.Rows.Count > table4Row)
  5414. {
  5415. table4.Rows.RemoveAt(table4Row);
  5416. }
  5417. //其他费用
  5418. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5419. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5420. {
  5421. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5422. dic.Add("titleQi", qtStr);
  5423. table5Row = dac5.Count;
  5424. #region 填充word表格内容
  5425. for (int i = 0; i < dac5.Count; i++)
  5426. {
  5427. var dac = dac5[i];
  5428. if (dac == null) continue;
  5429. builder.MoveToCell(4, i, 0, 0);
  5430. builder.Write("第" + dac.Index.ToString() + "项:");
  5431. builder.MoveToCell(4, i, 1, 0);
  5432. builder.Write(dac.itemName);
  5433. builder.MoveToCell(4, i, 2, 0);
  5434. builder.Write("费用标准:");
  5435. builder.MoveToCell(4, i, 3, 0);
  5436. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5437. builder.MoveToCell(4, i, 4, 0);
  5438. builder.Write("费用小计:");
  5439. builder.MoveToCell(4, i, 5, 0);
  5440. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5441. builder.MoveToCell(4, i, 6, 0);
  5442. builder.Write("备注:");
  5443. builder.MoveToCell(4, i, 7, 0);
  5444. builder.Write(dac.Remark);
  5445. }
  5446. #endregion
  5447. }
  5448. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5449. //删除多余行
  5450. while (table5.Rows.Count > table5Row)
  5451. {
  5452. table5.Rows.RemoveAt(table5Row);
  5453. }
  5454. //加上其他费用
  5455. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5456. decimal subJJC = 0.00M,
  5457. subGWC = 0.00M,
  5458. subTDC = 0.00M;
  5459. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5460. string totalLabel = string.Format("全部费用总计:");
  5461. //经济舱
  5462. if (_EnterExitCosts.SumJJC == 1)
  5463. {
  5464. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5465. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5466. }
  5467. //公务舱
  5468. if (_EnterExitCosts.SumGWC == 1) {
  5469. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5470. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5471. }
  5472. //头等舱
  5473. if (_EnterExitCosts.SumTDC == 1)
  5474. {
  5475. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5476. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5477. }
  5478. //TotalLabel
  5479. dic.Add("TotalLabel", totalLabel);
  5480. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5481. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5482. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5483. #region 填充word模板书签内容
  5484. foreach (var key in dic.Keys)
  5485. {
  5486. Bookmark bookmark = doc.Range.Bookmarks[key];
  5487. if (bookmark != null)
  5488. {
  5489. builder.MoveToBookmark(key);
  5490. builder.Write(dic[key]);
  5491. }
  5492. }
  5493. #endregion
  5494. #region 设置页眉
  5495. string userLabel = string.Empty;
  5496. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5497. if (currUserInfo != null)
  5498. {
  5499. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5500. if (userInfo != null)
  5501. {
  5502. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5503. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5504. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5505. }
  5506. }
  5507. //设置页脚
  5508. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5509. #endregion
  5510. //文件名
  5511. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5512. AsposeHelper.removewatermark_v2180();
  5513. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5514. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5515. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5516. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5517. }
  5518. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5519. {
  5520. //获取模板
  5521. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5522. //载入模板
  5523. Document doc = new Document(tempPath);
  5524. DocumentBuilder builder = new DocumentBuilder(doc);
  5525. Dictionary<string, string> dic = new Dictionary<string, string>();
  5526. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5527. {
  5528. List<string> list = new List<string>();
  5529. try
  5530. {
  5531. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5532. foreach (var item in spilitArr)
  5533. {
  5534. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5535. var depCode = spDotandEmpty[2].Substring(0, 3);
  5536. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5537. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5538. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5539. list.Add(depName);
  5540. list.Add(arrName);
  5541. }
  5542. list = list.Distinct().ToList();
  5543. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5544. }
  5545. catch (Exception)
  5546. {
  5547. dic.Add("ReturnCode", "行程录入不正确!");
  5548. }
  5549. }
  5550. else
  5551. {
  5552. dic.Add("ReturnCode", "未录入行程!");
  5553. }
  5554. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5555. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5556. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5557. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5558. {
  5559. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5560. dic.Add("Day", sp.Days.ToString());
  5561. }
  5562. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5563. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5564. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5565. //dic.Add("Names", Names);
  5566. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5567. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5568. decimal dac1totalPrice = 0.00M;
  5569. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5570. foreach (var dac in dac1)
  5571. {
  5572. if (dac.SubTotal == 0.00M)
  5573. {
  5574. continue;
  5575. }
  5576. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5577. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5578. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5579. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5580. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5581. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5582. builder.Write(currency);//币种
  5583. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5584. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5585. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5586. builder.Write("");//人数
  5587. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5588. builder.Write("");//天数
  5589. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5590. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5591. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5592. decimal rate = 0.00M;
  5593. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5594. builder.Write(rate.ToString("#0.0000"));//汇率
  5595. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5596. decimal rbmPrice = dac.SubTotal;
  5597. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5598. accommodationStartIndex++;
  5599. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5600. }
  5601. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5602. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5603. {
  5604. table1.Rows.RemoveAt(i - 1);
  5605. foodandotherStartIndex--;
  5606. }
  5607. if (dac2.Count == dac3.Count)//国家 币种 金额
  5608. {
  5609. for (int i = 0; i < dac2.Count; i++)
  5610. {
  5611. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5612. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5613. }
  5614. }
  5615. decimal dac2totalPrice = 0.00M;
  5616. foreach (var dac in dac2)
  5617. {
  5618. if (dac.SubTotal == 0)
  5619. {
  5620. continue;
  5621. }
  5622. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5623. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5624. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5625. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5626. builder.Write(currency);//币种
  5627. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5628. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5629. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5630. builder.Write("");//人数
  5631. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5632. builder.Write("");//天数
  5633. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5634. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5635. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5636. decimal rate = 0.00M;
  5637. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5638. builder.Write(rate.ToString("#0.0000"));//汇率
  5639. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5640. decimal rbmPrice = dac.SubTotal;
  5641. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5642. foodandotherStartIndex++;
  5643. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5644. }
  5645. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5646. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5647. {
  5648. table1.Rows.RemoveAt(i - 1);
  5649. }
  5650. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5651. string otherFeeStr = "";
  5652. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5653. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5654. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5655. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5656. foreach (var otherInfo in dac5)
  5657. {
  5658. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5659. }
  5660. #endregion
  5661. if (otherFeeStr.Length > 0)
  5662. {
  5663. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5664. otherFeeStr = $"({otherFeeStr})";
  5665. dic.Add("OtherFeeStr", otherFeeStr);
  5666. }
  5667. //总计
  5668. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5669. //国际旅费
  5670. string outsideAir = string.Empty;
  5671. string allPriceAir = string.Empty;
  5672. if (_EnterExitCosts.SumJJC == 1)
  5673. {
  5674. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5675. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5676. }
  5677. if (_EnterExitCosts.SumGWC == 1)
  5678. {
  5679. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5680. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5681. }
  5682. if (_EnterExitCosts.SumTDC == 1)
  5683. {
  5684. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5685. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5686. }
  5687. dic.Add("InTravelPrice", $"({outsideAir})");
  5688. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5689. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5690. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5691. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5692. foreach (var key in dic.Keys)
  5693. {
  5694. builder.MoveToBookmark(key);
  5695. builder.Write(dic[key]);
  5696. }
  5697. //模板文件名
  5698. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5699. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5700. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5701. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5702. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5703. }
  5704. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5705. {
  5706. //获取模板
  5707. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5708. //载入模板
  5709. WorkbookDesigner designer = new WorkbookDesigner();
  5710. designer.Workbook = new Workbook(tempPath);
  5711. Dictionary<string, string> dic = new Dictionary<string, string>();
  5712. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5713. {
  5714. List<string> list = new List<string>();
  5715. try
  5716. {
  5717. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5718. foreach (var item in spilitArr)
  5719. {
  5720. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5721. var depCode = spDotandEmpty[2].Substring(0, 3);
  5722. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5723. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5724. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5725. list.Add(depName);
  5726. list.Add(arrName);
  5727. }
  5728. list = list.Distinct().ToList();
  5729. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5730. }
  5731. catch (Exception)
  5732. {
  5733. dic.Add("ReturnCode", "行程录入不正确!");
  5734. }
  5735. }
  5736. else
  5737. {
  5738. dic.Add("ReturnCode", "未录入行程!");
  5739. }
  5740. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5741. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5742. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5743. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5744. {
  5745. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5746. dic.Add("Day", sp.Days.ToString());
  5747. }
  5748. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5749. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5750. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5751. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5752. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5753. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5754. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5755. designer.SetDataSource("Name", Names);
  5756. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5757. designer.SetDataSource("Day", dic["Day"] + "天");
  5758. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5759. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5760. int startIndex = 10;
  5761. const int startIndexcopy = 10;
  5762. if (dac2.Count == dac3.Count)//国家 币种 金额
  5763. {
  5764. for (int i = 0; i < dac2.Count; i++)
  5765. {
  5766. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5767. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5768. }
  5769. }
  5770. DataTable dtdac1 = new DataTable();
  5771. List<string> place = new List<string>();
  5772. dtdac1.Columns.AddRange(new DataColumn[] {
  5773. new DataColumn(){ ColumnName = "city"},
  5774. new DataColumn(){ ColumnName = "curr"},
  5775. new DataColumn(){ ColumnName = "criterion"},
  5776. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5777. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5778. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5779. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5780. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5781. });
  5782. DataTable dtdac2 = new DataTable();
  5783. dtdac2.Columns.AddRange(new DataColumn[] {
  5784. new DataColumn(){ ColumnName = "city"},
  5785. new DataColumn(){ ColumnName = "curr"},
  5786. new DataColumn(){ ColumnName = "criterion"},
  5787. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5788. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5789. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5790. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5791. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5792. });
  5793. dtdac1.TableName = "tb1";
  5794. dtdac2.TableName = "tb2";
  5795. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5796. foreach (var item in dac1)
  5797. {
  5798. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5799. if (place.Contains(item.Place))
  5800. {
  5801. continue;
  5802. }
  5803. DataRow row = dtdac1.NewRow();
  5804. row["city"] = item.Place;
  5805. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5806. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5807. row["curr"] = currency;
  5808. row["rate"] = rate.ToString("#0.0000");
  5809. row["criterion"] = item.Cost.ToString("#0.00");
  5810. row["number"] = 1;
  5811. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5812. //row["costRMB"] = rbmPrice;
  5813. dtdac1.Rows.Add(row);
  5814. place.Add(item.Place);
  5815. }
  5816. place = new List<string>();
  5817. foreach (var item in dac2)
  5818. {
  5819. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5820. if (place.Contains(item.Place))
  5821. {
  5822. continue;
  5823. }
  5824. DataRow row = dtdac2.NewRow();
  5825. row["city"] = item.Place;
  5826. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5827. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5828. row["curr"] = currency;
  5829. row["rate"] = rate.ToString("#0.0000");
  5830. row["criterion"] = item.Cost.ToString("#0.00");
  5831. row["number"] = 1;
  5832. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5833. //row["cost"] = item.SubTotal;
  5834. //row["costRMB"] = rbmPrice;
  5835. dtdac2.Rows.Add(row);
  5836. place.Add(item.Place);
  5837. //dac2totalPrice += rbmPrice;
  5838. }
  5839. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5840. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5841. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5842. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5843. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5844. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5845. string cell4Str1 = string.Empty;
  5846. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5847. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5848. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5849. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5850. string cellStr = $" 5.其他费用(";
  5851. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5852. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5853. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5854. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5855. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5856. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5857. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5858. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5859. foreach (var otherInfo in dac5)
  5860. {
  5861. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5862. }
  5863. #endregion
  5864. if (cellStr.Length > 8)
  5865. {
  5866. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5867. }
  5868. cellStr += ")";
  5869. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5870. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5871. decimal pxFee = dac4.Sum(it => it.Cost);
  5872. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5873. string celllastStr1 = "";
  5874. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5875. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5876. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5877. celllastStr1 += $",国际旅费 元";
  5878. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5879. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5880. designer.SetDataSource("cell4Str", cell4Str);
  5881. designer.SetDataSource("cellStr", cellStr);
  5882. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5883. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5884. designer.SetDataSource("celllastStr", celllastStr);
  5885. Workbook wb = designer.Workbook;
  5886. var sheet = wb.Worksheets[0];
  5887. //绑定datatable数据集
  5888. designer.SetDataSource(dtdac1);
  5889. designer.SetDataSource(dtdac2);
  5890. designer.Process();
  5891. var rowStart = dtdac1.Rows.Count;
  5892. while (rowStart > 0)
  5893. {
  5894. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5895. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5896. startIndex++;
  5897. rowStart--;
  5898. }
  5899. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5900. startIndex += 1; //总计行
  5901. rowStart = dtdac2.Rows.Count;
  5902. while (rowStart > 0)
  5903. {
  5904. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5905. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5906. startIndex++;
  5907. rowStart--;
  5908. }
  5909. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5910. wb.CalculateFormula(true);
  5911. //模板文件名
  5912. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5913. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5914. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5915. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5916. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5917. }
  5918. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5919. {
  5920. //获取模板
  5921. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5922. //载入模板
  5923. Document doc = new Document(tempPath);
  5924. DocumentBuilder builder = new DocumentBuilder(doc);
  5925. Dictionary<string, string> dic = new Dictionary<string, string>();
  5926. dic.Add("GroupName", _DelegationInfo.TeamName);
  5927. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5928. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5929. string missionLeaderJob = "";//负责人job
  5930. //int groupNumber = 0; //团人数
  5931. if (DeleClientList.Count > 0)
  5932. {
  5933. missionLeader = DeleClientList[0]?.Name ?? "";
  5934. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5935. }
  5936. dic.Add("MissionLeader", missionLeader); //团负责人
  5937. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5938. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5939. #region MyRegion
  5940. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5941. //{
  5942. // List<string> list = new List<string>();
  5943. // try
  5944. // {
  5945. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5946. // foreach (var item in spilitArr)
  5947. // {
  5948. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5949. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5950. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5951. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5952. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5953. // list.Add(depName);
  5954. // list.Add(arrName);
  5955. // }
  5956. // list = list.Distinct().ToList();
  5957. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5958. // }
  5959. // catch (Exception)
  5960. // {
  5961. // dic.Add("ReturnCode", "行程录入不正确!");
  5962. // }
  5963. //}
  5964. //else
  5965. //{
  5966. // dic.Add("ReturnCode", "未录入行程!");
  5967. //}
  5968. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5969. dic.Add("ReturnCode", string.Join("、", countrys));
  5970. #endregion
  5971. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5972. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5973. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5974. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5975. //{
  5976. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5977. // dic.Add("Day", sp.Days.ToString());
  5978. //}
  5979. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5980. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5981. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5982. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5983. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5984. //培训人员名单
  5985. int cultivateRowIndex = 7;
  5986. foreach (var item in DeleClientList)
  5987. {
  5988. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5989. builder.Write(item.Name);
  5990. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5991. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5992. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5993. string birthDay = "";
  5994. if (item.Birthday != null)
  5995. {
  5996. DateTime dt = Convert.ToDateTime(item.Birthday);
  5997. birthDay = $"{dt.Year}.{dt.Month}";
  5998. }
  5999. builder.Write(birthDay);
  6000. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6001. builder.Write(item.Company);
  6002. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6003. builder.Write(item.Job);
  6004. cultivateRowIndex++;
  6005. }
  6006. //删除多余行
  6007. //cultivateRowIndex -= 2;
  6008. int delRows = 10 + 7 - cultivateRowIndex;
  6009. if (delRows > 0)
  6010. {
  6011. for (int i = 0; i < delRows; i++)
  6012. {
  6013. table1.Rows.RemoveAt(cultivateRowIndex);
  6014. //cultivateRowIndex++;
  6015. }
  6016. }
  6017. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6018. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6019. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6020. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6021. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6022. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6023. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6024. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6025. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6026. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6027. //其他费用
  6028. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6029. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6030. //其他费用合计
  6031. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6032. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6033. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6034. //公务舱合计
  6035. //国际旅费
  6036. //string outsideJJ = "";
  6037. //string allPriceJJ = "";
  6038. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6039. {
  6040. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6041. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6042. }
  6043. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6044. {
  6045. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6046. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6047. }
  6048. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6049. {
  6050. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6051. dic.Add("AirFeeTotal", airFeeTotalStr);
  6052. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6053. dic.Add("FeeTotal", feeTotalStr);
  6054. }
  6055. foreach (var key in dic.Keys)
  6056. {
  6057. builder.MoveToBookmark(key);
  6058. builder.Write(dic[key]);
  6059. }
  6060. //模板文件名
  6061. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6062. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6063. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6064. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6065. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6066. }
  6067. }
  6068. else if (dto.ExportType == 2) //表格
  6069. {
  6070. //利用键值对存放数据
  6071. Dictionary<string, string> dic = new Dictionary<string, string>();
  6072. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6073. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6074. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6075. dic.Add("Day", sp.Days.ToString());
  6076. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6077. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6078. {
  6079. //获取模板
  6080. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6081. //载入模板
  6082. Document doc = new Document(tempPath);
  6083. DocumentBuilder builder = new DocumentBuilder(doc);
  6084. dic.Add("TeamName", _DelegationInfo.TeamName);
  6085. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6086. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6087. string missionLeaderName = "",
  6088. missionLeaderJob = "";
  6089. if (DeleClientList.Count > 0)
  6090. {
  6091. missionLeaderName = DeleClientList[0].Name;
  6092. missionLeaderJob = DeleClientList[0].Job;
  6093. }
  6094. dic.Add("MissionLeaderName", missionLeaderName);
  6095. dic.Add("MissionLeaderJob", missionLeaderJob);
  6096. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6097. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6098. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6099. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6100. int rowCount = 10;//总人数行
  6101. int startRowIndex = 7; //起始行
  6102. for (int i = 0; i < DeleClientList.Count; i++)
  6103. {
  6104. builder.MoveToCell(0, startRowIndex, 0, 0);
  6105. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6106. builder.MoveToCell(0, startRowIndex, 1, 0);
  6107. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6108. builder.Write(sex);//性别
  6109. builder.MoveToCell(0, startRowIndex, 2, 0);
  6110. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6111. builder.MoveToCell(0, startRowIndex, 3, 0);
  6112. builder.Write(DeleClientList[i].Company);//工作单位
  6113. builder.MoveToCell(0, startRowIndex, 4, 0);
  6114. builder.Write(DeleClientList[i].Job);//职务及级别
  6115. builder.MoveToCell(0, startRowIndex, 5, 0);
  6116. builder.Write("");//人员属性
  6117. builder.MoveToCell(0, startRowIndex, 6, 0);
  6118. builder.Write("");//上次出国时间
  6119. startRowIndex++;
  6120. }
  6121. int nullRow = rowCount - DeleClientList.Count;//空行
  6122. for (int i = 0; i < nullRow; i++)
  6123. {
  6124. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6125. }
  6126. foreach (var key in dic.Keys)
  6127. {
  6128. builder.MoveToBookmark(key);
  6129. builder.Write(dic[key]);
  6130. }
  6131. //模板文件名
  6132. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6133. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6134. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6135. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6136. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6137. }
  6138. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6139. {
  6140. //获取模板
  6141. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6142. //载入模板
  6143. Document doc = new Document(tempPath);
  6144. DocumentBuilder builder = new DocumentBuilder(doc);
  6145. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6146. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6147. dic.Add("Names", Names);
  6148. int accommodationRows = 12;
  6149. //int foodandotherRows = 12;
  6150. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6151. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6152. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6153. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6154. int accommodationStartIndex = 6;
  6155. decimal dac1totalPrice = 0.00M;
  6156. foreach (var dac in dac1)
  6157. {
  6158. if (dac.SubTotal == 0)
  6159. {
  6160. continue;
  6161. }
  6162. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6163. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6164. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6165. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6166. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6167. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6168. builder.Write(currency);//币种
  6169. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6170. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6171. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6172. builder.Write("");//人数
  6173. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6174. builder.Write("");//天数
  6175. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6176. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6177. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6178. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6179. builder.Write(rate.ToString("#0.0000"));//汇率
  6180. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6181. decimal rbmPrice = rate * dac.SubTotal;
  6182. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6183. accommodationStartIndex++;
  6184. dac1totalPrice += rbmPrice;
  6185. }
  6186. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6187. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6188. builder.Write("小计");
  6189. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6190. builder.Write(dac1totalPrice.ToString("#0.00"));
  6191. accommodationStartIndex++;
  6192. int nullRow = accommodationRows - dac1.Count;
  6193. //删除空行
  6194. //if (nullRow > 0)
  6195. //{
  6196. // int rowIndex = accommodationStartIndex;
  6197. // for (int i = 0; i < nullRow; i++)
  6198. // {
  6199. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6200. // row.Remove();
  6201. // rowIndex++;
  6202. // }
  6203. //}
  6204. if (dac2.Count == dac3.Count)//国家 币种 金额
  6205. {
  6206. for (int i = 0; i < dac2.Count; i++)
  6207. {
  6208. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6209. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6210. }
  6211. }
  6212. int foodandotherStartIndex = 19;//
  6213. decimal dac2totalPrice = 0.00M;
  6214. foreach (var dac in dac2)
  6215. {
  6216. if (dac.SubTotal == 0)
  6217. {
  6218. continue;
  6219. }
  6220. //foodandotherStartIndex = 12;
  6221. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6222. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6223. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6224. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6225. builder.Write(currency);//币种
  6226. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6227. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6228. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6229. builder.Write("");//人数
  6230. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6231. builder.Write("");//天数
  6232. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6233. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6234. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6235. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6236. builder.Write(rate.ToString("#0.0000"));//汇率
  6237. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6238. decimal rbmPrice = rate * dac.SubTotal;
  6239. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6240. foodandotherStartIndex++;
  6241. dac2totalPrice += rbmPrice;
  6242. }
  6243. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6244. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6245. //删除空行
  6246. //if (dac2.Count < foodandotherRows)
  6247. //{
  6248. // while (table2.Rows.Count > dac2.Count)
  6249. // {
  6250. // table2.Rows.RemoveAt(dac2.Count);
  6251. // }
  6252. //}
  6253. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6254. string otherFeeStr = "";
  6255. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6256. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6257. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6258. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6259. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6260. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6261. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6262. foreach (var otherInfo in dac5)
  6263. {
  6264. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6265. }
  6266. #endregion
  6267. if (otherFeeStr.Length > 0)
  6268. {
  6269. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6270. otherFeeStr = $"({otherFeeStr})";
  6271. dic.Add("OtherFeeStr", otherFeeStr);
  6272. }
  6273. foreach (var key in dic.Keys)
  6274. {
  6275. builder.MoveToBookmark(key);
  6276. builder.Write(dic[key]);
  6277. }
  6278. //模板文件名
  6279. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6280. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6281. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6282. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6283. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6284. }
  6285. }
  6286. else if (dto.ExportType == 3)
  6287. {
  6288. if (dto.SubTypeId == 1) //团组成员名单
  6289. {
  6290. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6291. //获取模板
  6292. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6293. //载入模板
  6294. Document doc = new Document(tempPath);
  6295. DocumentBuilder builder = new DocumentBuilder(doc);
  6296. //获取word里所有表格
  6297. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6298. //获取所填表格的序数
  6299. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6300. var rowStart = tableOne.Rows[0]; //获取第1行
  6301. //循环赋值
  6302. for (int i = 0; i < DeleClientList.Count; i++)
  6303. {
  6304. builder.MoveToCell(0, i + 1, 0, 0);
  6305. builder.Write(DeleClientList[i].Name);
  6306. builder.MoveToCell(0, i + 1, 1, 0);
  6307. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6308. builder.Write(sex);
  6309. builder.MoveToCell(0, i + 1, 2, 0);
  6310. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6311. builder.MoveToCell(0, i + 1, 3, 0);
  6312. builder.Write(DeleClientList[i].Company);
  6313. builder.MoveToCell(0, i + 1, 4, 0);
  6314. builder.Write(DeleClientList[i].Job);
  6315. }
  6316. //删除多余行
  6317. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6318. {
  6319. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6320. }
  6321. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6322. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6323. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6324. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6325. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6326. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6327. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6328. }
  6329. }
  6330. return Ok(JsonView(400, "操作失败!", ""));
  6331. }
  6332. catch (Exception ex)
  6333. {
  6334. return Ok(JsonView(400, ex.Message, ""));
  6335. }
  6336. }
  6337. /// <summary>
  6338. /// 获取三公费用标准city
  6339. /// </summary>
  6340. /// <param name="placeData"></param>
  6341. /// <param name="nationalTravelFeeId"></param>
  6342. /// <returns></returns>
  6343. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6344. {
  6345. string _city = string.Empty;
  6346. if (placeData.Count < 1) return _city;
  6347. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6348. if (data == null) return _city;
  6349. string country = data.Country;
  6350. string city = data.City;
  6351. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6352. else _city = city;
  6353. return _city;
  6354. }
  6355. /// <summary>
  6356. /// 团组模块 - 出入境费用 - 明细表导出
  6357. /// </summary>
  6358. /// <returns></returns>
  6359. [HttpPost]
  6360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6361. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6362. {
  6363. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6364. if (data.Code != 0)
  6365. {
  6366. return Ok(JsonView(false, data.Msg));
  6367. }
  6368. return Ok(JsonView(true, data.Msg, data.Data));
  6369. }
  6370. /// <summary>
  6371. /// 团组模块 - 出入境费用 - 一键清空
  6372. /// </summary>
  6373. /// <returns></returns>
  6374. [HttpPost]
  6375. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6377. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6378. {
  6379. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6380. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6381. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6382. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6383. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6384. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6385. .SetColumns(x => new Grp_DayOtherPrice
  6386. {
  6387. IsDel = 1,
  6388. DeleteUserId = dto.UserId,
  6389. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6390. })
  6391. .ExecuteCommandAsync();
  6392. if (_view.Code == 0)
  6393. {
  6394. return Ok(JsonView(true, "操作成功"));
  6395. }
  6396. return Ok(JsonView(false, "操作失败"));
  6397. }
  6398. /// <summary>
  6399. /// 团组模块 - 出入境费用 - 子项删除
  6400. /// </summary>
  6401. /// <returns></returns>
  6402. [HttpPost]
  6403. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6405. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6406. {
  6407. try
  6408. {
  6409. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6410. if (data.Code != 0)
  6411. {
  6412. return Ok(JsonView(false, data.Msg));
  6413. }
  6414. return Ok(JsonView(true, "操作成功!", data.Data));
  6415. }
  6416. catch (Exception ex)
  6417. {
  6418. return Ok(JsonView(false, ex.Message));
  6419. }
  6420. }
  6421. /// <summary>
  6422. /// 删除三公其他费用
  6423. /// </summary>
  6424. /// <param name="dto"></param>
  6425. /// <returns></returns>
  6426. [HttpPost]
  6427. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6428. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6429. {
  6430. var jw = JsonView(false, "删除失败!");
  6431. var data = new Grp_DayOtherPrice()
  6432. {
  6433. Id = dto.Id,
  6434. IsDel = 1,
  6435. DeleteUserId = dto.DeleteUserId,
  6436. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6437. };
  6438. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6439. if (del > 0)
  6440. {
  6441. jw.Code = 200;
  6442. jw.Msg = "删除成功!";
  6443. }
  6444. return Ok(jw);
  6445. }
  6446. /// <summary>
  6447. /// 团组模块 - 出入境国家费用标准 List
  6448. /// </summary>
  6449. /// <returns></returns>
  6450. [HttpPost]
  6451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6452. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6453. {
  6454. try
  6455. {
  6456. Stopwatch sw = new Stopwatch();
  6457. sw.Start();
  6458. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6459. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6460. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6461. Where gntf.Isdel = 0");
  6462. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6463. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6464. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6465. //foreach (var item in nationalTravel)
  6466. //{
  6467. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6468. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6469. // if (otherData != null)
  6470. // {
  6471. // cityData.Remove(otherData);
  6472. // cityData.Add(otherData);
  6473. // }
  6474. // nationalTravelFeeData1.Add(new
  6475. // {
  6476. // Country = item.Country,
  6477. // CityData = cityData
  6478. // });
  6479. //}
  6480. sw.Stop();
  6481. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6482. }
  6483. catch (Exception ex)
  6484. {
  6485. return Ok(JsonView(false, ex.Message));
  6486. throw;
  6487. }
  6488. }
  6489. /// <summary>
  6490. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6491. /// </summary>
  6492. /// <returns></returns>
  6493. [HttpPost]
  6494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6495. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6496. {
  6497. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6498. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6499. List<string> countryData = new List<string>();
  6500. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6501. countryData = countryData.Distinct().ToList();
  6502. List<dynamic> dataSource = new List<dynamic>();
  6503. foreach (var item in countryData)
  6504. {
  6505. var cityData1 = new List<string>();
  6506. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6507. var countryData2 = new
  6508. {
  6509. CountryName = item,
  6510. CityData = cityData1
  6511. };
  6512. dataSource.Add(countryData2);
  6513. }
  6514. return Ok(JsonView(true, "查询成功!", dataSource));
  6515. }
  6516. /// <summary>
  6517. /// 团组模块 - 出入境国家费用标准 Page List
  6518. /// </summary>
  6519. /// <returns></returns>
  6520. [HttpPost]
  6521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6522. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6523. {
  6524. int portId = dto.PortType;
  6525. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6526. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6527. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6528. string whereSql = string.Empty;
  6529. if (!string.IsNullOrEmpty(dto.Country))
  6530. {
  6531. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6532. }
  6533. if (!string.IsNullOrEmpty(dto.City))
  6534. {
  6535. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6536. }
  6537. string pageSql = string.Format(@"Select * From (
  6538. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6539. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6540. From Grp_NationalTravelFee gntf
  6541. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6542. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6543. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6544. RefAsync<int> total = 0;
  6545. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6546. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6547. }
  6548. /// <summary>
  6549. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6550. /// </summary>
  6551. /// <returns></returns>
  6552. [HttpPost]
  6553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6554. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6555. {
  6556. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6557. int portId = dto.PortType;
  6558. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6559. string whereSql = string.Empty;
  6560. if (!string.IsNullOrEmpty(dto.Country))
  6561. {
  6562. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6563. }
  6564. if (!string.IsNullOrEmpty(dto.City))
  6565. {
  6566. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6567. }
  6568. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6569. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6570. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6571. From Grp_NationalTravelFee gntf
  6572. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6573. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6574. Where gntf.Isdel = 0 {0} ", whereSql);
  6575. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6576. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6577. }
  6578. /// <summary>
  6579. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6580. /// </summary>
  6581. /// <returns></returns>
  6582. [HttpPost]
  6583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6584. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6585. {
  6586. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6587. if (data.Code != 0)
  6588. {
  6589. return Ok(JsonView(false, data.Msg));
  6590. }
  6591. return Ok(JsonView(true, "操作成功!", data.Data));
  6592. }
  6593. /// <summary>
  6594. /// 团组模块 - 出入境国家费用标准 - Del
  6595. /// </summary>
  6596. /// <returns></returns>
  6597. [HttpPost]
  6598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6599. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6600. {
  6601. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6602. {
  6603. Id = dto.Id,
  6604. DeleteUserId = dto.DeleteUserId,
  6605. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6606. IsDel = 1
  6607. };
  6608. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6609. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6610. .WhereColumns(it => new { it.Id })
  6611. .ExecuteCommandAsync();
  6612. if (delStatus <= 0)
  6613. {
  6614. return Ok(JsonView(false, "删除失败!"));
  6615. }
  6616. return Ok(JsonView(true, "操作成功!"));
  6617. }
  6618. /// <summary>
  6619. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6620. /// 注:Get 请求Headers 加 Token
  6621. /// </summary>
  6622. /// <param name="groupId"></param>
  6623. /// <returns></returns>
  6624. [HttpGet("{groupId}")]
  6625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6626. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6627. {
  6628. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6629. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6630. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6631. data.ForEach(x =>
  6632. {
  6633. x.CreateUserId = _currUserInfo.UserId;
  6634. });
  6635. if (data.Any())
  6636. {
  6637. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6638. if (add > 0)
  6639. {
  6640. return Ok(JsonView(true, "操作成功!"));
  6641. }
  6642. }
  6643. return Ok(JsonView(false, "未操作!"));
  6644. }
  6645. #endregion
  6646. #region 团组经理模块 出入境费用-草稿
  6647. /// <summary>
  6648. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6649. /// </summary>
  6650. /// <returns></returns>
  6651. [HttpPost]
  6652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6653. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6654. {
  6655. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6656. .Where(x => x.IsDel == 0)
  6657. .OrderByDescending(x => x.CreateTime)
  6658. .Select(x => new { x.Id, x.DraftName })
  6659. .ToListAsync();
  6660. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6661. //SetDataInfoView
  6662. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6663. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6664. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6665. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6666. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6667. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6668. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6669. //默认币种显示
  6670. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6671. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6672. return Ok(JsonView(true, "查询成功!", new
  6673. {
  6674. DraftNameDatas = draftNameDatas,
  6675. CurrencyData = _CurrencyData,
  6676. WordTypeData = _WordTypeData,
  6677. ExcelTypeData = _ExcelTypeData,
  6678. CurrencyInit = _currencyInfos,
  6679. ViewPermissionData = viewPermissionData
  6680. }));
  6681. }
  6682. /// <summary>
  6683. /// 团组模块 - 出入境费用-草稿
  6684. /// 实时汇率 tips
  6685. /// 机票费用 tips
  6686. /// </summary>
  6687. /// <returns></returns>
  6688. [HttpPost]
  6689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6690. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6691. {
  6692. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6693. return Ok(JsonView(true, "查询成功!", new
  6694. {
  6695. //GroupNameData = groupNameData.Data,
  6696. //visaData = visaData.Data,
  6697. //airData = airData.Data,
  6698. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6699. }));
  6700. }
  6701. /// <summary>
  6702. /// 团组模块 - 出入境费用-草稿
  6703. /// 签证费用 tips
  6704. /// </summary>
  6705. /// <returns></returns>
  6706. [HttpPost]
  6707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6708. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6709. {
  6710. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6711. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6712. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6713. .Select(x => x.NationalTravelFeeId)
  6714. .Distinct()
  6715. .ToListAsync();
  6716. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6717. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6718. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6719. .Select(x => x.Country)
  6720. .Distinct()
  6721. .ToArrayAsync();
  6722. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6723. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6724. return Ok(JsonView(true, "查询成功!", new
  6725. {
  6726. totalAmt = totalAmt,
  6727. remark = remark
  6728. }));
  6729. }
  6730. /// <summary>
  6731. /// 团组模块 - 出入境费用-草稿 - Info
  6732. /// </summary>
  6733. /// <returns></returns>
  6734. [HttpPost]
  6735. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6737. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6738. {
  6739. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6740. }
  6741. /// <summary>
  6742. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6743. /// </summary>
  6744. /// <returns></returns>
  6745. [HttpPost]
  6746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6747. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6748. {
  6749. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6750. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6751. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6752. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6753. foreach (var userId in dto.UserIds)
  6754. {
  6755. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6756. }
  6757. if (permissions.Any())
  6758. {
  6759. _sqlSugar.BeginTran();
  6760. try
  6761. {
  6762. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6763. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6764. if (result < 1)
  6765. {
  6766. _sqlSugar.RollbackTran();
  6767. return Ok(JsonView(false));
  6768. }
  6769. }
  6770. catch (Exception ex)
  6771. {
  6772. _sqlSugar.RollbackTran();
  6773. return Ok(JsonView(false, ex.Message));
  6774. }
  6775. _sqlSugar.CommitTran();
  6776. return Ok(JsonView(true));
  6777. }
  6778. return Ok(JsonView(false));
  6779. }
  6780. /// <summary>
  6781. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6782. /// </summary>
  6783. /// <returns></returns>
  6784. [HttpPost]
  6785. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6787. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6788. {
  6789. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6790. if (data.Code != 0)
  6791. {
  6792. return Ok(JsonView(false, data.Msg));
  6793. }
  6794. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6795. //汇率信息记录
  6796. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6797. return Ok(JsonView(true, data.Msg, data.Data));
  6798. }
  6799. /// <summary>
  6800. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6801. /// </summary>
  6802. /// <param name="dto"></param>
  6803. /// <returns></returns>
  6804. [HttpPost]
  6805. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6807. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6808. {
  6809. try
  6810. {
  6811. var id = dto.Id;
  6812. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6813. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6814. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6815. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6816. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6817. 3 团组成员名单 1 团组成员名单", ""));
  6818. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6819. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6820. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6821. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6822. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6823. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6824. //数据源
  6825. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6826. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6827. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6828. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6829. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6830. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6831. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6832. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6833. .Select((x, a, b) => new
  6834. {
  6835. x.Index,
  6836. itemName = a.Name,
  6837. CurrencyStr = b.Name,
  6838. x.Cost,
  6839. x.SubTotal,
  6840. x.Remark
  6841. })
  6842. .OrderBy((x) => x.Index)
  6843. .ToList(); //其他款项费用
  6844. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6845. var peiceItemCurrencys = new List<string>();
  6846. if (_DayAndCosts.Any())
  6847. {
  6848. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6849. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6850. }
  6851. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6852. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6853. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6854. {
  6855. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6856. }
  6857. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6858. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6859. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6860. if (dto.ExportType == 1) //明细表
  6861. {
  6862. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6863. {
  6864. //获取模板
  6865. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6866. //载入模板
  6867. Document doc = new Document(tempPath);
  6868. DocumentBuilder builder = new DocumentBuilder(doc);
  6869. //利用键值对存放数据
  6870. Dictionary<string, string> dic = new Dictionary<string, string>();
  6871. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6872. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6873. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6874. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6875. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6876. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6877. //境内费用(其他费用)
  6878. if (_EnterExitCosts.ChoiceOne == 1)
  6879. {
  6880. string row1_1 = "";
  6881. if (_EnterExitCosts.Visa > 0)
  6882. {
  6883. //insidePayTotal += _EnterExitCosts.Visa;
  6884. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6885. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6886. {
  6887. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6888. }
  6889. }
  6890. string row1_2 = "";
  6891. if (_EnterExitCosts.YiMiao > 0)
  6892. {
  6893. //insidePayTotal += _EnterExitCosts.YiMiao;
  6894. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6895. }
  6896. if (_EnterExitCosts.HeSuan > 0)
  6897. {
  6898. //insidePayTotal += _EnterExitCosts.HeSuan;
  6899. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6900. }
  6901. if (_EnterExitCosts.Service > 0)
  6902. {
  6903. //insidePayTotal += _EnterExitCosts.Service;
  6904. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6905. }
  6906. string row1_3 = "";
  6907. if (_EnterExitCosts.Safe > 0)
  6908. {
  6909. //insidePayTotal += _EnterExitCosts.Safe;
  6910. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6911. }
  6912. if (_EnterExitCosts.Ticket > 0)
  6913. {
  6914. //insidePayTotal += _EnterExitCosts.Ticket;
  6915. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6916. }
  6917. string row1 = "";
  6918. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6919. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6920. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6921. row1 += $"备注:{_EnterExitCosts.Remark}";
  6922. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6923. dic.Add("Row1Str", row1);
  6924. }
  6925. string airTotalStr = string.Empty,
  6926. airPriceStr = string.Empty;
  6927. //经济舱
  6928. if (_EnterExitCosts.SumJJC == 1)
  6929. {
  6930. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6931. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6932. }
  6933. //公务舱
  6934. if (_EnterExitCosts.SumGWC == 1)
  6935. {
  6936. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6937. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6938. }
  6939. //头等舱
  6940. if (_EnterExitCosts.SumTDC == 1)
  6941. {
  6942. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6943. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6944. }
  6945. //汇率描述
  6946. string rateStr = "";
  6947. if (peiceItemCurrencyInfos.Any())
  6948. {
  6949. rateStr = "\r\n汇率描述:";
  6950. foreach (var item in peiceItemCurrencyInfos)
  6951. {
  6952. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6953. }
  6954. }
  6955. string twoItemRemark = "备注:";
  6956. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6957. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6958. dic.Add("AirTotalStr", airTotalStr);
  6959. dic.Add("AirPriceStr", airPriceStr);
  6960. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6961. dic.Add("TwoItemRemark", twoItemRemark);
  6962. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6963. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6964. int table1Row = 0,
  6965. table2Row = 0,
  6966. table3Row = 0,
  6967. table4Row = 0,
  6968. table5Row = 0;
  6969. //住宿费
  6970. if (_EnterExitCosts.ChoiceThree == 1)
  6971. {
  6972. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6973. table1Row = dac1.Count;
  6974. #region 填充word表格内容
  6975. for (int i = 0; i < dac1.Count; i++)
  6976. {
  6977. var dac = dac1[i];
  6978. if (dac == null) continue;
  6979. builder.MoveToCell(0, i, 0, 0);
  6980. builder.Write("第" + dac.Days.ToString() + "晚:");
  6981. builder.MoveToCell(0, i, 1, 0);
  6982. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6983. //builder.Write(dac.Place == null ? "" : dac.Place);
  6984. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6985. builder.MoveToCell(0, i, 2, 0);
  6986. builder.Write("费用标准:");
  6987. string curr = "";
  6988. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6989. if (currData != null)
  6990. {
  6991. curr = currData.Name;
  6992. }
  6993. builder.MoveToCell(0, i, 3, 0);
  6994. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6995. builder.MoveToCell(0, i, 4, 0);
  6996. builder.Write("费用小计:");
  6997. builder.MoveToCell(0, i, 5, 0);
  6998. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6999. }
  7000. #endregion
  7001. }
  7002. else dic.Add("SubZS", "0.00");
  7003. //删除多余行
  7004. while (table1.Rows.Count > table1Row)
  7005. {
  7006. table1.Rows.RemoveAt(table1Row);
  7007. }
  7008. //伙食费
  7009. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7010. if (_EnterExitCosts.ChoiceFour == 1)
  7011. {
  7012. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7013. table2Row = dac2.Count;
  7014. #region 填充word表格内容
  7015. for (int i = 0; i < dac2.Count; i++)
  7016. {
  7017. var dac = dac2[i];
  7018. if (dac == null) continue;
  7019. builder.MoveToCell(1, i, 0, 0);
  7020. builder.Write("第" + dac.Days.ToString() + "天:");
  7021. builder.MoveToCell(1, i, 1, 0);
  7022. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7023. builder.MoveToCell(1, i, 2, 0);
  7024. builder.Write("费用标准:");
  7025. string curr = "";
  7026. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7027. if (currData != null)
  7028. {
  7029. curr = currData.Name;
  7030. }
  7031. builder.MoveToCell(1, i, 3, 0);
  7032. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7033. builder.MoveToCell(1, i, 4, 0);
  7034. builder.Write("费用小计:");
  7035. builder.MoveToCell(1, i, 5, 0);
  7036. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7037. }
  7038. #endregion
  7039. }
  7040. else dic.Add("SubHS", "0.00");
  7041. //删除多余行
  7042. while (table2.Rows.Count > table2Row)
  7043. {
  7044. table2.Rows.RemoveAt(table2Row);
  7045. }
  7046. //公杂费
  7047. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7048. if (_EnterExitCosts.ChoiceFive == 1)
  7049. {
  7050. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7051. table3Row = dac3.Count;
  7052. #region 填充word表格内容
  7053. for (int i = 0; i < dac3.Count; i++)
  7054. {
  7055. var dac = dac3[i];
  7056. if (dac == null) continue;
  7057. builder.MoveToCell(2, i, 0, 0);
  7058. builder.Write("第" + dac.Days.ToString() + "天:");
  7059. builder.MoveToCell(2, i, 1, 0);
  7060. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7061. builder.MoveToCell(2, i, 2, 0);
  7062. builder.Write("费用标准:");
  7063. string curr = "";
  7064. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7065. if (currData != null)
  7066. {
  7067. curr = currData.Name;
  7068. }
  7069. builder.MoveToCell(2, i, 3, 0);
  7070. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7071. builder.MoveToCell(2, i, 4, 0);
  7072. builder.Write("费用小计:");
  7073. builder.MoveToCell(2, i, 5, 0);
  7074. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7075. }
  7076. //删除多余行
  7077. while (table3.Rows.Count > table3Row)
  7078. {
  7079. table3.Rows.RemoveAt(table3Row);
  7080. }
  7081. #endregion
  7082. }
  7083. else dic.Add("SubGZF", "0.00");
  7084. //删除多余行
  7085. while (table3.Rows.Count > table3Row)
  7086. {
  7087. table3.Rows.RemoveAt(table3Row);
  7088. }
  7089. //培训费
  7090. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7091. if (_EnterExitCosts.ChoiceSix == 1)
  7092. {
  7093. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7094. dic.Add("SubPX", pxStr);
  7095. table4Row = dac4.Count;
  7096. #region 填充word表格内容
  7097. for (int i = 0; i < dac4.Count; i++)
  7098. {
  7099. var dac = dac4[i];
  7100. if (dac == null) continue;
  7101. builder.MoveToCell(3, i, 0, 0);
  7102. builder.Write("第" + dac.Days.ToString() + "天:");
  7103. builder.MoveToCell(3, i, 1, 0);
  7104. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7105. builder.MoveToCell(3, i, 2, 0);
  7106. builder.Write("费用标准:");
  7107. string curr = "";
  7108. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7109. if (currData != null)
  7110. {
  7111. curr = currData.Name;
  7112. }
  7113. builder.MoveToCell(3, i, 3, 0);
  7114. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7115. builder.MoveToCell(3, i, 4, 0);
  7116. builder.Write("费用小计:");
  7117. builder.MoveToCell(3, i, 5, 0);
  7118. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7119. }
  7120. #endregion
  7121. }
  7122. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7123. //删除多余行
  7124. while (table4.Rows.Count > table4Row)
  7125. {
  7126. table4.Rows.RemoveAt(table4Row);
  7127. }
  7128. //其他费用
  7129. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7130. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7131. {
  7132. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7133. dic.Add("titleQi", qtStr);
  7134. table5Row = dac5.Count;
  7135. #region 填充word表格内容
  7136. for (int i = 0; i < dac5.Count; i++)
  7137. {
  7138. var dac = dac5[i];
  7139. if (dac == null) continue;
  7140. builder.MoveToCell(4, i, 0, 0);
  7141. builder.Write("第" + dac.Index.ToString() + "项:");
  7142. builder.MoveToCell(4, i, 1, 0);
  7143. builder.Write(dac.itemName);
  7144. builder.MoveToCell(4, i, 2, 0);
  7145. builder.Write("费用标准:");
  7146. builder.MoveToCell(4, i, 3, 0);
  7147. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7148. builder.MoveToCell(4, i, 4, 0);
  7149. builder.Write("费用小计:");
  7150. builder.MoveToCell(4, i, 5, 0);
  7151. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7152. builder.MoveToCell(4, i, 6, 0);
  7153. builder.Write("备注:");
  7154. builder.MoveToCell(4, i, 7, 0);
  7155. builder.Write(dac.Remark);
  7156. }
  7157. #endregion
  7158. }
  7159. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7160. //删除多余行
  7161. while (table5.Rows.Count > table5Row)
  7162. {
  7163. table5.Rows.RemoveAt(table5Row);
  7164. }
  7165. //加上其他费用
  7166. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7167. decimal subJJC = 0.00M,
  7168. subGWC = 0.00M,
  7169. subTDC = 0.00M;
  7170. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7171. string totalLabel = string.Format("全部费用总计:");
  7172. //经济舱
  7173. if (_EnterExitCosts.SumJJC == 1)
  7174. {
  7175. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7176. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7177. }
  7178. //公务舱
  7179. if (_EnterExitCosts.SumGWC == 1)
  7180. {
  7181. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7182. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7183. }
  7184. //头等舱
  7185. if (_EnterExitCosts.SumTDC == 1)
  7186. {
  7187. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7188. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7189. }
  7190. //TotalLabel
  7191. dic.Add("TotalLabel", totalLabel);
  7192. #region 填充word模板书签内容
  7193. foreach (var key in dic.Keys)
  7194. {
  7195. Bookmark bookmark = doc.Range.Bookmarks[key];
  7196. if (bookmark != null)
  7197. {
  7198. builder.MoveToBookmark(key);
  7199. builder.Write(dic[key]);
  7200. }
  7201. }
  7202. #endregion
  7203. //文件名
  7204. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7205. strFileName = CommonFun.ValidFileName(strFileName);
  7206. AsposeHelper.removewatermark_v2180();
  7207. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7208. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7209. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7210. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7211. }
  7212. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7213. {
  7214. //获取模板
  7215. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7216. //载入模板
  7217. Document doc = new Document(tempPath);
  7218. DocumentBuilder builder = new DocumentBuilder(doc);
  7219. Dictionary<string, string> dic = new Dictionary<string, string>();
  7220. string returnCodeLabel = string.Empty;
  7221. if (nationalTravelFeeData.Any())
  7222. {
  7223. List<string> list = new List<string>();
  7224. foreach (var item in nationalTravelFeeData)
  7225. {
  7226. list.Add($"{item.Country}({item.City})");
  7227. }
  7228. list = list.Distinct().ToList();
  7229. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7230. }
  7231. var countryLabel = string.Empty;
  7232. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7233. if (countryData.Any())
  7234. {
  7235. countryLabel = string.Join("、", countryData);
  7236. }
  7237. dic.Add("ReturnCodeAir", returnCodeLabel);
  7238. dic.Add("VisitStartDate", "-");
  7239. dic.Add("VisitEndDate", "-");
  7240. dic.Add("Day", "-");
  7241. dic.Add("VisitCountry", countryLabel);
  7242. dic.Add("ClientUnit", "-");
  7243. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7244. //dic.Add("Names", Names);
  7245. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7246. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7247. decimal dac1totalPrice = 0.00M;
  7248. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7249. foreach (var dac in dac1)
  7250. {
  7251. if (dac.SubTotal == 0.00M)
  7252. {
  7253. continue;
  7254. }
  7255. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7256. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7257. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7258. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7259. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7260. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7261. builder.Write(currency);//币种
  7262. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7263. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7264. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7265. builder.Write("");//人数
  7266. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7267. builder.Write("");//天数
  7268. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7269. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7270. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7271. decimal rate = 0.00M;
  7272. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7273. builder.Write(rate.ToString("#0.0000"));//汇率
  7274. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7275. decimal rbmPrice = dac.SubTotal;
  7276. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7277. accommodationStartIndex++;
  7278. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7279. }
  7280. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7281. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7282. {
  7283. table1.Rows.RemoveAt(i - 1);
  7284. foodandotherStartIndex--;
  7285. }
  7286. if (dac2.Count == dac3.Count)//国家 币种 金额
  7287. {
  7288. for (int i = 0; i < dac2.Count; i++)
  7289. {
  7290. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7291. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7292. }
  7293. }
  7294. decimal dac2totalPrice = 0.00M;
  7295. foreach (var dac in dac2)
  7296. {
  7297. if (dac.SubTotal == 0)
  7298. {
  7299. continue;
  7300. }
  7301. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7302. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7303. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7304. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7305. builder.Write(currency);//币种
  7306. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7307. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7308. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7309. builder.Write("");//人数
  7310. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7311. builder.Write("");//天数
  7312. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7313. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7314. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7315. decimal rate = 0.00M;
  7316. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7317. builder.Write(rate.ToString("#0.0000"));//汇率
  7318. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7319. decimal rbmPrice = dac.SubTotal;
  7320. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7321. foodandotherStartIndex++;
  7322. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7323. }
  7324. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7325. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7326. {
  7327. table1.Rows.RemoveAt(i - 1);
  7328. }
  7329. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7330. string otherFeeStr = "";
  7331. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7332. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7333. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7334. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7335. foreach (var otherInfo in dac5)
  7336. {
  7337. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7338. }
  7339. #endregion
  7340. if (otherFeeStr.Length > 0)
  7341. {
  7342. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7343. otherFeeStr = $"({otherFeeStr})";
  7344. dic.Add("OtherFeeStr", otherFeeStr);
  7345. }
  7346. //总计
  7347. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7348. //国际旅费
  7349. string outsideAir = string.Empty;
  7350. string allPriceAir = string.Empty;
  7351. if (_EnterExitCosts.SumJJC == 1)
  7352. {
  7353. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7354. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7355. }
  7356. if (_EnterExitCosts.SumGWC == 1)
  7357. {
  7358. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7359. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7360. }
  7361. if (_EnterExitCosts.SumTDC == 1)
  7362. {
  7363. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7364. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7365. }
  7366. dic.Add("InTravelPrice", $"({outsideAir})");
  7367. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7368. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7369. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7370. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7371. foreach (var key in dic.Keys)
  7372. {
  7373. builder.MoveToBookmark(key);
  7374. builder.Write(dic[key]);
  7375. }
  7376. //模板文件名
  7377. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7378. strFileName = CommonFun.ValidFileName(strFileName);
  7379. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7380. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7381. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7382. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7383. }
  7384. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7385. {
  7386. //获取模板
  7387. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7388. //载入模板
  7389. WorkbookDesigner designer = new WorkbookDesigner();
  7390. designer.Workbook = new Workbook(tempPath);
  7391. Dictionary<string, string> dic = new Dictionary<string, string>();
  7392. string returnCodeLabel = string.Empty;
  7393. if (nationalTravelFeeData.Any())
  7394. {
  7395. List<string> list = new List<string>();
  7396. foreach (var item in nationalTravelFeeData)
  7397. {
  7398. list.Add($"{item.Country}({item.City})");
  7399. }
  7400. list = list.Distinct().ToList();
  7401. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7402. }
  7403. var countryLabel = string.Empty;
  7404. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7405. if (countryData.Any())
  7406. {
  7407. countryLabel = string.Join("、", countryData);
  7408. }
  7409. dic.Add("ReturnCodeAir", returnCodeLabel);
  7410. dic.Add("VisitStartDate", "-");
  7411. dic.Add("VisitEndDate", "-");
  7412. dic.Add("Day", "0");
  7413. dic.Add("VisitCountry", countryLabel);
  7414. dic.Add("ClientUnit", "-");
  7415. designer.SetDataSource("ClientUnit", "-");
  7416. designer.SetDataSource("VisitCountry", countryLabel);
  7417. designer.SetDataSource("Group", "-");
  7418. designer.SetDataSource("ClientUnitTitle", "-");
  7419. designer.SetDataSource("Name", "-");
  7420. designer.SetDataSource("VisitStartDate", "-");
  7421. designer.SetDataSource("Day", "0");
  7422. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7423. designer.SetDataSource("ReturnCodeAir", "-");
  7424. int startIndex = 10;
  7425. const int startIndexcopy = 10;
  7426. if (dac2.Count == dac3.Count)//国家 币种 金额
  7427. {
  7428. for (int i = 0; i < dac2.Count; i++)
  7429. {
  7430. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7431. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7432. }
  7433. }
  7434. DataTable dtdac1 = new DataTable();
  7435. List<string> place = new List<string>();
  7436. dtdac1.Columns.AddRange(new DataColumn[] {
  7437. new DataColumn(){ ColumnName = "city"},
  7438. new DataColumn(){ ColumnName = "curr"},
  7439. new DataColumn(){ ColumnName = "criterion"},
  7440. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7441. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7442. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7443. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7444. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7445. });
  7446. DataTable dtdac2 = new DataTable();
  7447. dtdac2.Columns.AddRange(new DataColumn[] {
  7448. new DataColumn(){ ColumnName = "city"},
  7449. new DataColumn(){ ColumnName = "curr"},
  7450. new DataColumn(){ ColumnName = "criterion"},
  7451. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7452. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7453. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7454. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7455. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7456. });
  7457. dtdac1.TableName = "tb1";
  7458. dtdac2.TableName = "tb2";
  7459. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7460. foreach (var item in dac1)
  7461. {
  7462. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7463. if (place.Contains(item.Place))
  7464. {
  7465. continue;
  7466. }
  7467. DataRow row = dtdac1.NewRow();
  7468. row["city"] = item.Place;
  7469. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7470. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7471. row["curr"] = currency;
  7472. row["rate"] = rate.ToString("#0.0000");
  7473. row["criterion"] = item.Cost.ToString("#0.00");
  7474. row["number"] = 1;
  7475. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7476. //row["costRMB"] = rbmPrice;
  7477. dtdac1.Rows.Add(row);
  7478. place.Add(item.Place);
  7479. }
  7480. place = new List<string>();
  7481. foreach (var item in dac2)
  7482. {
  7483. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7484. if (place.Contains(item.Place))
  7485. {
  7486. continue;
  7487. }
  7488. DataRow row = dtdac2.NewRow();
  7489. row["city"] = item.Place;
  7490. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7491. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7492. row["curr"] = currency;
  7493. row["rate"] = rate.ToString("#0.0000");
  7494. row["criterion"] = item.Cost.ToString("#0.00");
  7495. row["number"] = 1;
  7496. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7497. //row["cost"] = item.SubTotal;
  7498. //row["costRMB"] = rbmPrice;
  7499. dtdac2.Rows.Add(row);
  7500. place.Add(item.Place);
  7501. //dac2totalPrice += rbmPrice;
  7502. }
  7503. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7504. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7505. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7506. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7507. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7508. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7509. string cell4Str1 = string.Empty;
  7510. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7511. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7512. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7513. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7514. string cellStr = $" 5.其他费用(";
  7515. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7516. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7517. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7518. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7519. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7520. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7521. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7522. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7523. foreach (var otherInfo in dac5)
  7524. {
  7525. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7526. }
  7527. #endregion
  7528. if (cellStr.Length > 8)
  7529. {
  7530. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7531. }
  7532. cellStr += ")";
  7533. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7534. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7535. decimal pxFee = dac4.Sum(it => it.Cost);
  7536. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7537. string celllastStr1 = "";
  7538. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7539. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7540. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7541. celllastStr1 += $",国际旅费 元";
  7542. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7543. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7544. designer.SetDataSource("cell4Str", cell4Str);
  7545. designer.SetDataSource("cellStr", cellStr);
  7546. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7547. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7548. designer.SetDataSource("celllastStr", celllastStr);
  7549. Workbook wb = designer.Workbook;
  7550. var sheet = wb.Worksheets[0];
  7551. //绑定datatable数据集
  7552. designer.SetDataSource(dtdac1);
  7553. designer.SetDataSource(dtdac2);
  7554. designer.Process();
  7555. var rowStart = dtdac1.Rows.Count;
  7556. while (rowStart > 0)
  7557. {
  7558. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7559. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7560. startIndex++;
  7561. rowStart--;
  7562. }
  7563. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7564. startIndex += 1; //总计行
  7565. rowStart = dtdac2.Rows.Count;
  7566. while (rowStart > 0)
  7567. {
  7568. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7569. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7570. startIndex++;
  7571. rowStart--;
  7572. }
  7573. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7574. wb.CalculateFormula(true);
  7575. //模板文件名
  7576. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7577. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7578. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7579. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7580. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7581. }
  7582. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7583. {
  7584. //获取模板
  7585. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7586. //载入模板
  7587. Document doc = new Document(tempPath);
  7588. DocumentBuilder builder = new DocumentBuilder(doc);
  7589. Dictionary<string, string> dic = new Dictionary<string, string>();
  7590. dic.Add("GroupName", "-");
  7591. dic.Add("ClientUnit", "-");
  7592. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7593. //string missionLeaderJob = "";//负责人job
  7594. //int groupNumber = 0; //团人数
  7595. dic.Add("MissionLeader", "-"); //团负责人
  7596. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7597. dic.Add("GroupNumber", "0"); //团人数
  7598. dic.Add("Day", "0");
  7599. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7600. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7601. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7602. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7603. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7604. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7605. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7606. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7607. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7608. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7609. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7610. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7611. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7612. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7613. //其他费用
  7614. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7615. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7616. //其他费用合计
  7617. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7618. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7619. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7620. //公务舱合计
  7621. //国际旅费
  7622. //string outsideJJ = "";
  7623. //string allPriceJJ = "";
  7624. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7625. {
  7626. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7627. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7628. }
  7629. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7630. {
  7631. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7632. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7633. }
  7634. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7635. {
  7636. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7637. dic.Add("AirFeeTotal", airFeeTotalStr);
  7638. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7639. dic.Add("FeeTotal", feeTotalStr);
  7640. }
  7641. foreach (var key in dic.Keys)
  7642. {
  7643. builder.MoveToBookmark(key);
  7644. builder.Write(dic[key]);
  7645. }
  7646. //模板文件名
  7647. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7648. strFileName = CommonFun.ValidFileName(strFileName);
  7649. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7650. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7651. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7652. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7653. }
  7654. }
  7655. else if (dto.ExportType == 2) //表格
  7656. {
  7657. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7658. }
  7659. else if (dto.ExportType == 3)
  7660. {
  7661. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7662. }
  7663. return Ok(JsonView(400, "只可导出明细表!", ""));
  7664. }
  7665. catch (Exception ex)
  7666. {
  7667. return Ok(JsonView(400, ex.Message, ""));
  7668. }
  7669. }
  7670. /// <summary>
  7671. /// 获取三公费用标准city
  7672. /// </summary>
  7673. /// <param name="placeData"></param>
  7674. /// <param name="nationalTravelFeeId"></param>
  7675. /// <returns></returns>
  7676. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7677. {
  7678. string _city = string.Empty;
  7679. if (!placeData.Any()) return _city;
  7680. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7681. if (data == null) return _city;
  7682. string country = data.Country;
  7683. string city = data.City;
  7684. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7685. else _city = city;
  7686. return _city;
  7687. }
  7688. /// <summary>
  7689. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7690. /// </summary>
  7691. /// <returns></returns>
  7692. [HttpPost]
  7693. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7695. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7696. {
  7697. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7698. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7699. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7700. if (_view.Code == 0)
  7701. {
  7702. return Ok(JsonView(true, "操作成功"));
  7703. }
  7704. return Ok(JsonView(false, "操作失败"));
  7705. }
  7706. /// <summary>
  7707. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7708. /// </summary>
  7709. /// <returns></returns>
  7710. [HttpPost]
  7711. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7713. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7714. {
  7715. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7716. if (data.Code != 0)
  7717. {
  7718. return Ok(JsonView(false, data.Msg));
  7719. }
  7720. return Ok(JsonView(true, "操作成功!", data.Data));
  7721. }
  7722. /// <summary>
  7723. /// 三公其他费用草稿 删除
  7724. /// </summary>
  7725. /// <param name="dto"></param>
  7726. /// <returns></returns>
  7727. [HttpPost]
  7728. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7729. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7730. {
  7731. var jw = JsonView(false, "删除失败!");
  7732. var data = new Grp_DayOtherPriceDraft()
  7733. {
  7734. Id = dto.Id,
  7735. IsDel = 1,
  7736. DeleteUserId = dto.DeleteUserId,
  7737. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7738. };
  7739. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7740. if (del > 0)
  7741. {
  7742. jw.Code = 200;
  7743. jw.Msg = "删除成功!";
  7744. }
  7745. return Ok(jw);
  7746. }
  7747. /// <summary>
  7748. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7749. /// </summary>
  7750. /// <returns></returns>
  7751. [HttpPost]
  7752. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7753. {
  7754. var jw = JsonView(false);
  7755. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7756. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7757. jw.Code = StatusCodes.Status200OK;
  7758. jw.Msg = "操作成功!";
  7759. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7760. return Ok(jw);
  7761. }
  7762. /// <summary>
  7763. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7764. /// </summary>
  7765. /// <param name="dto"></param>
  7766. /// <returns></returns>
  7767. [HttpPost]
  7768. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7769. {
  7770. int userId = dto.UserId,
  7771. portId = dto.PortType,
  7772. groupId = dto.GroupId,
  7773. draftId = dto.DraftId;
  7774. _portTypeData.Add(1);
  7775. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7776. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7777. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7778. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7779. _sqlSugar.BeginTran();
  7780. try
  7781. {
  7782. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7783. if (draftDatas == null)
  7784. {
  7785. _sqlSugar.RollbackTran();
  7786. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7787. }
  7788. //验证可覆盖已有数据 两边创建人需为同一人;
  7789. int draftCreateUserId = draftDatas.CreateUserId,
  7790. formalCreateUserId = 0;
  7791. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7792. if (formalData != null)
  7793. {
  7794. formalCreateUserId = formalData.CreateUserId;
  7795. if (draftCreateUserId != formalCreateUserId)
  7796. {
  7797. _sqlSugar.RollbackTran();
  7798. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7799. }
  7800. }
  7801. //默认添加查看、编辑权限(创建人、自己)
  7802. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7803. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7804. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7805. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7806. newExterData.DiId = groupId;
  7807. newExterData.CreateUserId = userId;
  7808. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7809. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7810. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7811. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7812. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7813. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7814. //数据如果存在执行删除
  7815. if (enterExitCostInfo != null)
  7816. {
  7817. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7818. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7819. .Where(x => x.Id == enterExitCostInfo.Id)
  7820. .ExecuteCommand();
  7821. _sqlSugar.Updateable<Grp_DayAndCost>()
  7822. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7823. .Where(x => x.DiId == groupId)
  7824. .ExecuteCommand();
  7825. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7826. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7827. .Where(x => x.Diid == groupId)
  7828. .ExecuteCommand();
  7829. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7830. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7831. .Where(x => x.GroupId == groupId)
  7832. .ExecuteCommand();
  7833. }
  7834. //执行insert
  7835. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7836. if (insertId < 1)
  7837. {
  7838. _sqlSugar.RollbackTran();
  7839. return Ok(JsonView(false, "草稿数据导入失败!"));
  7840. }
  7841. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7842. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7843. #region 默认添加权限
  7844. #endregion
  7845. _sqlSugar.CommitTran();
  7846. //执行操作之后
  7847. //生成默认文件pdf并且通知人员
  7848. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7849. {
  7850. DiId = groupId,
  7851. ExportType = 1,
  7852. SubTypeId = 1005
  7853. }, "pdf");
  7854. //发送通知
  7855. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7856. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7857. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7858. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7859. //汇率信息记录
  7860. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7861. return Ok(JsonView(true));
  7862. }
  7863. catch (Exception ex)
  7864. {
  7865. _sqlSugar.RollbackTran();
  7866. return Ok(JsonView(false, ex.Message));
  7867. }
  7868. }
  7869. #endregion
  7870. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7871. /// <summary>
  7872. /// 获取币种基础数据(含逻辑处理)
  7873. /// </summary>
  7874. /// <returns></returns>
  7875. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7876. {
  7877. return await GeneralMethod.EnterExitCostInitRate();
  7878. }
  7879. /// <summary>
  7880. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7881. /// </summary>
  7882. /// <returns></returns>
  7883. [HttpPost]
  7884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7885. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7886. {
  7887. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7888. //SetDataInfoView
  7889. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7890. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7891. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7892. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7893. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7894. //默认币种显示
  7895. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7896. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7897. return Ok(JsonView(true, "查询成功!", new
  7898. {
  7899. WordTypeData = _WordTypeData,
  7900. ExcelTypeData = _ExcelTypeData,
  7901. CurrencyInit = _currencyInfos,
  7902. viewPermissionData = viewPermissionData
  7903. }));
  7904. }
  7905. /// <summary>
  7906. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7907. /// </summary>
  7908. /// <returns></returns>
  7909. [HttpPost]
  7910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7911. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7912. {
  7913. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7914. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7915. RefAsync<int> total = 0;
  7916. int diId = 0;
  7917. var status = int.TryParse(dto.GroupName, out diId);
  7918. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7919. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7920. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7921. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7922. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7923. .OrderByDescending(x => x.VisitStartDate)
  7924. .Select(x => new EnterExitCostMobileGroupView()
  7925. {
  7926. Id = x.Id,
  7927. GroupName = x.TeamName,
  7928. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  7929. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any() ? false : true,
  7930. })
  7931. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7932. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7933. {
  7934. foreach (var item in data)
  7935. {
  7936. item.IsView = true;
  7937. }
  7938. }
  7939. return Ok(JsonView(true, "查询成功!", data, total));
  7940. }
  7941. /// <summary>
  7942. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7943. /// </summary>
  7944. /// <returns></returns>
  7945. [HttpPost]
  7946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7947. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7948. {
  7949. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7950. RefAsync<int> total = 0;
  7951. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7952. .Where(x => x.IsDel == 0 && x.STid == 66)
  7953. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7954. .Select(x => new
  7955. {
  7956. id = x.Id,
  7957. name = x.Name,
  7958. remark = x.Remark,
  7959. })
  7960. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7961. return Ok(JsonView(true, "查询成功!", data, total));
  7962. }
  7963. /// <summary>
  7964. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7965. /// </summary>
  7966. /// <returns></returns>
  7967. [HttpPost]
  7968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7969. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7970. {
  7971. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7972. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7973. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7974. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7975. var groupOtherRateData = groupRateData.TeamRates;
  7976. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7977. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7978. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7979. groupOtherRateData = groupOtherRateData
  7980. .Select(x => new TeamRateDescAddCurrencyIdView
  7981. {
  7982. CurrencyId = x.CurrencyId,
  7983. CurrencyName = x.CurrencyName,
  7984. CurrencyCode = x.CurrencyCode,
  7985. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7986. }).ToList();
  7987. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7988. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7989. }
  7990. /// <summary>
  7991. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7992. /// </summary>
  7993. /// <returns></returns>
  7994. [HttpPost]
  7995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7996. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7997. {
  7998. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7999. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8000. var tipsData = new List<int>() { 1, 2, 3 };
  8001. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8002. if (dto.TipsType == 1)
  8003. {
  8004. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8005. }
  8006. else if (dto.TipsType == 2)
  8007. {
  8008. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8009. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8010. }
  8011. else if (dto.TipsType == 3)
  8012. {
  8013. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8014. return Ok(JsonView(true, "查询成功!", airData.Data));
  8015. }
  8016. return Ok(JsonView(false));
  8017. }
  8018. /// <summary>
  8019. /// 团组模块 - 出入境国家费用标准-移动端 List
  8020. /// </summary>
  8021. /// <returns></returns>
  8022. [HttpPost]
  8023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8024. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8025. {
  8026. Stopwatch sw = new Stopwatch();
  8027. sw.Start();
  8028. RefAsync<int> total = 0;
  8029. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8030. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8031. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8032. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8033. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8034. .Select((ntf, sd, u) => new
  8035. {
  8036. Id = ntf.Id,
  8037. Area = $"{ntf.Country}-{ntf.City}",
  8038. Currency = ntf.Currency,
  8039. CurrencyCode = sd.Name,
  8040. CurrencyName = sd.Remark,
  8041. RoomCost = ntf.RoomCost,
  8042. FoodCost = ntf.FoodCost,
  8043. PublicCost = ntf.PublicCost,
  8044. LastUpdateUserId = ntf.LastUpdateUserId,
  8045. LastUpdateUserName = u.CnName,
  8046. LastUpdateTime = ntf.LastUpdateTime,
  8047. })
  8048. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8049. sw.Stop();
  8050. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8051. }
  8052. /// <summary>
  8053. /// 团组模块 - 出入境费用-移动端 - Info
  8054. /// </summary>
  8055. /// <returns></returns>
  8056. [HttpPost]
  8057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8058. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8059. {
  8060. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8061. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8062. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8063. return Ok(data);
  8064. }
  8065. /// <summary>
  8066. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8067. /// </summary>
  8068. /// <returns></returns>
  8069. [HttpPost]
  8070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8071. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8072. {
  8073. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8074. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8075. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8076. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8077. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8078. mobileInfo.DiId = dto.DiId;
  8079. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8080. if (eecInfo == null) return Ok(mobileInfo);
  8081. //验证查看权限
  8082. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8083. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8084. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8085. mobileInfo.IsAssignPerm = isSet;
  8086. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8087. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8088. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8089. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8090. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8091. {
  8092. SubId = dac.Id,
  8093. DiId = dac.DiId,
  8094. Type = dac.Type,
  8095. Days = dac.Days,
  8096. NationalTravelFeeId = dac.NationalTravelFeeId,
  8097. Arae = $"{ntf.Country}-{ntf.City}",
  8098. Cost = dac.Cost,
  8099. Currency = dac.Currency,
  8100. CurrencyName = sd.Name,
  8101. SubTotal = dac.SubTotal,
  8102. })
  8103. .ToList();
  8104. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8105. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8106. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8107. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8108. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8109. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8110. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8111. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8112. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8113. //其他款项
  8114. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8115. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8116. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8117. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8118. .OrderBy((dop, sd1, sd2) => dop.Index)
  8119. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8120. {
  8121. SubId = dop.Id,
  8122. DiId = dop.Diid,
  8123. Index = dop.Index,
  8124. SetDataId = dop.SetDataId,
  8125. SetDataName = sd1.Name,
  8126. Cost = dop.Cost,
  8127. Currency = dop.Currency,
  8128. CurrencyName = sd2.Remark,
  8129. SubTotal = dop.SubTotal,
  8130. Remark = dop.Remark,
  8131. })
  8132. .ToArray();
  8133. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8134. return Ok(mobileInfo);
  8135. }
  8136. /// <summary>
  8137. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8138. /// </summary>
  8139. /// <returns></returns>
  8140. [HttpPost]
  8141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8142. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8143. {
  8144. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8145. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8146. //验证查看权限
  8147. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8148. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8149. var userIds = await _sqlSugar
  8150. .Queryable<Grp_EnterExitCostPermission>()
  8151. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8152. .Select(x => x.UserId)
  8153. .ToArrayAsync();
  8154. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8155. var perUsersView = new List<dynamic>();
  8156. foreach (var item in perUsers)
  8157. {
  8158. bool isView1 = false;
  8159. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8160. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8161. }
  8162. return Ok(JsonView(perUsersView));
  8163. }
  8164. /// <summary>
  8165. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8166. /// </summary>
  8167. /// <returns></returns>
  8168. [HttpPost]
  8169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8170. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8171. {
  8172. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8173. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8174. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8175. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8176. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8177. //验证查看权限
  8178. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8179. //if (!isView) return Ok(JsonView(false, msg));
  8180. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8181. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8182. var subType = dto.SubType;
  8183. if (subType == 1) //1:境内费用
  8184. {
  8185. var oneData = new ChoiceOneMobileSubInfoView()
  8186. {
  8187. Id = eecInfo.Id,
  8188. ChoiceOne = eecInfo.ChoiceOne,
  8189. ChoiceOneTotalCost = eecInfo.InsidePay,
  8190. Visa = eecInfo.Visa,
  8191. VisaRemark = eecInfo.VisaRemark,
  8192. YiMiao = eecInfo.YiMiao,
  8193. HeSuan = eecInfo.HeSuan,
  8194. Service = eecInfo.Service,
  8195. Ticket = eecInfo.Ticket,
  8196. Safe = eecInfo.Safe,
  8197. FirstItemRemark = eecInfo.FirstItemRemark
  8198. };
  8199. return Ok(JsonView(oneData));
  8200. }
  8201. else if (subType == 2) //2:国际旅费
  8202. {
  8203. var twoData = new ChoiceTwoMobileSubInfoView()
  8204. {
  8205. Id = eecInfo.Id,
  8206. ChoiceTwoJJ = eecInfo.SumJJC,
  8207. OutsideJJPay = eecInfo.OutsideJJPay,
  8208. ChoiceTwoGW = eecInfo.SumGWC,
  8209. OutsideGWPay = eecInfo.OutsideGWPay,
  8210. ChoiceTwoTD = eecInfo.SumTDC,
  8211. OutsideTDPay = eecInfo.OutsideTDPay,
  8212. AirJJ = eecInfo.AirJJ,
  8213. AirGW = eecInfo.AirGW,
  8214. AirTD = eecInfo.AirTD,
  8215. CityTranffic = eecInfo.CityTranffic,
  8216. TwoItemRemark = eecInfo.TwoItemRemark
  8217. };
  8218. return Ok(JsonView(twoData));
  8219. }
  8220. else if (subType == 3) //3:住宿费
  8221. {
  8222. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8223. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8224. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8225. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8226. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8227. {
  8228. SubId = dac.Id,
  8229. DiId = dac.DiId,
  8230. Type = dac.Type,
  8231. Days = dac.Days,
  8232. NationalTravelFeeId = dac.NationalTravelFeeId,
  8233. Arae = $"{ntf.Country}-{ntf.City}",
  8234. Cost = dac.Cost,
  8235. Currency = dac.Currency,
  8236. CurrencyName = sd.Name,
  8237. SubTotal = dac.SubTotal,
  8238. })
  8239. .ToArray();
  8240. var data = new ChoiceMobileSubInfo3To6View()
  8241. {
  8242. ParentId = eecInfo.Id,
  8243. Choice = eecInfo.ChoiceThree,
  8244. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8245. Details = dayAndCostDatas
  8246. };
  8247. return Ok(JsonView(data));
  8248. }
  8249. else if (subType == 4) //4:伙食费
  8250. {
  8251. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8252. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8253. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8254. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8255. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8256. {
  8257. SubId = dac.Id,
  8258. DiId = dac.DiId,
  8259. Type = dac.Type,
  8260. Days = dac.Days,
  8261. NationalTravelFeeId = dac.NationalTravelFeeId,
  8262. Arae = $"{ntf.Country}-{ntf.City}",
  8263. Cost = dac.Cost,
  8264. Currency = dac.Currency,
  8265. CurrencyName = sd.Name,
  8266. SubTotal = dac.SubTotal,
  8267. })
  8268. .ToArray();
  8269. var data = new ChoiceMobileSubInfo3To6View()
  8270. {
  8271. ParentId = eecInfo.Id,
  8272. Choice = eecInfo.ChoiceFour,
  8273. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8274. Details = dayAndCostDatas
  8275. };
  8276. return Ok(JsonView(data));
  8277. }
  8278. else if (subType == 5) //5:公杂费
  8279. {
  8280. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8281. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8282. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8283. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8284. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8285. {
  8286. SubId = dac.Id,
  8287. DiId = dac.DiId,
  8288. Type = dac.Type,
  8289. Days = dac.Days,
  8290. NationalTravelFeeId = dac.NationalTravelFeeId,
  8291. Arae = $"{ntf.Country}-{ntf.City}",
  8292. Cost = dac.Cost,
  8293. Currency = dac.Currency,
  8294. CurrencyName = sd.Name,
  8295. SubTotal = dac.SubTotal,
  8296. })
  8297. .ToArray();
  8298. var data = new ChoiceMobileSubInfo3To6View()
  8299. {
  8300. ParentId = eecInfo.Id,
  8301. Choice = eecInfo.ChoiceFive,
  8302. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8303. Details = dayAndCostDatas
  8304. };
  8305. return Ok(JsonView(data));
  8306. }
  8307. else if (subType == 6) //6:培训费
  8308. {
  8309. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8310. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8311. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8312. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8313. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8314. {
  8315. SubId = dac.Id,
  8316. DiId = dac.DiId,
  8317. Type = dac.Type,
  8318. Days = dac.Days,
  8319. NationalTravelFeeId = dac.NationalTravelFeeId,
  8320. Arae = $"{ntf.Country}-{ntf.City}",
  8321. Cost = dac.Cost,
  8322. Currency = dac.Currency,
  8323. CurrencyName = sd.Name,
  8324. SubTotal = dac.SubTotal,
  8325. })
  8326. .ToArray();
  8327. var data = new ChoiceMobileSubInfo3To6View()
  8328. {
  8329. ParentId = eecInfo.Id,
  8330. Choice = eecInfo.ChoiceSix,
  8331. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8332. Details = dayAndCostDatas
  8333. };
  8334. return Ok(JsonView(data));
  8335. }
  8336. else if (subType == 7) //7:其他
  8337. {
  8338. //其他款项
  8339. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8340. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8341. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8342. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8343. .OrderBy((dop, sd1, sd2) => dop.Index)
  8344. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8345. {
  8346. SubId = dop.Id,
  8347. DiId = dop.Diid,
  8348. Index = dop.Index,
  8349. SetDataId = dop.SetDataId,
  8350. SetDataName = sd1.Name,
  8351. Cost = dop.Cost,
  8352. Currency = dop.Currency,
  8353. CurrencyName = sd2.Name,
  8354. SubTotal = dop.SubTotal,
  8355. Remark = dop.Remark,
  8356. })
  8357. .ToArray();
  8358. var data = new ChoiceSevenMobileSubInfoView()
  8359. {
  8360. ParentId = eecInfo.Id,
  8361. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8362. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8363. Details = otherData
  8364. };
  8365. return Ok(JsonView(data));
  8366. }
  8367. return Ok(JsonView(false));
  8368. }
  8369. #region op
  8370. /// <summary>
  8371. /// 移动端更新费用消息通知
  8372. /// </summary>
  8373. /// <param name="diid"></param>
  8374. /// <param name="id"></param>
  8375. /// <param name="currUserId"></param>
  8376. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8377. {
  8378. try
  8379. {
  8380. ////生成默认文件pdf并且通知人员
  8381. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8382. //{
  8383. // DiId = diid,
  8384. // ExportType = 1,
  8385. // SubTypeId = 1005
  8386. //}, "pdf");
  8387. ////发送通知
  8388. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8389. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8390. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8391. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8392. ////汇率信息记录
  8393. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8394. }
  8395. catch (Exception ex)
  8396. {
  8397. //记录日志
  8398. throw;
  8399. }
  8400. }
  8401. /// <summary>
  8402. /// 验证出入境费用数据是否存在
  8403. /// 不存在添加
  8404. /// </summary>
  8405. /// <param name="diId"></param>
  8406. /// <param name="currUserId"></param>
  8407. /// <returns></returns>
  8408. /// <exception cref="CustomException"></exception>
  8409. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8410. {
  8411. var parentId = 0;
  8412. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8413. if (info != null)
  8414. {
  8415. parentId = info.Id;
  8416. }
  8417. else
  8418. {
  8419. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8420. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8421. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8422. parentId = addId;
  8423. }
  8424. return parentId;
  8425. }
  8426. /// <summary>
  8427. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8428. /// </summary>
  8429. /// <returns></returns>
  8430. [HttpPost]
  8431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8432. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8433. {
  8434. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8435. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8436. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8437. //验证编辑权限
  8438. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8439. //if (!isEdit) return Ok(JsonView(false, msg));
  8440. var permissions = new List<Grp_EnterExitCostPermission>();
  8441. foreach (var userId in dto.UserIds)
  8442. {
  8443. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8444. }
  8445. if (permissions.Any())
  8446. {
  8447. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8448. {
  8449. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8450. }
  8451. _sqlSugar.BeginTran();
  8452. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8453. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8454. if (result < 1)
  8455. {
  8456. _sqlSugar.RollbackTran();
  8457. return Ok(JsonView(false));
  8458. }
  8459. _sqlSugar.CommitTran();
  8460. return Ok(JsonView(true));
  8461. }
  8462. return Ok(JsonView(false));
  8463. }
  8464. /// <summary>
  8465. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8466. /// </summary>
  8467. /// <returns></returns>
  8468. [HttpPost]
  8469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8470. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8471. {
  8472. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8473. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8474. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8475. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8476. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8477. int id = dto.Id;
  8478. if (id <= 0) //add
  8479. {
  8480. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8481. if (add < 1) return Ok(JsonView(false));
  8482. id = add;
  8483. }
  8484. else //update
  8485. {
  8486. ////验证编辑权限
  8487. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8488. //if (!isEdit) return Ok(JsonView(false, msg));
  8489. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8490. if (upd < 1) return Ok(JsonView(false));
  8491. }
  8492. #region 汇率变更时更改币种相关费用
  8493. var opDayCosts = new List<Grp_DayAndCost>();
  8494. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8495. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8496. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8497. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8498. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8499. .Select((dac, sd) => new
  8500. {
  8501. dac.Id,
  8502. dac.DiId,
  8503. CurrencyCode = sd.Name,
  8504. dac.Cost
  8505. })
  8506. .ToList();
  8507. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8508. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8509. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8510. .Select((dop, sd) => new
  8511. {
  8512. dop.Id,
  8513. dop.Diid,
  8514. CurrencyCode = sd.Name,
  8515. dop.Cost
  8516. })
  8517. .ToList();
  8518. if (dayCosts.Count > 0)
  8519. {
  8520. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8521. foreach (var dc in new_dayCosts)
  8522. {
  8523. var thisCurrency = dc.Key.ToUpper();
  8524. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8525. if (thisRate == 0.00M) continue;
  8526. foreach (var dcSub in dc)
  8527. {
  8528. opDayCosts.Add(new Grp_DayAndCost()
  8529. {
  8530. Id = dcSub.Id,
  8531. DiId = dcSub.DiId,
  8532. Cost = dcSub.Cost,
  8533. SubTotal = dcSub.Cost * thisRate,
  8534. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8535. });
  8536. }
  8537. }
  8538. if (opDayCosts.Count > 0)
  8539. {
  8540. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8541. }
  8542. }
  8543. if (dayOtherCosts.Count > 0)
  8544. {
  8545. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8546. foreach (var dc in new_dayOtherCosts)
  8547. {
  8548. var thisCurrency = dc.Key.ToUpper();
  8549. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8550. if (thisRate == 0.00M) continue;
  8551. foreach (var dcSub in dc)
  8552. {
  8553. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8554. {
  8555. Id = dcSub.Id,
  8556. Diid = dcSub.Diid,
  8557. Cost = dcSub.Cost,
  8558. SubTotal = dcSub.Cost * thisRate,
  8559. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8560. });
  8561. }
  8562. }
  8563. if (opDayOtherCosts.Count > 0)
  8564. {
  8565. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8566. }
  8567. }
  8568. #endregion
  8569. //消息通知
  8570. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8571. //汇率信息记录
  8572. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8573. return Ok(JsonView(new { parentId = id }));
  8574. }
  8575. /// <summary>
  8576. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8577. /// </summary>
  8578. /// <returns></returns>
  8579. [HttpPost]
  8580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8581. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8582. {
  8583. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8584. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8585. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8586. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8587. int id = dto.Id;
  8588. if (id <= 0) //add
  8589. {
  8590. checkboxInfo.CreateUserId = dto.CurrUserId;
  8591. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8592. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8593. if (add < 1) return Ok(JsonView(false));
  8594. }
  8595. else //update
  8596. {
  8597. ////验证编辑权限
  8598. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8599. //if (!isEdit) return Ok(JsonView(false, msg));
  8600. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8601. .UpdateColumns(x => new
  8602. {
  8603. x.ChoiceOne,
  8604. x.ChoiceTwo,
  8605. x.SumJJC,
  8606. x.SumGWC,
  8607. x.SumTDC,
  8608. x.ChoiceThree,
  8609. x.ChoiceFour,
  8610. x.ChoiceFive,
  8611. x.ChoiceSix,
  8612. x.OtherExpenses_Checked
  8613. })
  8614. .Where(x => x.Id == id)
  8615. .ExecuteCommandAsync();
  8616. if (upd < 1) return Ok(JsonView(false));
  8617. }
  8618. return Ok(JsonView(new { parentId = id }));
  8619. }
  8620. /// <summary>
  8621. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8622. /// </summary>
  8623. /// <returns></returns>
  8624. [HttpPost]
  8625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8626. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8627. {
  8628. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8629. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8630. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8631. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8632. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8633. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8634. var checkboxInfo = new Grp_EnterExitCost()
  8635. {
  8636. Id = id,
  8637. DiId = diId,
  8638. CreateUserId = currUserId
  8639. };
  8640. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8641. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8642. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8643. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8644. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8645. if (id <= 0) //add
  8646. {
  8647. checkboxInfo.CreateUserId = dto.CurrUserId;
  8648. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8649. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8650. if (add < 1) return Ok(JsonView(false));
  8651. }
  8652. else //update
  8653. {
  8654. ////验证编辑权限
  8655. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8656. //if (!isEdit) return Ok(JsonView(false, msg));
  8657. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8658. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8659. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8660. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8661. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8662. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8663. .Where(x => x.Id == id)
  8664. .ExecuteCommandAsync();
  8665. if (upd < 1) return Ok(JsonView(false));
  8666. }
  8667. return Ok(JsonView(new { parentId = id }));
  8668. }
  8669. /// <summary>
  8670. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8671. /// </summary>
  8672. /// <returns></returns>
  8673. [HttpPost]
  8674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8675. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8676. {
  8677. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8678. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8679. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8680. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8681. info.FirstItemRemark = dto.FirstItemRemark;
  8682. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8683. int id = dto.Id;
  8684. if (id <= 0) //add
  8685. {
  8686. info.CreateUserId = dto.CurrUserId;
  8687. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8688. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8689. if (add < 1) return Ok(JsonView(false));
  8690. id = add;
  8691. }
  8692. else //update
  8693. {
  8694. ////验证编辑权限
  8695. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8696. //if (!isEdit) return Ok(JsonView(false, msg));
  8697. var upd = await _sqlSugar.Updateable(info)
  8698. .UpdateColumns(x => new
  8699. {
  8700. x.ChoiceOne,
  8701. x.InsidePay,
  8702. x.VisaRemark,
  8703. x.Visa,
  8704. x.Service,
  8705. x.Safe,
  8706. x.Ticket,
  8707. x.HeSuan,
  8708. x.YiMiao,
  8709. x.FirstItemRemark
  8710. })
  8711. .Where(x => x.Id == id)
  8712. .ExecuteCommandAsync();
  8713. if (upd < 1) return Ok(JsonView(false));
  8714. }
  8715. //消息通知
  8716. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8717. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8718. }
  8719. /// <summary>
  8720. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8721. /// </summary>
  8722. /// <returns></returns>
  8723. [HttpPost]
  8724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8725. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8726. {
  8727. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8728. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8729. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8730. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8731. info.OutsideJJPay = dto.OutsideJJPay;
  8732. info.OutsideGWPay = dto.OutsideGWPay;
  8733. info.OutsideTDPay = dto.OutsideTDPay;
  8734. info.AirJJ = dto.AirJJ;
  8735. info.AirGW = dto.AirGW;
  8736. info.AirTD = dto.AirTD;
  8737. info.CityTranffic = dto.CityTranffic;
  8738. info.TwoItemRemark = dto.TwoItemRemark;
  8739. info.SumJJC = dto.ChoiceTwoJJ;
  8740. info.SumGWC = dto.ChoiceTwoGW;
  8741. info.SumTDC = dto.ChoiceTwoTD;
  8742. int id = dto.Id;
  8743. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8744. if (id <= 0) //add
  8745. {
  8746. info.CreateUserId = dto.CurrUserId;
  8747. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8748. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8749. if (addId <= 0) return Ok(JsonView(false));
  8750. id = addId;
  8751. }
  8752. else //update
  8753. {
  8754. ////验证编辑权限
  8755. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8756. //if (!isEdit) return Ok(JsonView(false, msg));
  8757. var upd = await _sqlSugar.Updateable(info)
  8758. .UpdateColumns(x => new
  8759. {
  8760. x.SumJJC,
  8761. x.OutsideJJPay,
  8762. x.SumGWC,
  8763. x.OutsideGWPay,
  8764. x.SumTDC,
  8765. x.OutsideTDPay,
  8766. x.AirJJ,
  8767. x.AirGW,
  8768. x.AirTD,
  8769. x.CityTranffic,
  8770. x.TwoItemRemark
  8771. })
  8772. .Where(x => x.Id == id)
  8773. .ExecuteCommandAsync();
  8774. if (upd < 1) return Ok(JsonView(false));
  8775. }
  8776. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8777. gwcItemTotal = info.AirGW + info.CityTranffic;
  8778. tdcItemTotal = info.AirTD + info.CityTranffic;
  8779. //消息通知
  8780. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8781. return Ok(JsonView(new
  8782. {
  8783. parentId = id,
  8784. choiceTwoJJ = dto.ChoiceTwoJJ,
  8785. jjcItemTotal = jjcItemTotal,
  8786. choiceTwoGW = dto.ChoiceTwoGW,
  8787. gwcItemTotal = gwcItemTotal,
  8788. choiceTwoTD = dto.ChoiceTwoTD,
  8789. tdcItemTotal = tdcItemTotal
  8790. }));
  8791. }
  8792. /// <summary>
  8793. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8794. /// </summary>
  8795. /// <returns></returns>
  8796. [HttpPost]
  8797. [ApiExplorerSettings(IgnoreApi = true)]
  8798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8799. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8800. {
  8801. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8802. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8803. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8804. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8805. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8806. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8807. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8808. var infos = infos1.Select(x => new Grp_DayAndCost
  8809. {
  8810. Id = x.Id,
  8811. DiId = dto.DiId,
  8812. Type = dto.FeeType,
  8813. Days = x.Days,
  8814. NationalTravelFeeId = x.NationalTravelFeeId,
  8815. Cost = x.Cost,
  8816. Currency = x.Currency,
  8817. SubTotal = x.SubTotal,
  8818. CreateUserId = dto.CurrUserId
  8819. })
  8820. .ToList();
  8821. var adds = infos.Where(x => x.Id <= 0).ToList();
  8822. var upds = infos.Where(x => x.Id > 0).ToList();
  8823. if (adds.Count > 0)
  8824. {
  8825. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8826. if (add < 1) return Ok(JsonView(false));
  8827. }
  8828. if (upds.Count > 0)
  8829. {
  8830. var upd = await _sqlSugar.Updateable(adds)
  8831. .UpdateColumns(x => new
  8832. {
  8833. x.Days,
  8834. x.NationalTravelFeeId,
  8835. x.Cost,
  8836. x.Currency,
  8837. x.SubTotal
  8838. })
  8839. .WhereColumns(x => new { x.Id })
  8840. .ExecuteCommandAsync();
  8841. if (upd < 1) return Ok(JsonView(false));
  8842. }
  8843. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8844. //消息通知
  8845. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8846. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8847. return Ok(JsonView(new { itemTotal = itemTotal }));
  8848. }
  8849. /// <summary>
  8850. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8851. /// </summary>
  8852. /// <returns></returns>
  8853. [HttpPost]
  8854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8855. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8856. {
  8857. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8858. int subId = dto.SubId, feeType = dto.FeeType;
  8859. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8860. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8861. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8862. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8863. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8864. subInfo.Id = subId;
  8865. subInfo.DiId = dto.DiId;
  8866. if (feeType == 3) subInfo.Type = 1;
  8867. else if (feeType == 4) subInfo.Type = 2;
  8868. else if (feeType == 5) subInfo.Type = 3;
  8869. else if (feeType == 6) subInfo.Type = 4;
  8870. subInfo.CreateUserId = dto.CurrUserId;
  8871. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8872. if (parentId < 1) return Ok(JsonView(false));
  8873. //子表op
  8874. if (subId < 1)
  8875. {
  8876. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8877. if (subAdd < 1) return Ok(JsonView(false));
  8878. }
  8879. else
  8880. {
  8881. ////验证编辑权限
  8882. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8883. //if (!isEdit) return Ok(JsonView(false, msg));
  8884. var subUpd = await _sqlSugar.Updateable(subInfo)
  8885. .UpdateColumns(x => new
  8886. {
  8887. x.Days,
  8888. x.NationalTravelFeeId,
  8889. x.Cost,
  8890. x.Currency,
  8891. x.SubTotal
  8892. })
  8893. .WhereColumns(x => new { x.Id })
  8894. .ExecuteCommandAsync();
  8895. if (subUpd < 1) return Ok(JsonView(false));
  8896. }
  8897. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8898. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8899. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8900. }
  8901. /// <summary>
  8902. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8903. /// </summary>
  8904. /// <returns></returns>
  8905. [HttpPost]
  8906. [ApiExplorerSettings(IgnoreApi = true)]
  8907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8908. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8909. {
  8910. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8911. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8912. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8913. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8914. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8915. {
  8916. Id = x.Id,
  8917. Diid = dto.DiId,
  8918. SetDataId = x.SetDataId,
  8919. Index = x.Index,
  8920. Cost = x.Cost,
  8921. Currency = x.Currency,
  8922. SubTotal = x.SubTotal,
  8923. CreateUserId = dto.CurrUserId,
  8924. Remark = x.Remark
  8925. }).ToList();
  8926. var adds = infos.Where(x => x.Id <= 0).ToList();
  8927. var upds = infos.Where(x => x.Id > 0).ToList();
  8928. if (adds.Count > 0)
  8929. {
  8930. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8931. if (add < 1) return Ok(JsonView(false));
  8932. }
  8933. if (upds.Count > 0)
  8934. {
  8935. var upd = await _sqlSugar.Updateable(adds)
  8936. .UpdateColumns(x => new
  8937. {
  8938. x.Index,
  8939. x.SetDataId,
  8940. x.Cost,
  8941. x.Currency,
  8942. x.SubTotal,
  8943. x.Remark
  8944. })
  8945. .WhereColumns(x => new { x.Id })
  8946. .ExecuteCommandAsync();
  8947. if (upd < 1) return Ok(JsonView(false));
  8948. }
  8949. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8950. //消息通知
  8951. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8952. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8953. return Ok(JsonView(new { itemTotal = itemTotal }));
  8954. }
  8955. /// <summary>
  8956. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8957. /// </summary>
  8958. /// <returns></returns>
  8959. [HttpPost]
  8960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8961. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8962. {
  8963. int subId = dto.SubId;
  8964. int diId = dto.Diid;
  8965. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8966. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8967. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8968. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8969. subInfo.Id = subId;
  8970. subInfo.Diid = dto.Diid;
  8971. subInfo.CreateUserId = dto.CurrUserId;
  8972. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8973. if (parentId < 1) return Ok(JsonView(false));
  8974. #region 子表op
  8975. if (subId < 1)//add
  8976. {
  8977. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8978. if (subAdd < 1) return Ok(JsonView(false));
  8979. }
  8980. else //upd
  8981. {
  8982. ////验证编辑权限
  8983. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8984. //if (!isEdit) return Ok(JsonView(false, msg));
  8985. var subUpd = await _sqlSugar.Updateable(subInfo)
  8986. .UpdateColumns(x => new
  8987. {
  8988. x.Index,
  8989. x.SetDataId,
  8990. x.Cost,
  8991. x.Currency,
  8992. x.SubTotal,
  8993. x.Remark
  8994. })
  8995. .WhereColumns(x => new { x.Id })
  8996. .ExecuteCommandAsync();
  8997. if (subUpd < 1) return Ok(JsonView(false));
  8998. }
  8999. #endregion
  9000. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9001. //消息通知
  9002. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9003. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9004. }
  9005. /// <summary>
  9006. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9007. /// </summary>
  9008. /// <returns></returns>
  9009. [HttpPost]
  9010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9011. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9012. {
  9013. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9014. if (data.Code != 0)
  9015. {
  9016. return Ok(JsonView(false, data.Msg));
  9017. }
  9018. return Ok(JsonView(true, "操作成功!", data.Data));
  9019. }
  9020. /// <summary>
  9021. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9022. /// </summary>
  9023. /// <param name="dto"></param>
  9024. /// <returns></returns>
  9025. [HttpPost]
  9026. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9027. {
  9028. var data = new Grp_DayOtherPrice()
  9029. {
  9030. Id = dto.Id,
  9031. IsDel = 1,
  9032. DeleteUserId = dto.DeleteUserId,
  9033. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9034. };
  9035. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9036. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9037. return Ok(JsonView(false, "删除失败!"));
  9038. }
  9039. #endregion
  9040. #endregion
  9041. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9042. /// <summary>
  9043. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9044. /// </summary>
  9045. /// <returns></returns>
  9046. [HttpPost]
  9047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9048. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9049. {
  9050. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9051. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9052. RefAsync<int> total = 0;
  9053. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9054. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9055. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9056. .Select(x => new
  9057. {
  9058. Id = x.Id,
  9059. DraftName = x.DraftName,
  9060. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9061. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9062. .Any()
  9063. })
  9064. .OrderByDescending(x => x.Id)
  9065. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9066. return Ok(JsonView(true, "查询成功!", data, total));
  9067. }
  9068. /// <summary>
  9069. /// 出入境费用-草稿 移动端
  9070. /// 获取币种基础数据(含逻辑处理)
  9071. /// </summary>
  9072. /// <returns></returns>
  9073. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9074. {
  9075. return await GeneralMethod.EnterExitCostInitRate();
  9076. }
  9077. /// <summary>
  9078. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9079. /// </summary>
  9080. /// <returns></returns>
  9081. [HttpPost]
  9082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9083. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9084. {
  9085. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9086. //SetDataInfoView
  9087. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9088. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9089. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9090. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9091. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9092. //默认币种显示
  9093. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9094. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9095. return Ok(JsonView(true, "查询成功!", new
  9096. {
  9097. WordTypeData = _WordTypeData,
  9098. ExcelTypeData = _ExcelTypeData,
  9099. CurrencyInit = _currencyInfos,
  9100. viewPermissionData = viewPermissionData
  9101. }));
  9102. }
  9103. /// <summary>
  9104. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9105. /// </summary>
  9106. /// <returns></returns>
  9107. [HttpPost]
  9108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9109. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9110. {
  9111. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9112. RefAsync<int> total = 0;
  9113. int diId = 0;
  9114. var status = int.TryParse(dto.GroupName, out diId);
  9115. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9116. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9117. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9118. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9119. .OrderByDescending(x => x.VisitStartDate)
  9120. .Select(x => new
  9121. {
  9122. Id = x.Id,
  9123. GroupName = x.TeamName
  9124. })
  9125. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9126. return Ok(JsonView(true, "查询成功!", data, total));
  9127. }
  9128. /// <summary>
  9129. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9130. /// </summary>
  9131. /// <returns></returns>
  9132. [HttpPost]
  9133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9134. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9135. {
  9136. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9137. RefAsync<int> total = 0;
  9138. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9139. .Where(x => x.IsDel == 0 && x.STid == 66)
  9140. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9141. .Select(x => new
  9142. {
  9143. id = x.Id,
  9144. name = x.Name,
  9145. remark = x.Remark,
  9146. })
  9147. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9148. return Ok(JsonView(true, "查询成功!", data, total));
  9149. }
  9150. /// <summary>
  9151. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9152. /// </summary>
  9153. /// <returns></returns>
  9154. [HttpPost]
  9155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9156. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9157. {
  9158. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9159. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9160. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9161. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9162. var groupOtherRateData = groupRateData.TeamRates;
  9163. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9164. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9165. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9166. groupOtherRateData = groupOtherRateData
  9167. .Select(x => new TeamRateDescAddCurrencyIdView
  9168. {
  9169. CurrencyId = x.CurrencyId,
  9170. CurrencyName = x.CurrencyName,
  9171. CurrencyCode = x.CurrencyCode,
  9172. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9173. }).ToList();
  9174. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9175. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9176. }
  9177. /// <summary>
  9178. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9179. /// </summary>
  9180. /// <returns></returns>
  9181. [HttpPost]
  9182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9183. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9184. {
  9185. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9186. var tipsData = new List<int>() { 1, 2, 3 };
  9187. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9188. if (dto.TipsType == 1)
  9189. {
  9190. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9191. }
  9192. else if (dto.TipsType == 2)
  9193. {
  9194. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9195. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9196. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9197. .Select(x => x.NationalTravelFeeId)
  9198. .Distinct()
  9199. .ToListAsync();
  9200. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9201. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9202. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9203. .Select(x => x.Country)
  9204. .Distinct()
  9205. .ToArrayAsync();
  9206. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9207. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9208. return Ok(JsonView(true, "查询成功!", new
  9209. {
  9210. totalAmt = totalAmt,
  9211. remark = remark
  9212. }));
  9213. }
  9214. else if (dto.TipsType == 3)
  9215. {
  9216. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9217. }
  9218. return Ok(JsonView(false));
  9219. }
  9220. /// <summary>
  9221. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9222. /// </summary>
  9223. /// <returns></returns>
  9224. [HttpPost]
  9225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9226. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9227. {
  9228. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9229. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9230. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9231. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9232. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9233. var info = new Grp_EnterExitCostDraft() {
  9234. DraftName = dto.DraftName,
  9235. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9236. CreateUserId = dto.CurrUserId
  9237. };
  9238. _sqlSugar.BeginTran();
  9239. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9240. if (draftId < 1) {
  9241. _sqlSugar.RollbackTran();
  9242. return Ok(JsonView(false, "草稿创建失败!"));
  9243. }
  9244. //添加默认权限
  9245. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9246. _sqlSugar.CommitTran();
  9247. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9248. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9249. mobileInfo.Id = draftId;
  9250. mobileInfo.DraftName = dto.DraftName;
  9251. mobileInfo.Currencys = rateInfos;
  9252. mobileInfo.IsAssignPerm = assignPerm;
  9253. return Ok(JsonView(mobileInfo));
  9254. }
  9255. /// <summary>
  9256. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9257. /// </summary>
  9258. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9259. /// <summary>
  9260. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9261. /// </summary>
  9262. /// <returns></returns>
  9263. [HttpPost]
  9264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9265. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9266. {
  9267. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9268. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9269. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9270. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9271. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9272. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9273. //验证查看编辑权限
  9274. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9275. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9276. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9277. mobileInfo.IsAssignPerm = assignPerm;
  9278. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9279. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9280. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9281. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9282. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9283. {
  9284. ParentId = dac.ParentId,
  9285. SubId = dac.Id,
  9286. Type = dac.Type,
  9287. Days = dac.Days,
  9288. NationalTravelFeeId = dac.NationalTravelFeeId,
  9289. Arae = $"{ntf.Country}-{ntf.City}",
  9290. Cost = dac.Cost,
  9291. Currency = dac.Currency,
  9292. CurrencyName = sd.Name,
  9293. SubTotal = dac.SubTotal,
  9294. })
  9295. .ToList();
  9296. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9297. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9298. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9299. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9300. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9301. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9302. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9303. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9304. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9305. //其他款项
  9306. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9307. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9308. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9309. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9310. .OrderBy((dop, sd1, sd2) => dop.Index)
  9311. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9312. {
  9313. ParentId = dop.ParentId,
  9314. SubId = dop.Id,
  9315. Index = dop.Index,
  9316. SetDataId = dop.SetDataId,
  9317. SetDataName = sd1.Name,
  9318. Cost = dop.Cost,
  9319. Currency = dop.Currency,
  9320. CurrencyName = sd2.Remark,
  9321. SubTotal = dop.SubTotal,
  9322. Remark = dop.Remark,
  9323. })
  9324. .ToArray();
  9325. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9326. return Ok(mobileInfo);
  9327. }
  9328. /// <summary>
  9329. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9330. /// </summary>
  9331. /// <returns></returns>
  9332. [HttpPost]
  9333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9334. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9335. {
  9336. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9337. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9338. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9339. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9340. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9341. //验证查看编辑权限
  9342. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9343. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9344. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9345. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9346. var subType = dto.SubType;
  9347. if (subType == 1) //1:境内费用
  9348. {
  9349. var oneData = new ChoiceOneMobileSubInfoView()
  9350. {
  9351. Id = eecInfo.Id,
  9352. ChoiceOne = eecInfo.ChoiceOne,
  9353. ChoiceOneTotalCost = eecInfo.InsidePay,
  9354. Visa = eecInfo.Visa,
  9355. VisaRemark = eecInfo.VisaRemark,
  9356. YiMiao = eecInfo.YiMiao,
  9357. HeSuan = eecInfo.HeSuan,
  9358. Service = eecInfo.Service,
  9359. Ticket = eecInfo.Ticket,
  9360. Safe = eecInfo.Safe,
  9361. FirstItemRemark = eecInfo.FirstItemRemark
  9362. };
  9363. return Ok(JsonView(oneData));
  9364. }
  9365. else if (subType == 2) //2:国际旅费
  9366. {
  9367. var twoData = new ChoiceTwoMobileSubInfoView()
  9368. {
  9369. Id = eecInfo.Id,
  9370. ChoiceTwoJJ = eecInfo.SumJJC,
  9371. OutsideJJPay = eecInfo.OutsideJJPay,
  9372. ChoiceTwoGW = eecInfo.SumGWC,
  9373. OutsideGWPay = eecInfo.OutsideGWPay,
  9374. ChoiceTwoTD = eecInfo.SumTDC,
  9375. OutsideTDPay = eecInfo.OutsideTDPay,
  9376. AirJJ = eecInfo.AirJJ,
  9377. AirGW = eecInfo.AirGW,
  9378. AirTD = eecInfo.AirTD,
  9379. CityTranffic = eecInfo.CityTranffic,
  9380. TwoItemRemark = eecInfo.TwoItemRemark
  9381. };
  9382. return Ok(JsonView(twoData));
  9383. }
  9384. else if (subType == 3) //3:住宿费
  9385. {
  9386. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9387. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9388. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9389. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9390. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9391. {
  9392. ParentId = dac.ParentId,
  9393. SubId = dac.Id,
  9394. Type = dac.Type,
  9395. Days = dac.Days,
  9396. NationalTravelFeeId = dac.NationalTravelFeeId,
  9397. Arae = $"{ntf.Country}-{ntf.City}",
  9398. Cost = dac.Cost,
  9399. Currency = dac.Currency,
  9400. CurrencyName = sd.Name,
  9401. SubTotal = dac.SubTotal,
  9402. })
  9403. .ToArray();
  9404. var data = new ChoiceDraftMobileSubInfo3To6View()
  9405. {
  9406. ParentId = eecInfo.Id,
  9407. Choice = eecInfo.ChoiceThree,
  9408. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9409. Details = dayAndCostDatas
  9410. };
  9411. return Ok(JsonView(data));
  9412. }
  9413. else if (subType == 4) //4:伙食费
  9414. {
  9415. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9416. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9417. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9418. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9419. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9420. {
  9421. ParentId = dac.ParentId,
  9422. SubId = dac.Id,
  9423. Type = dac.Type,
  9424. Days = dac.Days,
  9425. NationalTravelFeeId = dac.NationalTravelFeeId,
  9426. Arae = $"{ntf.Country}-{ntf.City}",
  9427. Cost = dac.Cost,
  9428. Currency = dac.Currency,
  9429. CurrencyName = sd.Name,
  9430. SubTotal = dac.SubTotal,
  9431. })
  9432. .ToArray();
  9433. var data = new ChoiceDraftMobileSubInfo3To6View()
  9434. {
  9435. ParentId = eecInfo.Id,
  9436. Choice = eecInfo.ChoiceFour,
  9437. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9438. Details = dayAndCostDatas
  9439. };
  9440. return Ok(JsonView(data));
  9441. }
  9442. else if (subType == 5) //5:公杂费
  9443. {
  9444. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9445. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9446. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9447. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9448. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9449. {
  9450. ParentId = dac.ParentId,
  9451. SubId = dac.Id,
  9452. Type = dac.Type,
  9453. Days = dac.Days,
  9454. NationalTravelFeeId = dac.NationalTravelFeeId,
  9455. Arae = $"{ntf.Country}-{ntf.City}",
  9456. Cost = dac.Cost,
  9457. Currency = dac.Currency,
  9458. CurrencyName = sd.Name,
  9459. SubTotal = dac.SubTotal,
  9460. })
  9461. .ToArray();
  9462. var data = new ChoiceDraftMobileSubInfo3To6View()
  9463. {
  9464. ParentId = eecInfo.Id,
  9465. Choice = eecInfo.ChoiceFive,
  9466. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9467. Details = dayAndCostDatas
  9468. };
  9469. return Ok(JsonView(data));
  9470. }
  9471. else if (subType == 6) //6:培训费
  9472. {
  9473. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9474. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9475. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9476. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9477. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9478. {
  9479. ParentId = dac.ParentId,
  9480. SubId = dac.Id,
  9481. Type = dac.Type,
  9482. Days = dac.Days,
  9483. NationalTravelFeeId = dac.NationalTravelFeeId,
  9484. Arae = $"{ntf.Country}-{ntf.City}",
  9485. Cost = dac.Cost,
  9486. Currency = dac.Currency,
  9487. CurrencyName = sd.Name,
  9488. SubTotal = dac.SubTotal,
  9489. })
  9490. .ToArray();
  9491. var data = new ChoiceDraftMobileSubInfo3To6View()
  9492. {
  9493. ParentId = eecInfo.Id,
  9494. Choice = eecInfo.ChoiceSix,
  9495. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9496. Details = dayAndCostDatas
  9497. };
  9498. return Ok(JsonView(data));
  9499. }
  9500. else if (subType == 7) //7:其他
  9501. {
  9502. //其他款项
  9503. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9504. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9505. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9506. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9507. .OrderBy((dop, sd1, sd2) => dop.Index)
  9508. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9509. {
  9510. ParentId = dop.ParentId,
  9511. SubId = dop.Id,
  9512. Index = dop.Index,
  9513. SetDataId = dop.SetDataId,
  9514. SetDataName = sd1.Name,
  9515. Cost = dop.Cost,
  9516. Currency = dop.Currency,
  9517. CurrencyName = sd2.Name,
  9518. SubTotal = dop.SubTotal,
  9519. Remark = dop.Remark,
  9520. })
  9521. .ToArray();
  9522. var data = new ChoiceSevenDraftMobileSubInfoView()
  9523. {
  9524. ParentId = eecInfo.Id,
  9525. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9526. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9527. Details = otherData
  9528. };
  9529. return Ok(JsonView(data));
  9530. }
  9531. return Ok(JsonView(false));
  9532. }
  9533. #region op
  9534. /// <summary>
  9535. /// 移动端更新费用消息通知
  9536. /// </summary>
  9537. /// <param name="draftId"></param>
  9538. /// <param name="id"></param>
  9539. /// <param name="currUserId"></param>
  9540. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9541. {
  9542. try
  9543. {
  9544. ////生成默认文件pdf并且通知人员
  9545. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9546. //{
  9547. // DiId = draftId,
  9548. // ExportType = 1,
  9549. // SubTypeId = 1005
  9550. //}, "pdf");
  9551. ////发送通知
  9552. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9553. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9554. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9555. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9556. ////汇率信息记录
  9557. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9558. }
  9559. catch (Exception ex)
  9560. {
  9561. //记录日志
  9562. throw;
  9563. }
  9564. }
  9565. /// <summary>
  9566. /// 验证出入境费用数据是否存在
  9567. /// 不存在添加
  9568. /// </summary>
  9569. /// <param name="draftId"></param>
  9570. /// <param name="currUserId"></param>
  9571. /// <returns></returns>
  9572. /// <exception cref="CustomException"></exception>
  9573. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9574. {
  9575. var parentId = 0;
  9576. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9577. if (info != null) parentId = info.Id;
  9578. else
  9579. {
  9580. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9581. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9582. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9583. parentId = addId;
  9584. }
  9585. return parentId;
  9586. }
  9587. /// <summary>
  9588. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9589. /// </summary>
  9590. /// <returns></returns>
  9591. [HttpPost]
  9592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9593. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9594. {
  9595. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9596. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9597. //验证查看权限
  9598. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9599. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9600. var userIds = await _sqlSugar
  9601. .Queryable<Grp_EnterExitCostDraftPermission>()
  9602. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9603. .Select(x => x.UserId)
  9604. .ToArrayAsync();
  9605. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9606. var perUsersView = new List<dynamic>();
  9607. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9608. var viewPermissionData = new List<PermissionViewUserview>();
  9609. if (feeBasePerm.Any())
  9610. {
  9611. foreach (var item in feeBasePerm)
  9612. {
  9613. if (item.Users.Any())
  9614. {
  9615. viewPermissionData.AddRange(item.Users);
  9616. }
  9617. }
  9618. }
  9619. foreach (var item in perUsers)
  9620. {
  9621. bool isView1 = false;
  9622. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9623. else if (viewPermissionData.Any(x => x.Id ==dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9624. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9625. }
  9626. return Ok(JsonView(perUsersView));
  9627. }
  9628. /// <summary>
  9629. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9630. /// </summary>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9634. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9635. {
  9636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9637. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9638. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9639. //验证查看编辑权限
  9640. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9641. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9642. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9643. foreach (var userId in dto.UserIds)
  9644. {
  9645. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9646. }
  9647. if (permissions.Any())
  9648. {
  9649. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9650. {
  9651. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9652. }
  9653. _sqlSugar.BeginTran();
  9654. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9655. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9656. if (result < 1)
  9657. {
  9658. _sqlSugar.RollbackTran();
  9659. return Ok(JsonView(false));
  9660. }
  9661. _sqlSugar.CommitTran();
  9662. return Ok(JsonView(true));
  9663. }
  9664. return Ok(JsonView(false));
  9665. }
  9666. /// <summary>
  9667. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9668. /// </summary>
  9669. /// <returns></returns>
  9670. [HttpPost]
  9671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9672. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9673. {
  9674. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9675. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9676. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9677. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9678. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9679. int id = dto.DraftId;
  9680. if (id <= 0) //add
  9681. {
  9682. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9683. if (add < 1) return Ok(JsonView(false));
  9684. id = add;
  9685. }
  9686. else //update
  9687. {
  9688. //验证查看编辑权限
  9689. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9690. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9691. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9692. if (upd < 1) return Ok(JsonView(false));
  9693. }
  9694. #region 汇率变更时更改币种相关费用
  9695. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9696. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9697. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9698. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9699. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9700. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9701. .Select((dac, sd) => new
  9702. {
  9703. dac.Id,
  9704. dac.ParentId,
  9705. CurrencyCode = sd.Name,
  9706. dac.Cost
  9707. })
  9708. .ToList();
  9709. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9710. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9711. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9712. .Select((dop, sd) => new
  9713. {
  9714. dop.Id,
  9715. dop.ParentId,
  9716. CurrencyCode = sd.Name,
  9717. dop.Cost
  9718. })
  9719. .ToList();
  9720. if (dayCosts.Count > 0)
  9721. {
  9722. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9723. foreach (var dc in new_dayCosts)
  9724. {
  9725. var thisCurrency = dc.Key.ToUpper();
  9726. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9727. if (thisRate == 0.00M) continue;
  9728. foreach (var dcSub in dc)
  9729. {
  9730. opDayCosts.Add(new Grp_DayAndCostDraft()
  9731. {
  9732. Id = dcSub.Id,
  9733. ParentId = dcSub.ParentId,
  9734. Cost = dcSub.Cost,
  9735. SubTotal = dcSub.Cost * thisRate,
  9736. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9737. });
  9738. }
  9739. }
  9740. if (opDayCosts.Count > 0)
  9741. {
  9742. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9743. }
  9744. }
  9745. if (dayOtherCosts.Count > 0)
  9746. {
  9747. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9748. foreach (var dc in new_dayOtherCosts)
  9749. {
  9750. var thisCurrency = dc.Key.ToUpper();
  9751. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9752. if (thisRate == 0.00M) continue;
  9753. foreach (var dcSub in dc)
  9754. {
  9755. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9756. {
  9757. Id = dcSub.Id,
  9758. ParentId = dcSub.ParentId,
  9759. Cost = dcSub.Cost,
  9760. SubTotal = dcSub.Cost * thisRate,
  9761. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9762. });
  9763. }
  9764. }
  9765. if (opDayOtherCosts.Count > 0)
  9766. {
  9767. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9768. }
  9769. }
  9770. #endregion
  9771. ////消息通知
  9772. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9773. ////汇率信息记录
  9774. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9775. return Ok(JsonView(new { parentId = id }));
  9776. }
  9777. /// <summary>
  9778. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9779. /// </summary>
  9780. /// <returns></returns>
  9781. [HttpPost]
  9782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9783. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9784. {
  9785. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9786. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9787. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9788. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9789. int id = dto.DraftId;
  9790. if (id <= 0) //add
  9791. {
  9792. checkboxInfo.CreateUserId = dto.CurrUserId;
  9793. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9794. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9795. if (add < 1) return Ok(JsonView(false));
  9796. }
  9797. else //update
  9798. {
  9799. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9800. .UpdateColumns(x => new
  9801. {
  9802. x.ChoiceOne,
  9803. x.ChoiceTwo,
  9804. x.SumJJC,
  9805. x.SumGWC,
  9806. x.SumTDC,
  9807. x.ChoiceThree,
  9808. x.ChoiceFour,
  9809. x.ChoiceFive,
  9810. x.ChoiceSix,
  9811. x.OtherExpenses_Checked
  9812. })
  9813. .Where(x => x.Id == id)
  9814. .ExecuteCommandAsync();
  9815. if (upd < 1) return Ok(JsonView(false));
  9816. }
  9817. return Ok(JsonView(new { parentId = id }));
  9818. }
  9819. /// <summary>
  9820. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9821. /// </summary>
  9822. /// <returns></returns>
  9823. [HttpPost]
  9824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9825. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9826. {
  9827. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9828. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9829. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9830. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9831. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9832. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9833. var checkboxInfo = new Grp_EnterExitCostDraft()
  9834. {
  9835. Id = draftId,
  9836. CreateUserId = currUserId
  9837. };
  9838. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9839. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9840. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9841. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9842. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9843. if (draftId <= 0) //add
  9844. {
  9845. checkboxInfo.CreateUserId = dto.CurrUserId;
  9846. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9847. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9848. if (add < 1) return Ok(JsonView(false));
  9849. }
  9850. else //update
  9851. {
  9852. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9853. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9854. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9855. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9856. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9857. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9858. .Where(x => x.Id == draftId)
  9859. .ExecuteCommandAsync();
  9860. if (upd < 1) return Ok(JsonView(false));
  9861. }
  9862. return Ok(JsonView(new { parentId = draftId }));
  9863. }
  9864. /// <summary>
  9865. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9866. /// </summary>
  9867. /// <returns></returns>
  9868. [HttpPost]
  9869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9870. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9871. {
  9872. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9873. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9874. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9875. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9876. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9877. info.FirstItemRemark = dto.FirstItemRemark;
  9878. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9879. if (id <= 0) //add
  9880. {
  9881. info.CreateUserId = dto.CurrUserId;
  9882. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9883. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9884. if (add < 1) return Ok(JsonView(false));
  9885. id = add;
  9886. }
  9887. else //update
  9888. {
  9889. var upd = await _sqlSugar.Updateable(info)
  9890. .UpdateColumns(x => new
  9891. {
  9892. x.ChoiceOne,
  9893. x.InsidePay,
  9894. x.VisaRemark,
  9895. x.Visa,
  9896. x.Service,
  9897. x.Safe,
  9898. x.Ticket,
  9899. x.HeSuan,
  9900. x.YiMiao,
  9901. x.FirstItemRemark
  9902. })
  9903. .Where(x => x.Id == id)
  9904. .ExecuteCommandAsync();
  9905. if (upd < 1) return Ok(JsonView(false));
  9906. }
  9907. ////消息通知
  9908. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9909. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9910. }
  9911. /// <summary>
  9912. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9913. /// </summary>
  9914. /// <returns></returns>
  9915. [HttpPost]
  9916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9917. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9918. {
  9919. int id = dto.DraftId;
  9920. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9921. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9922. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9923. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9924. info.OutsideJJPay = dto.OutsideJJPay;
  9925. info.OutsideGWPay = dto.OutsideGWPay;
  9926. info.OutsideTDPay = dto.OutsideTDPay;
  9927. info.AirJJ = dto.AirJJ;
  9928. info.AirGW = dto.AirGW;
  9929. info.AirTD = dto.AirTD;
  9930. info.CityTranffic = dto.CityTranffic;
  9931. info.TwoItemRemark = dto.TwoItemRemark;
  9932. info.SumJJC = dto.ChoiceTwoJJ;
  9933. info.SumGWC = dto.ChoiceTwoGW;
  9934. info.SumTDC = dto.ChoiceTwoTD;
  9935. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9936. if (id <= 0) //add
  9937. {
  9938. info.CreateUserId = dto.CurrUserId;
  9939. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9940. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9941. if (addId <= 0) return Ok(JsonView(false));
  9942. id = addId;
  9943. }
  9944. else //update
  9945. {
  9946. var upd = await _sqlSugar.Updateable(info)
  9947. .UpdateColumns(x => new
  9948. {
  9949. x.SumJJC,
  9950. x.OutsideJJPay,
  9951. x.SumGWC,
  9952. x.OutsideGWPay,
  9953. x.SumTDC,
  9954. x.OutsideTDPay,
  9955. x.AirJJ,
  9956. x.AirGW,
  9957. x.AirTD,
  9958. x.CityTranffic,
  9959. x.TwoItemRemark
  9960. })
  9961. .Where(x => x.Id == id)
  9962. .ExecuteCommandAsync();
  9963. if (upd < 1) return Ok(JsonView(false));
  9964. }
  9965. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9966. gwcItemTotal = info.AirGW + info.CityTranffic;
  9967. tdcItemTotal = info.AirTD + info.CityTranffic;
  9968. ////消息通知
  9969. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9970. return Ok(JsonView(new
  9971. {
  9972. parentId = id,
  9973. choiceTwoJJ = dto.ChoiceTwoJJ,
  9974. jjcItemTotal = jjcItemTotal,
  9975. choiceTwoGW = dto.ChoiceTwoGW,
  9976. gwcItemTotal = gwcItemTotal,
  9977. choiceTwoTD = dto.ChoiceTwoTD,
  9978. tdcItemTotal = tdcItemTotal
  9979. }));
  9980. }
  9981. /// <summary>
  9982. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9983. /// </summary>
  9984. /// <returns></returns>
  9985. [HttpPost]
  9986. [ApiExplorerSettings(IgnoreApi = true)]
  9987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9988. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9989. {
  9990. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9991. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9992. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9993. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9994. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9995. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9996. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9997. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9998. {
  9999. Id = x.Id,
  10000. ParentId = dto.DraftId,
  10001. Type = dto.FeeType,
  10002. Days = x.Days,
  10003. NationalTravelFeeId = x.NationalTravelFeeId,
  10004. Cost = x.Cost,
  10005. Currency = x.Currency,
  10006. SubTotal = x.SubTotal,
  10007. CreateUserId = dto.CurrUserId
  10008. })
  10009. .ToList();
  10010. var adds = infos.Where(x => x.Id <= 0).ToList();
  10011. var upds = infos.Where(x => x.Id > 0).ToList();
  10012. if (adds.Count > 0)
  10013. {
  10014. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10015. if (add < 1) return Ok(JsonView(false));
  10016. }
  10017. if (upds.Count > 0)
  10018. {
  10019. var upd = await _sqlSugar.Updateable(adds)
  10020. .UpdateColumns(x => new
  10021. {
  10022. x.Days,
  10023. x.NationalTravelFeeId,
  10024. x.Cost,
  10025. x.Currency,
  10026. x.SubTotal
  10027. })
  10028. .WhereColumns(x => new { x.Id })
  10029. .ExecuteCommandAsync();
  10030. if (upd < 1) return Ok(JsonView(false));
  10031. }
  10032. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10033. ////消息通知
  10034. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10035. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10036. return Ok(JsonView(new { itemTotal = itemTotal }));
  10037. }
  10038. /// <summary>
  10039. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10040. /// </summary>
  10041. /// <returns></returns>
  10042. [HttpPost]
  10043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10044. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10045. {
  10046. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10047. int subId = dto.SubId, feeType = dto.FeeType;
  10048. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10049. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10050. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10051. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10052. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10053. subInfo.Id = subId;
  10054. subInfo.ParentId = dto.DraftId;
  10055. if (feeType == 3) subInfo.Type = 1;
  10056. else if (feeType == 4) subInfo.Type = 2;
  10057. else if (feeType == 5) subInfo.Type = 3;
  10058. else if (feeType == 6) subInfo.Type = 4;
  10059. subInfo.CreateUserId = dto.CurrUserId;
  10060. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10061. if (parentId < 1) return Ok(JsonView(false));
  10062. //子表op
  10063. if (subId < 1)
  10064. {
  10065. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10066. if (subAdd < 1) return Ok(JsonView(false));
  10067. }
  10068. else
  10069. {
  10070. var subUpd = await _sqlSugar.Updateable(subInfo)
  10071. .UpdateColumns(x => new
  10072. {
  10073. x.Days,
  10074. x.NationalTravelFeeId,
  10075. x.Cost,
  10076. x.Currency,
  10077. x.SubTotal
  10078. })
  10079. .WhereColumns(x => new { x.Id })
  10080. .ExecuteCommandAsync();
  10081. if (subUpd < 1) return Ok(JsonView(false));
  10082. }
  10083. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10084. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10085. }
  10086. /// <summary>
  10087. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10088. /// </summary>
  10089. /// <returns></returns>
  10090. [HttpPost]
  10091. [ApiExplorerSettings(IgnoreApi = true)]
  10092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10093. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10094. {
  10095. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10096. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10097. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10098. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10099. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10100. {
  10101. Id = x.Id,
  10102. ParentId = dto.DraftId,
  10103. SetDataId = x.SetDataId,
  10104. Index = x.Index,
  10105. Cost = x.Cost,
  10106. Currency = x.Currency,
  10107. SubTotal = x.SubTotal,
  10108. CreateUserId = dto.CurrUserId,
  10109. Remark = x.Remark
  10110. }).ToList();
  10111. var adds = infos.Where(x => x.Id <= 0).ToList();
  10112. var upds = infos.Where(x => x.Id > 0).ToList();
  10113. if (adds.Count > 0)
  10114. {
  10115. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10116. if (add < 1) return Ok(JsonView(false));
  10117. }
  10118. if (upds.Count > 0)
  10119. {
  10120. var upd = await _sqlSugar.Updateable(adds)
  10121. .UpdateColumns(x => new
  10122. {
  10123. x.Index,
  10124. x.SetDataId,
  10125. x.Cost,
  10126. x.Currency,
  10127. x.SubTotal,
  10128. x.Remark
  10129. })
  10130. .WhereColumns(x => new { x.Id })
  10131. .ExecuteCommandAsync();
  10132. if (upd < 1) return Ok(JsonView(false));
  10133. }
  10134. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10135. //消息通知
  10136. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10137. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10138. return Ok(JsonView(new { itemTotal = itemTotal }));
  10139. }
  10140. /// <summary>
  10141. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10142. /// </summary>
  10143. /// <returns></returns>
  10144. [HttpPost]
  10145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10146. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10147. {
  10148. int subId = dto.SubId, id = dto.DraftId;
  10149. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10150. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10151. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10152. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10153. subInfo.Id = subId;
  10154. subInfo.ParentId = id;
  10155. subInfo.CreateUserId = dto.CurrUserId;
  10156. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10157. if (parentId < 1) return Ok(JsonView(false));
  10158. #region 子表op
  10159. if (subId < 1)//add
  10160. {
  10161. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10162. if (subAdd < 1) return Ok(JsonView(false));
  10163. }
  10164. else //upd
  10165. {
  10166. var subUpd = await _sqlSugar.Updateable(subInfo)
  10167. .UpdateColumns(x => new
  10168. {
  10169. x.Index,
  10170. x.SetDataId,
  10171. x.Cost,
  10172. x.Currency,
  10173. x.SubTotal,
  10174. x.Remark
  10175. })
  10176. .WhereColumns(x => new { x.Id })
  10177. .ExecuteCommandAsync();
  10178. if (subUpd < 1) return Ok(JsonView(false));
  10179. }
  10180. #endregion
  10181. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10182. ////消息通知
  10183. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10184. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10185. }
  10186. /// <summary>
  10187. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10188. /// </summary>
  10189. /// <returns></returns>
  10190. [HttpPost]
  10191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10192. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10193. {
  10194. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10195. if (data.Code != 0)
  10196. {
  10197. return Ok(JsonView(false, data.Msg));
  10198. }
  10199. return Ok(JsonView(true, "操作成功!", data.Data));
  10200. }
  10201. /// <summary>
  10202. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10203. /// </summary>
  10204. /// <param name="dto"></param>
  10205. /// <returns></returns>
  10206. [HttpPost]
  10207. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10208. {
  10209. var data = new Grp_DayOtherPriceDraft()
  10210. {
  10211. Id = dto.Id,
  10212. IsDel = 1,
  10213. DeleteUserId = dto.DeleteUserId,
  10214. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10215. };
  10216. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10217. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10218. return Ok(JsonView(false, "删除失败!"));
  10219. }
  10220. #endregion
  10221. #endregion
  10222. #region 团组经理模块 出入境费用报价表
  10223. /// <summary>
  10224. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10225. /// </summary>
  10226. /// <returns></returns>
  10227. [HttpPost]
  10228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10229. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10230. {
  10231. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10232. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10233. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10234. initRates.Insert(0, cnyInfo);
  10235. liveRates.Insert(0, cnyInfo);
  10236. return Ok(JsonView(true, "查询成功!", new
  10237. {
  10238. InitRates = initRates,
  10239. LiveRates = liveRates
  10240. }));
  10241. }
  10242. /// <summary>
  10243. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10244. /// </summary>
  10245. /// <returns></returns>
  10246. [HttpPost]
  10247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10248. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10249. {
  10250. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10251. }
  10252. /// <summary>
  10253. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10254. /// </summary>
  10255. /// <returns></returns>
  10256. [HttpPost]
  10257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10258. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10259. {
  10260. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10261. }
  10262. /// <summary>
  10263. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10264. /// </summary>
  10265. /// <returns></returns>
  10266. [HttpPost]
  10267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10268. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10269. {
  10270. int groupId = dto.DiId,
  10271. currUserId = dto.CurrUserId;
  10272. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10273. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10274. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10275. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10276. var infoView = info.Data as EnterExitCostInfoView;
  10277. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10278. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10279. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10280. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10281. var eecRates = infoView.Currencys;
  10282. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10283. int pplNum = 1;
  10284. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10285. var views = new List<QuoteSubItemInfo>();
  10286. #region 数据填充
  10287. var intTravelCosts = new List<QuoteSubItemInfo>();
  10288. #region 机票费用 1354
  10289. int intTravelIndex = 1;
  10290. if (infoView.SumJJC == 1)
  10291. {
  10292. intTravelCosts.Add(new QuoteSubItemInfo
  10293. {
  10294. ItemId = 1354,
  10295. Index = intTravelIndex,
  10296. FeeName = "经济舱",
  10297. UnitPrice = infoView.AirJJ,
  10298. Currency = "CNY",
  10299. Quantity = 1,
  10300. PplNum = 1,
  10301. TotalAmt = infoView.AirJJ,
  10302. Remark = "",
  10303. });
  10304. intTravelIndex++;
  10305. }
  10306. if (infoView.SumGWC == 1)
  10307. {
  10308. intTravelCosts.Add(new QuoteSubItemInfo
  10309. {
  10310. ItemId = 1354,
  10311. Index = intTravelIndex,
  10312. FeeName = "公务舱",
  10313. UnitPrice = infoView.AirGW,
  10314. Currency = "CNY",
  10315. Quantity = 1,
  10316. PplNum = 1,
  10317. TotalAmt = infoView.AirGW,
  10318. Remark = "",
  10319. });
  10320. intTravelIndex++;
  10321. }
  10322. if (infoView.SumTDC == 1)
  10323. {
  10324. intTravelCosts.Add(new QuoteSubItemInfo
  10325. {
  10326. ItemId = 1354,
  10327. Index = intTravelIndex,
  10328. FeeName = "头等舱",
  10329. UnitPrice = infoView.AirTD,
  10330. Currency = "CNY",
  10331. Quantity = 1,
  10332. PplNum = 1,
  10333. TotalAmt = infoView.AirTD,
  10334. Remark = "",
  10335. });
  10336. intTravelIndex++;
  10337. }
  10338. intTravelCosts.Add(new QuoteSubItemInfo
  10339. {
  10340. ItemId = 1354,
  10341. Index = intTravelIndex,
  10342. FeeName = "城市间交通费用",
  10343. UnitPrice = infoView.CityTranffic,
  10344. Currency = "CNY",
  10345. Quantity = 1,
  10346. PplNum = pplNum,
  10347. TotalAmt = infoView.CityTranffic * pplNum,
  10348. Remark = "",
  10349. });
  10350. views.AddRange(intTravelCosts);
  10351. #endregion
  10352. var accomCosts = new List<QuoteSubItemInfo>();
  10353. #region 住宿费 1355
  10354. if (infoView.QuarterageData.Any())
  10355. {
  10356. int accomIndex = 1;
  10357. int accomItemTypeId = 1355;
  10358. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10359. foreach (var item in groupData)
  10360. {
  10361. string feeName = string.Empty;
  10362. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10363. if (countryInfo != null)
  10364. {
  10365. feeName = countryInfo.Country;
  10366. var city = countryInfo.City;
  10367. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10368. {
  10369. feeName += $"-{city}";
  10370. }
  10371. }
  10372. var hotelInfo = item.FirstOrDefault();
  10373. if (hotelInfo == null) continue;
  10374. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10375. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10376. int quantity = item.ToList().Count;
  10377. accomCosts.Add(new QuoteSubItemInfo
  10378. {
  10379. ItemId = accomItemTypeId,
  10380. Index = accomIndex,
  10381. FeeName = feeName,
  10382. UnitPrice = hotelInfo.Cost,
  10383. Currency = thisCurrency,
  10384. Quantity = quantity,
  10385. PplNum = pplNum,
  10386. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10387. Remark = "",
  10388. });
  10389. accomIndex++;
  10390. }
  10391. views.AddRange(accomCosts);
  10392. }
  10393. #endregion
  10394. var mealCosts = new List<QuoteSubItemInfo>();
  10395. #region 餐饮费 1356
  10396. if (infoView.BoardWagesData.Any())
  10397. {
  10398. var mealIndex = 1;
  10399. int mealItemTypeId = 1356;
  10400. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10401. foreach (var item in groupData)
  10402. {
  10403. string feeName = string.Empty;
  10404. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10405. if (countryInfo != null)
  10406. {
  10407. feeName = countryInfo.Country;
  10408. var city = countryInfo.City;
  10409. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10410. {
  10411. feeName += $"-{city}";
  10412. }
  10413. }
  10414. var mealInfo = item.FirstOrDefault();
  10415. if (mealInfo == null) continue;
  10416. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10417. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10418. int quantity = item.ToList().Count;
  10419. mealCosts.Add(new QuoteSubItemInfo
  10420. {
  10421. ItemId = mealItemTypeId,
  10422. Index = mealIndex,
  10423. FeeName = feeName,
  10424. UnitPrice = mealInfo.Cost,
  10425. Currency = thisCurrency,
  10426. Quantity = quantity,
  10427. PplNum = pplNum,
  10428. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10429. Remark = "",
  10430. });
  10431. mealIndex++;
  10432. }
  10433. views.AddRange(mealCosts);
  10434. }
  10435. #endregion
  10436. var miscCosts = new List<QuoteSubItemInfo>();
  10437. #region 公杂费 1364
  10438. if (infoView.MiscellaneousFeeData.Any())
  10439. {
  10440. var miscIndex = 1;
  10441. int miscItemTypeId = 1364;
  10442. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10443. foreach (var item in groupData)
  10444. {
  10445. string feeName = string.Empty;
  10446. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10447. if (countryInfo != null)
  10448. {
  10449. feeName = countryInfo.Country;
  10450. var city = countryInfo.City;
  10451. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10452. {
  10453. feeName += $"-{city}";
  10454. }
  10455. }
  10456. var miscInfo = item.FirstOrDefault();
  10457. if (miscInfo == null) continue;
  10458. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10459. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10460. int quantity = item.ToList().Count;
  10461. mealCosts.Add(new QuoteSubItemInfo
  10462. {
  10463. ItemId = miscItemTypeId,
  10464. Index = miscIndex,
  10465. FeeName = feeName,
  10466. UnitPrice = miscInfo.Cost,
  10467. Currency = thisCurrency,
  10468. Quantity = quantity,
  10469. PplNum = pplNum,
  10470. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10471. Remark = "",
  10472. });
  10473. miscIndex++;
  10474. }
  10475. views.AddRange(mealCosts);
  10476. }
  10477. #endregion
  10478. #region 签证+保险 1362
  10479. int visaInsIndex = 1;
  10480. int visaInsItemTypeId = 1362;
  10481. if (infoView.Visa > 0)
  10482. {
  10483. views.Add(new QuoteSubItemInfo() {
  10484. ItemId = visaInsItemTypeId,
  10485. Index = visaInsIndex,
  10486. FeeName = $"签证",
  10487. UnitPrice = infoView.Visa,
  10488. Currency = $"CNY",
  10489. Quantity = 1,
  10490. PplNum = pplNum,
  10491. TotalAmt = infoView.Visa * pplNum,
  10492. Remark = "",
  10493. });
  10494. visaInsIndex++;
  10495. }
  10496. if (infoView.Safe > 0)
  10497. {
  10498. views.Add(new QuoteSubItemInfo()
  10499. {
  10500. ItemId = visaInsItemTypeId,
  10501. Index = visaInsIndex,
  10502. FeeName = $"保险",
  10503. UnitPrice = infoView.Safe,
  10504. Currency = $"CNY",
  10505. Quantity = 1,
  10506. PplNum = pplNum,
  10507. TotalAmt = infoView.Safe * pplNum,
  10508. Remark = "",
  10509. });
  10510. }
  10511. #endregion
  10512. #region 服务费 1363
  10513. int serviceFeeIndex = 1;
  10514. int serviceFeeItemTypeId = 1363;
  10515. if (infoView.Service > 0)
  10516. {
  10517. views.Add(new QuoteSubItemInfo()
  10518. {
  10519. ItemId = serviceFeeItemTypeId,
  10520. Index = serviceFeeIndex,
  10521. FeeName = $"服务费",
  10522. UnitPrice = infoView.Service,
  10523. Currency = $"CNY",
  10524. Quantity = 1,
  10525. PplNum = pplNum,
  10526. TotalAmt = infoView.Service * pplNum,
  10527. Remark = "",
  10528. });
  10529. }
  10530. #endregion
  10531. #endregion
  10532. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10533. result.Rates = eecRates.ToArray();
  10534. if (result.FeeItems.Any())
  10535. {
  10536. result.FeeItems.Select(x =>
  10537. {
  10538. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10539. if (feeInfos.Any()) x.Infos = feeInfos;
  10540. return x;
  10541. }
  10542. )
  10543. .OrderBy(x => x.Index)
  10544. .ToList();
  10545. }
  10546. return Ok(JsonView(result));
  10547. }
  10548. /// <summary>
  10549. /// 团组模块 - 出入境费用报价表 - Info
  10550. /// </summary>
  10551. /// <returns></returns>
  10552. [HttpPost]
  10553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10554. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10555. {
  10556. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10557. if (!info.Rates.Any())
  10558. {
  10559. var rates = await GeneralMethod.EnterExitCostInitRate();
  10560. info.Rates = rates.ToArray();
  10561. }
  10562. return Ok(JsonView(info));
  10563. }
  10564. /// <summary>
  10565. /// 团组模块 - 出入境费用报价表 - OP
  10566. /// </summary>
  10567. /// <returns></returns>
  10568. [HttpPost]
  10569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10570. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10571. {
  10572. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10573. }
  10574. /// <summary>
  10575. /// 团组模块 - 出入境费用报价表 - 删除 项
  10576. /// </summary>
  10577. /// <returns></returns>
  10578. [HttpPost]
  10579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10580. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10581. {
  10582. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10584. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10585. }
  10586. /// <summary>
  10587. /// 团组模块 - 出入境费用报价表 - 导出
  10588. /// </summary>
  10589. /// <returns></returns>
  10590. [HttpPost]
  10591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10592. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10593. {
  10594. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10595. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10596. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10597. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10598. var rates = info.Rates;
  10599. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10600. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10601. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10602. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10603. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10604. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10605. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10606. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10607. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10608. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10609. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10610. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10611. //获取模板
  10612. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10613. var designer = new WorkbookDesigner();
  10614. designer.Workbook = new Workbook(tempPath);
  10615. designer.SetDataSource("QuoteName", info.Name);
  10616. designer.SetDataSource("CompanyTitle", "公司名称");
  10617. designer.SetDataSource("CompanyLabel", "");
  10618. #region 国际旅费
  10619. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10620. if (intTravelCosts.Infos.Any())
  10621. {
  10622. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10623. string label = string.Empty;
  10624. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10625. if (infos.Any())
  10626. {
  10627. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10628. }
  10629. foreach (var item in intTravelCosts.Infos)
  10630. {
  10631. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10632. }
  10633. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10634. designer.SetDataSource("IntTravelLabel", label);
  10635. }
  10636. #endregion
  10637. #region 住宿费
  10638. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10639. if (accomCosts.Infos.Any())
  10640. {
  10641. string currencyName = string.Empty;
  10642. decimal rate = 1.0000M;
  10643. string label = "全程五星酒店,每人1间房\r\n";
  10644. foreach (var item in accomCosts.Infos)
  10645. {
  10646. string hotelName = string.Empty;
  10647. if (item.FeeName.Contains("-"))
  10648. {
  10649. var feeName = item.FeeName.Split('-');
  10650. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10651. }
  10652. else hotelName = $"\r\n{item.FeeName}:";
  10653. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10654. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10655. rate = rateInfo?.Rate ?? 1.0000M;
  10656. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10657. }
  10658. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10659. designer.SetDataSource("AccomLabel", label);
  10660. }
  10661. #endregion
  10662. #region 餐饮费
  10663. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10664. if (mealCosts.Infos.Any())
  10665. {
  10666. string currencyName = string.Empty;
  10667. decimal rate = 1.0000M;
  10668. string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
  10669. foreach (var item in mealCosts.Infos)
  10670. {
  10671. string name = string.Empty;
  10672. if (item.FeeName.Contains("-"))
  10673. {
  10674. var feeName = item.FeeName.Split('-');
  10675. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10676. }
  10677. else name = $"\r\n{item.FeeName}:";
  10678. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10679. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10680. rate = rateInfo?.Rate ?? 1.0000M;
  10681. label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10682. }
  10683. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
  10684. designer.SetDataSource("MealLabel", label);
  10685. }
  10686. #endregion
  10687. #region 车辆安排
  10688. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  10689. if (vehArranges.Infos.Any())
  10690. {
  10691. string currencyName = string.Empty;
  10692. decimal rate = 1.0000M;
  10693. string label = $"";
  10694. foreach (var item in vehArranges.Infos)
  10695. {
  10696. label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
  10697. }
  10698. designer.SetDataSource("VehArrangeLabel", label);
  10699. }
  10700. #endregion
  10701. #region 邀请函发放对象
  10702. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  10703. #endregion
  10704. designer.Process();
  10705. //文件名
  10706. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10707. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10708. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10709. return Ok(JsonView(true, "成功", url));
  10710. }
  10711. #endregion
  10712. #region 签证费用录入
  10713. /// <summary>
  10714. /// 根据diid查询签证费用列表
  10715. /// </summary>
  10716. /// <param name="dto"></param>
  10717. /// <returns></returns>
  10718. [HttpPost]
  10719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10720. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10721. {
  10722. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10723. if (groupData.Code != 0)
  10724. {
  10725. return Ok(JsonView(false, groupData.Msg));
  10726. }
  10727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10728. }
  10729. /// <summary>
  10730. /// 根据签证费用Id查询单条数据及c表数据
  10731. /// </summary>
  10732. /// <param name="dto"></param>
  10733. /// <returns></returns>
  10734. [HttpPost]
  10735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10736. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10737. {
  10738. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10739. if (groupData.Code != 0)
  10740. {
  10741. return Ok(JsonView(false, groupData.Msg));
  10742. }
  10743. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10744. }
  10745. /// <summary>
  10746. /// 签证费用删除
  10747. /// </summary>
  10748. /// <param name="dto"></param>
  10749. /// <returns></returns>
  10750. [HttpPost]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10753. {
  10754. _sqlSugar.BeginTran();
  10755. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10756. if (!res)
  10757. {
  10758. _sqlSugar.RollbackTran();
  10759. return Ok(JsonView(false, "删除失败"));
  10760. }
  10761. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10762. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10763. .SetColumns(a => new Grp_CreditCardPayment()
  10764. {
  10765. IsDel = 1,
  10766. DeleteUserId = dto.DeleteUserId,
  10767. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10768. })
  10769. .ExecuteCommand();
  10770. if (resSub < 1)
  10771. {
  10772. _sqlSugar.RollbackTran();
  10773. return Ok(JsonView(false, "删除失败"));
  10774. }
  10775. _sqlSugar.CommitTran();
  10776. return Ok(JsonView(true, "删除成功!"));
  10777. }
  10778. /// <summary>
  10779. /// 签证费用录入下拉框初始化
  10780. /// </summary>
  10781. /// <returns></returns>
  10782. [HttpPost]
  10783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10784. public async Task<IActionResult> VisaPriceAddSelect()
  10785. {
  10786. //支付方式
  10787. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10788. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10789. //币种
  10790. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10791. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10792. //乘客类型
  10793. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10794. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10795. //卡类型
  10796. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10797. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10798. //代办费类型
  10799. var agencyFeeTypeData = new List<dynamic>() {
  10800. new { id = 0 , Text = "未选择" },
  10801. new { id = 1 , Text = "小公务" },
  10802. new { id = 2 , Text = "大公务" },
  10803. };
  10804. //签证费用标准国家Data
  10805. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10806. var data = new
  10807. {
  10808. Payment = _Payment,
  10809. CurrencyList = _CurrencyList,
  10810. PassengerType = _PassengerType,
  10811. BankCard = _BankCard,
  10812. AgencyFeeType = agencyFeeTypeData,
  10813. CountryFeeData = visaCountryFeeData
  10814. };
  10815. return Ok(JsonView(true, "查询成功!", data));
  10816. }
  10817. /// <summary>
  10818. /// 签证费用录入操作(Status:1.新增,2.修改)
  10819. /// </summary>
  10820. /// <param name="dto"></param>
  10821. /// <returns></returns>
  10822. [HttpPost]
  10823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10824. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10825. {
  10826. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10827. if (groupData.Code != 0)
  10828. {
  10829. return Ok(JsonView(false, groupData.Msg));
  10830. }
  10831. #region 应用推送
  10832. try
  10833. {
  10834. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10835. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10836. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10837. //2024-10-21 新增LZ UID
  10838. var userIds = new List<int>() { 21 };
  10839. string title = $"系统通知";
  10840. string content = "";
  10841. var diId = dto.DiId;
  10842. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10843. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10844. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10845. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10846. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10847. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10848. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10849. }
  10850. catch (Exception ex)
  10851. {
  10852. }
  10853. #endregion
  10854. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10855. }
  10856. #endregion
  10857. #region 签证提成录入
  10858. /// <summary>
  10859. /// 签证提成录入
  10860. /// 基础数据
  10861. /// </summary>
  10862. /// <returns></returns>
  10863. [HttpGet]
  10864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10865. public async Task<IActionResult> VisaCommissionInit()
  10866. {
  10867. return Ok(await _visaCommissionRep.Init());
  10868. }
  10869. /// <summary>
  10870. /// 签证提成录入
  10871. /// Item
  10872. /// </summary>
  10873. /// <param name="_dto"></param>
  10874. /// <returns></returns>
  10875. [HttpPost]
  10876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10877. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10878. {
  10879. var validator = new VisaCommissionItemDtoValidator();
  10880. var validatorRes = await validator.ValidateAsync(_dto);
  10881. if (!validatorRes.IsValid)
  10882. {
  10883. StringBuilder sb = new StringBuilder();
  10884. foreach (var item in validatorRes.Errors)
  10885. {
  10886. sb.AppendLine(item.ErrorMessage);
  10887. }
  10888. return Ok(JsonView(false, sb.ToString()));
  10889. }
  10890. return Ok(await _visaCommissionRep.Item(_dto));
  10891. }
  10892. /// <summary>
  10893. /// 签证提成录入
  10894. /// Save
  10895. /// </summary>
  10896. /// <param name="_dto"></param>
  10897. /// <returns></returns>
  10898. [HttpPost]
  10899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10900. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10901. {
  10902. //参数验证
  10903. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10904. foreach (var item in _dto.Items)
  10905. {
  10906. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10907. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10908. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10909. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10910. }
  10911. return Ok(await _visaCommissionRep.Save(_dto));
  10912. }
  10913. /// <summary>
  10914. /// 签证提成录入
  10915. /// Create
  10916. /// </summary>
  10917. /// <param name="_dto"></param>
  10918. /// <returns></returns>
  10919. [HttpPost]
  10920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10921. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10922. {
  10923. var validator = new VisaCommissionCreateDtoValidator();
  10924. var validatorRes = await validator.ValidateAsync(_dto);
  10925. if (!validatorRes.IsValid)
  10926. {
  10927. StringBuilder sb = new StringBuilder();
  10928. foreach (var item in validatorRes.Errors)
  10929. {
  10930. sb.AppendLine(item.ErrorMessage);
  10931. }
  10932. return Ok(JsonView(false, sb.ToString()));
  10933. }
  10934. return Ok(await _visaCommissionRep.Create(_dto));
  10935. }
  10936. /// <summary>
  10937. /// 签证提成录入
  10938. /// Put(编辑)
  10939. /// </summary>
  10940. /// <param name="id"></param>
  10941. /// <param name="_dto"></param>
  10942. /// <returns></returns>
  10943. [HttpPut]
  10944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10945. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10946. {
  10947. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10948. var validator = new VisaCommissionCreateDtoValidator();
  10949. var validatorRes = await validator.ValidateAsync(_dto);
  10950. if (!validatorRes.IsValid)
  10951. {
  10952. StringBuilder sb = new StringBuilder();
  10953. foreach (var item in validatorRes.Errors)
  10954. {
  10955. sb.AppendLine(item.ErrorMessage);
  10956. }
  10957. return Ok(JsonView(false, sb.ToString()));
  10958. }
  10959. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10960. }
  10961. /// <summary>
  10962. /// 签证提成录入
  10963. /// Del
  10964. /// </summary>
  10965. /// <param name="id"></param>
  10966. /// <param name="currUserId"></param>
  10967. /// <returns></returns>
  10968. [HttpPost]
  10969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10970. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10971. {
  10972. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10973. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10974. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10975. }
  10976. #endregion
  10977. #region op费用录入
  10978. /// <summary>
  10979. /// 根据diid查询op费用列表
  10980. /// </summary>
  10981. /// <param name="dto"></param>
  10982. /// <returns></returns>
  10983. [HttpPost]
  10984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10985. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10986. {
  10987. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10988. if (groupData.Code != 0)
  10989. {
  10990. return Ok(JsonView(false, groupData.Msg));
  10991. }
  10992. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10993. }
  10994. /// <summary>
  10995. /// 根据op费用Id查询单条数据及c表数据
  10996. /// </summary>
  10997. /// <param name="dto"></param>
  10998. /// <returns></returns>
  10999. [HttpPost]
  11000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11001. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11002. {
  11003. try
  11004. {
  11005. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11006. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11007. var data = new
  11008. {
  11009. CarTouristGuideGround = _groupData,
  11010. CreditCardPayment = _creditCardPayment
  11011. };
  11012. return Ok(JsonView(true, "查询成功!", data));
  11013. }
  11014. catch (Exception ex)
  11015. {
  11016. return Ok(JsonView(false, "程序错误!"));
  11017. }
  11018. }
  11019. /// <summary>
  11020. /// op费用删除
  11021. /// </summary>
  11022. /// <param name="dto"></param>
  11023. /// <returns></returns>
  11024. [HttpPost]
  11025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11026. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11027. {
  11028. try
  11029. {
  11030. _sqlSugar.BeginTran();
  11031. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11032. if (!res)
  11033. {
  11034. return Ok(JsonView(false, "删除失败"));
  11035. }
  11036. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11037. {
  11038. IsDel = 1,
  11039. DeleteUserId = dto.DeleteUserId,
  11040. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11041. }).ExecuteCommandAsync();
  11042. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11043. {
  11044. IsDel = 1,
  11045. DeleteUserId = dto.DeleteUserId,
  11046. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11047. }).ExecuteCommandAsync();
  11048. #region 删除超支相关数据
  11049. //删除导入的超支数据
  11050. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11051. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11052. {
  11053. IsDel = 1,
  11054. DeleteUserId = dto.DeleteUserId,
  11055. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11056. }).ExecuteCommand();
  11057. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11058. {
  11059. IsDel = 1,
  11060. DeleteUserId = dto.DeleteUserId,
  11061. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11062. }).ExecuteCommand();
  11063. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11064. {
  11065. IsDel = 1,
  11066. DeleteUserId = dto.DeleteUserId,
  11067. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11068. }).ExecuteCommand();
  11069. #endregion
  11070. _sqlSugar.CommitTran();
  11071. return Ok(JsonView(true, "删除成功!"));
  11072. }
  11073. catch (Exception ex)
  11074. {
  11075. _sqlSugar.RollbackTran();
  11076. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11077. }
  11078. }
  11079. /// <summary>
  11080. /// op费用录入操作(Status:1.新增,2.修改)
  11081. /// </summary>
  11082. /// <param name="dto"></param>
  11083. /// <returns></returns>
  11084. [HttpPost]
  11085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11086. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11087. {
  11088. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11089. if (groupData.Code != 0)
  11090. {
  11091. return Ok(JsonView(false, groupData.Msg));
  11092. }
  11093. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11094. }
  11095. /// <summary>
  11096. /// 填写费用详细页面初始化绑定
  11097. /// </summary>
  11098. /// <param name="dto"></param>
  11099. /// <returns></returns>
  11100. [HttpPost]
  11101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11102. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11103. {
  11104. try
  11105. {
  11106. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11107. if (groupData.Code != 0)
  11108. {
  11109. return Ok(JsonView(false, groupData.Msg));
  11110. }
  11111. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11112. }
  11113. catch (Exception ex)
  11114. {
  11115. return Ok(JsonView(false, ex.Message));
  11116. }
  11117. }
  11118. /// <summary>
  11119. /// 根据op费用Id查询详细数据
  11120. /// </summary>
  11121. /// <param name="dto"></param>
  11122. /// <returns></returns>
  11123. [HttpPost]
  11124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11125. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11126. {
  11127. try
  11128. {
  11129. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11130. if (groupData.Code != 0)
  11131. {
  11132. return Ok(JsonView(false, groupData.Msg));
  11133. }
  11134. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11135. }
  11136. catch (Exception ex)
  11137. {
  11138. return Ok(JsonView(false, ex.Message));
  11139. }
  11140. }
  11141. /// <summary>
  11142. /// OP费用录入填写详情
  11143. /// </summary>
  11144. /// <param name="dto"></param>
  11145. /// <returns></returns>
  11146. [HttpPost]
  11147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11148. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11149. {
  11150. try
  11151. {
  11152. #region 参数校验
  11153. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11154. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11155. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11156. #endregion
  11157. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11158. if (groupData.Code != 0)
  11159. {
  11160. return Ok(JsonView(false, groupData.Msg));
  11161. }
  11162. //自动审核
  11163. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11164. #region 应用推送
  11165. try
  11166. {
  11167. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11168. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11169. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11170. //2024-10-21 新增LZ UID
  11171. var userIds = new List<int>() { 21 };
  11172. string title = $"系统通知";
  11173. var diId = dto.DiId;
  11174. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11175. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11176. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11177. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11178. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11179. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11180. }
  11181. catch (Exception ex)
  11182. {
  11183. }
  11184. #endregion
  11185. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11186. }
  11187. catch (Exception ex)
  11188. {
  11189. return Ok(JsonView(false, ex.Message));
  11190. }
  11191. }
  11192. /// <summary>
  11193. /// 获取三公详细所有城市
  11194. /// </summary>
  11195. /// <returns></returns>
  11196. [HttpGet]
  11197. public IActionResult OpCarCityResult()
  11198. {
  11199. var jw = JsonView(false);
  11200. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11201. {
  11202. x.Id,
  11203. x.Country,
  11204. x.City,
  11205. }).ToList();
  11206. if (data.Count > 0)
  11207. {
  11208. jw = JsonView(true, "获取成功!", data);
  11209. }
  11210. else
  11211. {
  11212. jw.Msg = "城市数据为空!";
  11213. jw.Data = new string[0];
  11214. }
  11215. return Ok(jw);
  11216. }
  11217. /// <summary>
  11218. /// 导出地接费用明细
  11219. /// </summary>
  11220. /// <param name="dto"></param>
  11221. /// <returns></returns>
  11222. [HttpPost]
  11223. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11224. {
  11225. var jw = JsonView(false);
  11226. if (dto.Diid < 1)
  11227. {
  11228. jw.Msg = "请输入正确的diid!";
  11229. return Ok(jw);
  11230. }
  11231. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11232. if (group == null)
  11233. {
  11234. jw.Msg = "未找到团组信息!";
  11235. return Ok(jw);
  11236. }
  11237. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11238. if (localGuideArr.Count == 0)
  11239. {
  11240. jw.Msg = "该团组暂无地接信息!";
  11241. return Ok(jw);
  11242. }
  11243. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11244. var overspendSoure = new Dictionary<int, int>
  11245. {
  11246. { 91, 982 }, //车
  11247. { 92 , 1059} ,//导游
  11248. { 994 , 1073}, //翻译
  11249. { 988 , 1074 }, //早餐
  11250. { 93 , 1075 }, //午餐
  11251. { 989 , 1076 }, //晚餐
  11252. };
  11253. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11254. foreach (var groupArr in localGroup)
  11255. {
  11256. var keyValue = groupArr.Key;
  11257. if (int.TryParse(keyValue, out int cityid))
  11258. {
  11259. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11260. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11261. }
  11262. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11263. foreach (var item in groupArr)
  11264. {
  11265. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11266. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11267. new Grp_CarTouristGuideGroundReservationsContentExtend
  11268. {
  11269. Count = a.Count,
  11270. CreateTime = a.CreateTime,
  11271. CreateUserId = a.CreateUserId,
  11272. CTGGRId = a.CTGGRId,
  11273. Currency = a.Currency,
  11274. DatePrice = a.DatePrice,
  11275. DeleteTime = a.DeleteTime,
  11276. DeleteUserId = a.DeleteUserId,
  11277. DiId = a.DiId,
  11278. Id = a.Id,
  11279. IsDel = a.IsDel,
  11280. Price = a.Price,
  11281. PriceContent = a.PriceContent,
  11282. Remark = a.Remark,
  11283. SId = a.SId,
  11284. SidName = b.Name,
  11285. Units = a.Units,
  11286. }
  11287. ).ToList();
  11288. if (content.Count > 0)
  11289. {
  11290. contentArr.Add(content);
  11291. }
  11292. }
  11293. //open excel
  11294. //set excel
  11295. //save excel
  11296. try
  11297. {
  11298. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11299. IWorkbook workbook;
  11300. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11301. {
  11302. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11303. }
  11304. else
  11305. {
  11306. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11307. }
  11308. ISheet sheet = workbook.GetSheetAt(0);
  11309. var rowStartIndex = 2;
  11310. var clounmCount = 10;
  11311. var initStyleRow = sheet.GetRow(2);
  11312. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11313. //var overspendArrDetail =
  11314. var existsId = new List<CarCompare>();
  11315. var lastElem = arr.Last();
  11316. var thisSid = -1;
  11317. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11318. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11319. {
  11320. Name = "未知币种!",
  11321. Remark = "未知币种!",
  11322. };
  11323. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11324. Action cloneRowFn = () =>
  11325. {
  11326. rowStartIndex++;
  11327. var cloneRow = sheet.CreateRow(rowStartIndex);
  11328. // 复制样式
  11329. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11330. {
  11331. ICell sourceCell = initStyleRow.GetCell(i);
  11332. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11333. // 确保单元格存在样式
  11334. if (sourceCell.CellStyle != null)
  11335. {
  11336. targetCell.CellStyle = sourceCell.CellStyle;
  11337. }
  11338. }
  11339. };
  11340. var mergeRow = () =>
  11341. {
  11342. for (int i = 2; i < sheet.LastRowNum; i++)
  11343. {
  11344. var row = sheet.GetRow(i);
  11345. var cellFirst = row.GetCell(0);
  11346. var thisIndex = i + 1;
  11347. while (thisIndex < sheet.LastRowNum)
  11348. {
  11349. var nextRow = sheet.GetRow(thisIndex);
  11350. var nextCellFirst = nextRow.GetCell(0);
  11351. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11352. {
  11353. thisIndex++;
  11354. }
  11355. else
  11356. {
  11357. break;
  11358. }
  11359. }
  11360. thisIndex--;
  11361. if (thisIndex != i)
  11362. {
  11363. //合并row
  11364. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11365. i, // 起始行索引(0-based)
  11366. thisIndex, // 结束行索引(0-based)
  11367. 0, // 起始列索引(0-based)
  11368. 0 // 结束列索引(0-based)
  11369. );
  11370. sheet.AddMergedRegion(cellRangeAddress);
  11371. i = thisIndex;
  11372. }
  11373. }
  11374. };
  11375. var chaoshiNumber = 0;
  11376. var totalNumber = 0.00M;
  11377. string lastStr = "";
  11378. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11379. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11380. {
  11381. b.IsAuditGM,
  11382. x.Id,
  11383. x.Area,
  11384. b.PayPercentage,
  11385. b.PayMoney,
  11386. }).ToList();
  11387. string yesPayment = "", noPayment = "";
  11388. foreach (var item in queryCarArrByCityAndDiid)
  11389. {
  11390. if (item.IsAuditGM == 1)
  11391. {
  11392. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11393. }
  11394. else
  11395. {
  11396. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11397. }
  11398. }
  11399. lastStr = yesPayment + noPayment;
  11400. foreach (var item in arr)
  11401. {
  11402. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11403. {
  11404. if (thisSid != item.SId)
  11405. {
  11406. if (thisSid == -1)
  11407. {
  11408. thisSid = item.SId;
  11409. }
  11410. else
  11411. {
  11412. //合并小计行
  11413. //创建合并区域的实例
  11414. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11415. rowStartIndex, // 起始行索引(0-based)
  11416. rowStartIndex, // 结束行索引(0-based)
  11417. 0, // 起始列索引(0-based)
  11418. 3 // 结束列索引(0-based)
  11419. );
  11420. sheet.AddMergedRegion(cellRangeAddress);
  11421. var CellStyle = workbook.CreateCellStyle();
  11422. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11423. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11424. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11425. for (int i = 0; i <= clounmCount; i++)
  11426. {
  11427. if (i > 6)
  11428. {
  11429. var CellStyle1 = workbook.CreateCellStyle();
  11430. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11431. IFont Font = workbook.CreateFont(); // 创建字体
  11432. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11433. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11434. CellStyle1.SetFont(Font);
  11435. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11436. }
  11437. else
  11438. {
  11439. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11440. }
  11441. }
  11442. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11443. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11444. //超时合计
  11445. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11446. //超时数
  11447. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11448. //超时合计费用
  11449. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11450. thisSid = item.SId;
  11451. cloneRowFn();
  11452. chaoshiNumber = 0;
  11453. totalNumber = 0;
  11454. }
  11455. }
  11456. IRow row = sheet.GetRow(rowStartIndex);
  11457. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11458. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11459. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11460. if (isOpenOverspendSoure)
  11461. {
  11462. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11463. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11464. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11465. }
  11466. for (int i = 0; i <= clounmCount; i++)
  11467. {
  11468. var cell = row.GetCell(i);
  11469. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11470. if (cell == null)
  11471. {
  11472. cell = row.CreateCell(i);
  11473. }
  11474. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11475. fontRed.CloneStyleFrom(cell.CellStyle);
  11476. IFont Font = workbook.CreateFont(); // 创建字体
  11477. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11478. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11479. fontRed.SetFont(Font);
  11480. byte[] rgb = new byte[3] { 255, 242, 204 };
  11481. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11482. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11483. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11484. if (workbook is XSSFWorkbook)
  11485. {
  11486. BackgroundColor255_242_204.FillForegroundColor = 0;
  11487. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11488. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11489. }
  11490. else
  11491. {
  11492. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11493. }
  11494. if (i == 1 || i > 6)
  11495. {
  11496. if (i > 6)
  11497. {
  11498. fontRed.FillForegroundColor = 0;
  11499. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11500. fontRed.FillPattern = FillPattern.SolidForeground;
  11501. }
  11502. cell.CellStyle = fontRed;
  11503. }
  11504. if (i > 2 && i < 7)
  11505. {
  11506. cell.CellStyle = BackgroundColor255_242_204;
  11507. }
  11508. cell.SetCellValue(setCellValue); //写入单元格
  11509. }
  11510. if (overspendSoure.ContainsKey(thisSid))
  11511. {
  11512. var overspendId = overspendSoure[thisSid];
  11513. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11514. }
  11515. cloneRowFn();
  11516. existsId.Add(new CarCompare
  11517. {
  11518. DataPrice = item.DatePrice.ObjToDate(),
  11519. Sid = item.SId
  11520. });
  11521. }
  11522. if (item.Equals(lastElem))
  11523. {
  11524. //合并小计行
  11525. //创建合并区域的实例
  11526. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11527. rowStartIndex, // 起始行索引(0-based)
  11528. rowStartIndex, // 结束行索引(0-based)
  11529. 0, // 起始列索引(0-based)
  11530. 3 // 结束列索引(0-based)
  11531. );
  11532. sheet.AddMergedRegion(cellRangeAddress);
  11533. var CellStyle = workbook.CreateCellStyle();
  11534. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11535. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11536. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11537. for (int i = 0; i <= clounmCount; i++)
  11538. {
  11539. if (i > 6)
  11540. {
  11541. var CellStyle1 = workbook.CreateCellStyle();
  11542. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11543. IFont Font = workbook.CreateFont(); // 创建字体
  11544. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11545. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11546. CellStyle1.SetFont(Font);
  11547. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11548. }
  11549. else
  11550. {
  11551. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11552. }
  11553. }
  11554. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11555. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11556. //超时合计
  11557. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11558. //超时数
  11559. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11560. //超时合计费用
  11561. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11562. cloneRowFn();
  11563. // 创建合并区域的实例
  11564. cellRangeAddress = new CellRangeAddress(
  11565. rowStartIndex, // 起始行索引(0-based)
  11566. rowStartIndex, // 结束行索引(0-based)
  11567. 0, // 起始列索引(0-based)
  11568. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11569. );
  11570. // 添加合并区域
  11571. sheet.AddMergedRegion(cellRangeAddress);
  11572. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11573. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11574. }
  11575. }
  11576. mergeRow();
  11577. // 保存修改后的Excel文件到新文件
  11578. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11579. // new FileStream(newFilePath, FileMode.CreateNew)
  11580. using (var stream = new MemoryStream())
  11581. {
  11582. workbook.Write(stream, true);
  11583. stream.Flush();
  11584. stream.Seek(0, SeekOrigin.Begin);
  11585. MemoryStream memoryStream = new MemoryStream();
  11586. stream.CopyTo(memoryStream);
  11587. memoryStream.Seek(0, SeekOrigin.Begin);
  11588. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11589. }
  11590. workbook.Close();
  11591. workbook.Dispose();
  11592. }
  11593. catch (Exception ex)
  11594. {
  11595. jw.Msg = "出现异常!" + ex.Message;
  11596. return Ok(jw);
  11597. }
  11598. }
  11599. if (Zips.Count > 0)
  11600. {
  11601. IOOperatorHelper io = new IOOperatorHelper();
  11602. var byts = io.ConvertZipStream(Zips);
  11603. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11604. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11605. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11606. }
  11607. else
  11608. {
  11609. jw.Msg = "暂无生成文件!";
  11610. }
  11611. return Ok(jw);
  11612. }
  11613. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11614. {
  11615. string outStr = string.Empty;
  11616. switch (i)
  11617. {
  11618. case 0:
  11619. outStr = arr[0].SidName;
  11620. break;
  11621. case 1:
  11622. outStr = arr[0].DataPriceStr;
  11623. break;
  11624. case 2:
  11625. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11626. break;
  11627. case 4:
  11628. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11629. break;
  11630. case 7:
  11631. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11632. {
  11633. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11634. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11635. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11636. }
  11637. break;
  11638. case 8:
  11639. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11640. {
  11641. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11642. }
  11643. break;
  11644. case 9:
  11645. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11646. {
  11647. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11648. }
  11649. break;
  11650. case 10:
  11651. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11652. {
  11653. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11654. }
  11655. break;
  11656. }
  11657. return outStr;
  11658. }
  11659. #region OP行程单
  11660. /// <summary>
  11661. /// OP行程单初始化
  11662. /// </summary>
  11663. /// <param name="dto"></param>
  11664. /// <returns></returns>
  11665. [HttpPost]
  11666. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11667. {
  11668. var jw = JsonView(false);
  11669. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11670. var group = groupList.First();
  11671. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11672. if (group == null)
  11673. {
  11674. jw.Msg = "暂无团组!";
  11675. return Ok(jw);
  11676. }
  11677. group = groupList.Find(x => x.Id == diid);
  11678. if (group == null)
  11679. {
  11680. jw.Msg = "请输入正确的团组ID!";
  11681. return Ok(jw);
  11682. }
  11683. string city = string.Empty;
  11684. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11685. if (blackCode.Count > 0)
  11686. {
  11687. var black = blackCode.First();
  11688. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11689. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11690. if (blackSp.Length > 0)
  11691. {
  11692. try
  11693. {
  11694. var cityArrCode = new List<string>(20);
  11695. foreach (var item in blackSp)
  11696. {
  11697. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11698. var IndexSelect = itemSp[2];
  11699. var cityArrCodeLength = cityArrCode.Count - 1;
  11700. var startCity = IndexSelect.Substring(0, 3);
  11701. if (cityArrCodeLength > 0)
  11702. {
  11703. var arrEndCity = cityArrCode[cityArrCodeLength];
  11704. if (arrEndCity != startCity)
  11705. {
  11706. cityArrCode.Add(startCity.ToUpper());
  11707. }
  11708. }
  11709. else
  11710. {
  11711. cityArrCode.Add(startCity.ToUpper());
  11712. }
  11713. var endCity = IndexSelect.Substring(3, 3);
  11714. cityArrCode.Add(endCity.ToUpper());
  11715. }
  11716. var cityThree = string.Empty;
  11717. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11718. cityThree = cityThree.TrimEnd(',');
  11719. if (string.IsNullOrWhiteSpace(cityThree))
  11720. {
  11721. throw new
  11722. Exception("error");
  11723. }
  11724. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11725. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11726. foreach (var item in cityArrCode)
  11727. {
  11728. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11729. if (find != null)
  11730. {
  11731. city += find.City + "/";
  11732. }
  11733. else
  11734. {
  11735. city += item + "三字码未收入/";
  11736. }
  11737. }
  11738. city = city.TrimEnd('/');
  11739. }
  11740. catch (Exception e)
  11741. {
  11742. city = "黑屏代码格式不正确!";
  11743. }
  11744. }
  11745. }
  11746. else
  11747. {
  11748. city = "未录入黑屏代码";
  11749. }
  11750. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11751. {
  11752. Date = x.Date,
  11753. Days = x.Days,
  11754. Diffgroup = x.Diffgroup,
  11755. Diid = x.Diid,
  11756. Traffic_First = x.Traffic_First,
  11757. Traffic_Second = x.Traffic_Second,
  11758. Trip = x.Trip,
  11759. WeekDay = x.WeekDay,
  11760. Id = x.Id
  11761. }).ToList();
  11762. jw.Data = new
  11763. {
  11764. groupList = groupList.Select(x => new
  11765. {
  11766. x.Id,
  11767. x.TeamName,
  11768. x.TourCode
  11769. }).ToList(),
  11770. groupInfo = new
  11771. {
  11772. group.VisitDays,
  11773. group.TourCode,
  11774. group.VisitPNumber,
  11775. group.TeamName,
  11776. city
  11777. },
  11778. OpTravelList
  11779. };
  11780. jw.Code = 200;
  11781. jw.Msg = "操作成功!";
  11782. return Ok(jw);
  11783. }
  11784. /// <summary>
  11785. /// 删除团组行程单
  11786. /// </summary>
  11787. /// <returns></returns>
  11788. [HttpPost]
  11789. public IActionResult DelTravel(DelOpTravelDto dto)
  11790. {
  11791. var jw = JsonView(false);
  11792. if (dto.UserId <= 0 || dto.Diid <= 0)
  11793. {
  11794. jw.Msg = "请输入正确的参数!";
  11795. return Ok(jw);
  11796. }
  11797. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11798. .SetColumns(x => new Grp_TravelList
  11799. {
  11800. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11801. DeleteUserId = dto.UserId,
  11802. IsDel = 1,
  11803. }).ExecuteCommand();
  11804. jw = JsonView(true);
  11805. return Ok(jw);
  11806. }
  11807. /// <summary>
  11808. /// 行程单保存
  11809. /// </summary>
  11810. /// <returns></returns>
  11811. [HttpPost]
  11812. public IActionResult TravelSave(TravelSaveDto dto)
  11813. {
  11814. var jw = JsonView(false);
  11815. if (dto.Arr.Count > 0)
  11816. {
  11817. try
  11818. {
  11819. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11820. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11821. .ToList();
  11822. _sqlSugar.BeginTran();
  11823. foreach (var item in dto.Arr)
  11824. {
  11825. if (item.Id == 0)
  11826. {
  11827. throw new Exception("请传入正确的Id");
  11828. }
  11829. //比较上一次的差异
  11830. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11831. if (findTravel != null)
  11832. {
  11833. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11834. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11835. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11836. }
  11837. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11838. .SetColumns(x => new Grp_TravelList
  11839. {
  11840. Trip = item.Trip
  11841. }).ExecuteCommand();
  11842. }
  11843. _sqlSugar.CommitTran();
  11844. jw = JsonView(true);
  11845. }
  11846. catch (Exception ex)
  11847. {
  11848. _sqlSugar.RollbackTran();
  11849. jw.Msg = "程序异常!" + ex.Message;
  11850. }
  11851. }
  11852. else
  11853. {
  11854. jw.Msg = "请传入正确的参数!";
  11855. }
  11856. return Ok(jw);
  11857. }
  11858. private string CheckStr(string original, string changed)
  11859. {
  11860. // 创建diff_match_patch对象
  11861. var dmp = new diff_match_patch();
  11862. // 计算差异
  11863. List<Diff> diffs = dmp.diff_main(original, changed);
  11864. // 清理和合并差异
  11865. dmp.diff_cleanupSemantic(diffs);
  11866. // 使用StringBuilder构建最终的字符串
  11867. StringBuilder finalString = new StringBuilder();
  11868. // 输出差异结果,并构建变动后的字符串
  11869. foreach (Diff diff in diffs)
  11870. {
  11871. switch (diff.operation)
  11872. {
  11873. case Operation.EQUAL:
  11874. // 相等的部分,直接添加到最终字符串
  11875. finalString.Append(diff.text);
  11876. break;
  11877. case Operation.INSERT:
  11878. // 插入的部分,添加标记并添加到最终字符串
  11879. finalString.Append("[++]" + diff.text + "[++]");
  11880. break;
  11881. case Operation.DELETE:
  11882. // 删除的部分,不添加到最终字符串
  11883. //finalString.Append("[++]" + diff.text + "[++]");
  11884. break;
  11885. }
  11886. }
  11887. // 输出变动后的字符串
  11888. return finalString.ToString();
  11889. }
  11890. private class tagContent
  11891. {
  11892. public DateTime Date { get; set; }
  11893. public string StartTag { get; set; }
  11894. public string EndTag { get; set; }
  11895. public string Content { get; set; }
  11896. public static int tagLength { get { return 3; } }
  11897. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11898. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11899. public bool IsFinally { get; set; }
  11900. }
  11901. private List<string> ExtractContentBetweenTags(string input, string tag)
  11902. {
  11903. List<string> results = new List<string>();
  11904. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11905. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11906. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11907. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11908. string[] strValueArr = new string[1];
  11909. foreach (System.Text.RegularExpressions.Match match in matches)
  11910. {
  11911. var strValue = match.Groups[1].Value;
  11912. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11913. }
  11914. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11915. return results;
  11916. }
  11917. /// <summary>
  11918. /// 导出行程单
  11919. /// </summary>
  11920. /// <param name="dto"></param>
  11921. /// <returns></returns>
  11922. [HttpPost]
  11923. public IActionResult ExportTravel(ExportTravelDto dto)
  11924. {
  11925. var jw = JsonView(false);
  11926. jw.Data = "";
  11927. int diid = 0;
  11928. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11929. if (Find == null)
  11930. {
  11931. jw.Msg = "请选择正确的团组!";
  11932. return Ok(jw);
  11933. }
  11934. else
  11935. {
  11936. diid = Find.Id;
  11937. }
  11938. //数据源
  11939. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11940. DataTable dtBlack = null;
  11941. try
  11942. {
  11943. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11944. }
  11945. catch (Exception)
  11946. {
  11947. jw.Msg = "机票黑屏代码有误!";
  11948. return Ok(jw);
  11949. }
  11950. string CityStr = string.Empty;
  11951. if (dtBlack.Rows.Count == 0)
  11952. {
  11953. jw.Msg = "机票黑屏代码有误!";
  11954. return Ok(jw);
  11955. }
  11956. else
  11957. {
  11958. foreach (DataRow row in dtBlack.Rows)
  11959. {
  11960. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11961. {
  11962. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11963. return Ok(jw);
  11964. }
  11965. }
  11966. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11967. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11968. }
  11969. // 指定的文字
  11970. var targetTextDic = new Dictionary<string, List<string>>();
  11971. //创建数据源Table
  11972. DataTable dtSource = new DataTable();
  11973. dtSource.Columns.Add("Days", typeof(string));
  11974. dtSource.Columns.Add("Date", typeof(string));
  11975. dtSource.Columns.Add("Week", typeof(string));
  11976. dtSource.Columns.Add("Traffic", typeof(string));
  11977. dtSource.Columns.Add("Trip", typeof(string));
  11978. //获取数据,放到datatable
  11979. foreach (var item in _travelList)
  11980. {
  11981. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11982. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11983. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11984. .Replace("[++]", string.Empty);
  11985. DataRow dr = dtSource.NewRow();
  11986. dr["Days"] = item.Days;
  11987. dr["Date"] = item.Date;
  11988. dr["Week"] = item.WeekDay;
  11989. dr["Traffic"] = item.Traffic_First
  11990. + "\r\n"
  11991. + item.Traffic_Second;
  11992. dr["Trip"] = item.Trip;
  11993. dtSource.Rows.Add(dr);
  11994. }
  11995. Dictionary<string, string> dic = new Dictionary<string, string>();
  11996. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11997. dic.Add("City", CityStr);
  11998. dic.Add("Days", Find.VisitDays.ToString());
  11999. dic.Add("DeleCode", Find.TourCode);
  12000. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12001. //模板路径
  12002. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12003. //载入模板
  12004. Document doc = null;
  12005. DocumentBuilder builder = null;
  12006. try
  12007. {
  12008. //载入模板
  12009. doc = new Document(tempPath);
  12010. builder = new DocumentBuilder(doc);
  12011. }
  12012. catch (Exception)
  12013. {
  12014. jw.Msg = "模板位置不存在!";
  12015. return Ok(jw);
  12016. }
  12017. foreach (var key in dic.Keys)
  12018. {
  12019. Bookmark bookmark = doc.Range.Bookmarks[key];
  12020. if (bookmark != null)
  12021. {
  12022. builder.MoveToBookmark(key);
  12023. builder.Write(dic[key]);
  12024. }
  12025. }
  12026. //获取word里所有表格
  12027. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12028. //获取所填表格的序数
  12029. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12030. try
  12031. {
  12032. //循环赋值
  12033. for (int i = 0; i < dtSource.Rows.Count; i++)
  12034. {
  12035. builder.MoveToCell(0, i + 1, 0, 0);
  12036. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12037. builder.MoveToCell(0, i + 1, 1, 0);
  12038. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12039. builder.MoveToCell(0, i + 1, 2, 0);
  12040. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12041. var trip = dtSource.Rows[i]["Trip"].ToString();
  12042. builder.MoveToCell(0, i + 1, 3, 0);
  12043. builder.Write(trip);
  12044. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12045. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12046. // 获取特定索引的段落
  12047. Paragraph paragraph = (Paragraph)paragraphs[0];
  12048. Run run = paragraph.Runs[0];
  12049. Aspose.Words.Font font = run.Font;
  12050. font.Name = "黑体";
  12051. //设置双休红色
  12052. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12053. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12054. paragraph = (Paragraph)paragraphs[1];
  12055. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12056. {
  12057. run = paragraph.Runs[0];
  12058. font = run.Font;
  12059. font.Color = Color.Red;
  12060. }
  12061. }
  12062. }
  12063. catch (Exception ex)
  12064. {
  12065. }
  12066. //删除多余行
  12067. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12068. {
  12069. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12070. }
  12071. var targetTextList = new List<string>();
  12072. // 遍历文档中的表格
  12073. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12074. {
  12075. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12076. {
  12077. var cellIndex = 0;
  12078. foreach (Cell cell in row.Cells)
  12079. {
  12080. if (cellIndex == 1 && row.Cells.Count == 4)
  12081. {
  12082. foreach (var target in targetTextDic.Keys)
  12083. {
  12084. if (cell.GetText().Contains(target))
  12085. {
  12086. targetTextList = targetTextDic[target];
  12087. break;
  12088. }
  12089. }
  12090. }
  12091. // 遍历单元格中的所有段落
  12092. foreach (Paragraph paragraph in cell.Paragraphs)
  12093. {
  12094. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12095. List<Run> runs = new List<Run>();
  12096. foreach (Run run in paragraph.Runs)
  12097. {
  12098. runs.Add(run);
  12099. }
  12100. foreach (Run run in runs)
  12101. {
  12102. foreach (var targetText in targetTextList)
  12103. {
  12104. // 检查文字是否包含指定文字
  12105. if (run.Text.Contains(targetText))
  12106. {
  12107. // 将包含的部分设置为红色
  12108. HighlightText(run, targetText, Color.Red);
  12109. }
  12110. }
  12111. }
  12112. }
  12113. cellIndex++;
  12114. }
  12115. }
  12116. }
  12117. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12118. if (!Directory.Exists(savePath))
  12119. {
  12120. try
  12121. {
  12122. Directory.CreateDirectory(savePath);
  12123. }
  12124. catch
  12125. {
  12126. }
  12127. }
  12128. string path = savePath + Find.TeamName + "出访日程";
  12129. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12130. try
  12131. {
  12132. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12133. string postfix = ".docx";
  12134. if (dto.IsPDF == 1)
  12135. {
  12136. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12137. postfix = ".pdf";
  12138. }
  12139. doc.Save(path + postfix, saveFormat);
  12140. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12141. }
  12142. catch (Exception)
  12143. {
  12144. jw = JsonView(false);
  12145. }
  12146. return Ok(jw);
  12147. }
  12148. /// <summary>
  12149. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12150. /// </summary>
  12151. /// <param name="num"></param>
  12152. /// <returns></returns>
  12153. string GetNum(string num)
  12154. {
  12155. string str = "";
  12156. switch (num)
  12157. {
  12158. case "1":
  12159. str = "一";
  12160. break;
  12161. case "2":
  12162. str = "二";
  12163. break;
  12164. case "3":
  12165. str = "三";
  12166. break;
  12167. case "4":
  12168. str = "四";
  12169. break;
  12170. case "5":
  12171. str = "五";
  12172. break;
  12173. case "6":
  12174. str = "六";
  12175. break;
  12176. case "7":
  12177. str = "七";
  12178. break;
  12179. case "8":
  12180. str = "八";
  12181. break;
  12182. case "9":
  12183. str = "九";
  12184. break;
  12185. case "10":
  12186. str = "十";
  12187. break;
  12188. case "11":
  12189. str = "十一";
  12190. break;
  12191. case "12":
  12192. str = "十二";
  12193. break;
  12194. case "一":
  12195. str = "1";
  12196. break;
  12197. case "二":
  12198. str = "2";
  12199. break;
  12200. case "三":
  12201. str = "3";
  12202. break;
  12203. case "四":
  12204. str = "4";
  12205. break;
  12206. case "五":
  12207. str = "5";
  12208. break;
  12209. case "六":
  12210. str = "6";
  12211. break;
  12212. case "七":
  12213. str = "7";
  12214. break;
  12215. case "八":
  12216. str = "8";
  12217. break;
  12218. case "九":
  12219. str = "9";
  12220. break;
  12221. case "十":
  12222. str = "10";
  12223. break;
  12224. case "十一":
  12225. str = "11";
  12226. break;
  12227. case "十二":
  12228. str = "12";
  12229. break;
  12230. }
  12231. return str;
  12232. }
  12233. // 高亮包含指定文字的部分
  12234. void HighlightText(Run run, string targetText, Color color)
  12235. {
  12236. string text = run.Text;
  12237. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12238. if (startIndex >= 0)
  12239. {
  12240. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12241. // 前部分
  12242. if (startIndex > 0)
  12243. {
  12244. Run beforeRun = (Run)run.Clone(true);
  12245. beforeRun.Text = text.Substring(0, startIndex);
  12246. parentParagraph.InsertBefore(beforeRun, run);
  12247. }
  12248. // 匹配部分
  12249. Run matchRun = (Run)run.Clone(true);
  12250. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12251. matchRun.Font.Color = color;
  12252. parentParagraph.InsertBefore(matchRun, run);
  12253. // 后部分
  12254. if (startIndex + targetText.Length < text.Length)
  12255. {
  12256. Run afterRun = (Run)run.Clone(true);
  12257. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12258. parentParagraph.InsertBefore(afterRun, run);
  12259. }
  12260. // 删除原始Run
  12261. run.Remove();
  12262. }
  12263. }
  12264. #endregion
  12265. #endregion
  12266. #region 团组成本
  12267. /// <summary>
  12268. /// 团组成本数据初始化
  12269. /// </summary>
  12270. /// <param name="dto"></param>
  12271. /// <returns></returns>
  12272. [HttpPost]
  12273. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12274. {
  12275. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12276. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12277. WHEN COUNT(*) >= 0 THEN 'True'
  12278. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12279. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12280. ").ToList(); //团组列表
  12281. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12282. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12283. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12284. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12285. if (groupinfoValue != null)
  12286. {
  12287. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12288. var spArr = new string[1] { countryArr };
  12289. if (countryArr.Contains("|"))
  12290. {
  12291. spArr = countryArr.Split("|");
  12292. }
  12293. else if (countryArr.Contains("、"))
  12294. {
  12295. spArr = countryArr.Split("、");
  12296. }
  12297. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12298. {
  12299. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12300. if (dbQueryCountry != null)
  12301. {
  12302. visaCountryInfoArr.Add(dbQueryCountry);
  12303. }
  12304. }
  12305. }
  12306. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12307. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12308. var create = _GroupCostRepository.
  12309. CreateGroupCostByBlackCode(dto.Diid);
  12310. if (groupCost.Count == 0 && create.Code == 0)
  12311. {
  12312. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12313. }
  12314. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12315. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12316. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12317. groupCostMap = groupCostMap.Select(x =>
  12318. {
  12319. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12320. {
  12321. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12322. }
  12323. return x;
  12324. }).ToList();
  12325. //GroupCostParameter.Add(new
  12326. // Grp_GroupCostParameter());
  12327. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12328. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12329. return Ok(JsonView(new
  12330. {
  12331. groupList,
  12332. groupInfo,
  12333. groupChecks,
  12334. groupCost = groupCostMap,
  12335. hotelNumber,
  12336. GroupCostParameter = GroupCostParameterMap,
  12337. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12338. {
  12339. x.VisaCountry,
  12340. x.VisaPrice,
  12341. x.Id,
  12342. }).ToList(),
  12343. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12344. blackCodeIsTrue = create.Code == 0 ? true : false,
  12345. hotelIsTrue = hotelIsTrue,
  12346. }));
  12347. }
  12348. /// <summary>
  12349. /// 团组成本信息保存
  12350. /// </summary>
  12351. /// <param name="dto"></param>
  12352. /// <returns></returns>
  12353. [HttpPost]
  12354. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12355. {
  12356. if (dto.Diid <= 0 || dto.Userid <= 0)
  12357. {
  12358. return Ok(JsonView(false));
  12359. }
  12360. JsonView jw = null;
  12361. bool isTrue = false;
  12362. #region 复制团组成本
  12363. //if (dto.Diid == 2581)
  12364. //{
  12365. // dto.Diid = 2599;
  12366. // dto.CheckBoxs.ForEach(x =>
  12367. // {
  12368. // x.Diid = 2599;
  12369. // });
  12370. // dto.GroupCosts.ForEach(x =>
  12371. // {
  12372. // x.Diid = 2599;
  12373. // });
  12374. // dto.CostTypeHotelNumbers.ForEach(x =>
  12375. // {
  12376. // x.Diid = 2599;
  12377. // });
  12378. // dto.GroupCostParameters.ForEach(x =>
  12379. // {
  12380. // x.DiId = 2599;
  12381. // });
  12382. //}
  12383. #endregion
  12384. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12385. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12386. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12387. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12388. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12389. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12390. try
  12391. {
  12392. _sqlSugar.BeginTran();
  12393. isTrue = await _GroupCostRepository.
  12394. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12395. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12396. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12397. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12398. _sqlSugar.CommitTran();
  12399. jw = JsonView(true, "保存成功!", isTrue);
  12400. }
  12401. catch (Exception)
  12402. {
  12403. _sqlSugar.RollbackTran();
  12404. jw = JsonView(false);
  12405. }
  12406. return Ok(jw);
  12407. }
  12408. /// <summary>
  12409. /// 司兼导数据
  12410. /// </summary>
  12411. /// <param name="dto"></param>
  12412. /// <returns></returns>
  12413. [HttpPost]
  12414. public IActionResult GetCarGuides(CarGuidesDto dto)
  12415. {
  12416. JsonView jw = null;
  12417. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12418. jw = JsonView(true, "获取成功!", Data);
  12419. return Ok(jw);
  12420. }
  12421. /// <summary>
  12422. /// 导游数据
  12423. /// </summary>
  12424. /// <param name="dto"></param>
  12425. /// <returns></returns>
  12426. [HttpPost]
  12427. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12428. {
  12429. JsonView jw = null;
  12430. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12431. // 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
  12432. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12433. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12434. jw = JsonView(true, "获取成功!", Data);
  12435. return Ok(jw);
  12436. }
  12437. /// <summary>
  12438. /// 成本车数据
  12439. /// </summary>
  12440. /// <param name="dto"></param>
  12441. /// <returns></returns>
  12442. [HttpPost]
  12443. public IActionResult GetCarInfo(CarGuidesDto dto)
  12444. {
  12445. JsonView jw = null;
  12446. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12447. jw = JsonView(true, "获取成功!", Data);
  12448. return Ok(jw);
  12449. }
  12450. /// <summary>
  12451. /// 景点数据
  12452. /// </summary>
  12453. /// <param name="dto"></param>
  12454. /// <returns></returns>
  12455. [HttpPost]
  12456. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12457. {
  12458. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12459. return Ok(JsonView(true, "获取成功!", Data));
  12460. }
  12461. /// <summary>
  12462. /// 成本通知
  12463. /// </summary>
  12464. /// <param name="dto"></param>
  12465. /// <returns></returns>
  12466. [HttpPost]
  12467. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12468. {
  12469. if (dto.Diid < 0)
  12470. {
  12471. return Ok(JsonView(false));
  12472. }
  12473. JsonView jw = null;
  12474. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12475. if (GroupCostParameter != null)
  12476. {
  12477. int IsShare = 0;
  12478. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12479. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12480. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12481. string msg = string.Empty;
  12482. if (isTrue)
  12483. {
  12484. if (IsShare == 0)
  12485. {
  12486. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12487. }
  12488. else
  12489. {
  12490. #region 企微通知对应岗位用户
  12491. try
  12492. {
  12493. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12494. }
  12495. catch (Exception ex)
  12496. {
  12497. }
  12498. #endregion
  12499. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12500. }
  12501. jw = JsonView(isTrue, msg, new { IsShare });
  12502. }
  12503. else
  12504. {
  12505. msg = "修改失败!";
  12506. jw = JsonView(isTrue, msg);
  12507. }
  12508. }
  12509. else
  12510. {
  12511. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12512. }
  12513. return Ok(jw);
  12514. }
  12515. /// <summary>
  12516. /// 导出报价单
  12517. /// </summary>
  12518. /// <param name="dto"></param>
  12519. /// <returns></returns>
  12520. [HttpPost]
  12521. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12522. {
  12523. if (dto.Diid == 0)
  12524. {
  12525. return Ok(JsonView(false, "请传递团组id"));
  12526. }
  12527. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12528. if (deleInfo.Code != 0)
  12529. {
  12530. return Ok(JsonView(false, "团组信息查询失败!"));
  12531. }
  12532. var di = deleInfo.Data as DelegationInfoWebView;
  12533. if (di != null)
  12534. {
  12535. di.TeamName = di.TeamName.Replace("|", "、");
  12536. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12537. //文件名
  12538. string strFileName = di.TeamName + "-收款账单.doc";
  12539. //获取模板
  12540. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12541. //载入模板
  12542. Document doc = new Document(tmppath);
  12543. decimal TotalPrice = 0.00M;
  12544. string itemStr = string.Empty;
  12545. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12546. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12547. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12548. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12549. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12550. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12551. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12552. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12553. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12554. foreach (var cost in groupCostType)
  12555. {
  12556. var List = cost.ToList();
  12557. if (cost.Key == "A")
  12558. {
  12559. foreach (var ListItem in List)
  12560. {
  12561. if (ListItem.number > 0)
  12562. {
  12563. if (ListItem.code.Contains("TBR"))
  12564. {
  12565. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12566. }
  12567. else
  12568. {
  12569. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12570. }
  12571. TotalPrice += (ListItem.number * ListItem.price);
  12572. }
  12573. }
  12574. }
  12575. else
  12576. {
  12577. itemStr = itemStr.Insert(0, "A段\r\n");
  12578. itemStr += "B段\r\n";
  12579. foreach (var ListItem in List)
  12580. {
  12581. if (ListItem.number > 0)
  12582. {
  12583. if (ListItem.code.Contains("TBR"))
  12584. {
  12585. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12586. }
  12587. else
  12588. {
  12589. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12590. }
  12591. TotalPrice += (ListItem.number * ListItem.price);
  12592. }
  12593. }
  12594. }
  12595. }
  12596. #region 替换Word模板书签内容
  12597. Dictionary<string, string> marks = new Dictionary<string, string>();
  12598. marks.Add("To", di.ClientUnit);//付款方
  12599. marks.Add("ToTel", di.TellPhone);//付款方电话
  12600. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12601. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12602. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12603. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12604. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12605. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12606. marks.Add("PayItemContent", itemStr);//详细信息
  12607. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12608. #endregion
  12609. ////注
  12610. //if (doc.Range.Bookmarks["Attention"] != null)
  12611. //{
  12612. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12613. // mark.Text = frList[0].Attention;
  12614. //}
  12615. foreach (var item in marks.Keys)
  12616. {
  12617. if (doc.Range.Bookmarks[item] != null)
  12618. {
  12619. Bookmark mark = doc.Range.Bookmarks[item];
  12620. mark.Text = marks[item];
  12621. }
  12622. }
  12623. byte[] bytes = null;
  12624. using (MemoryStream stream = new MemoryStream())
  12625. {
  12626. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12627. bytes = stream.ToArray();
  12628. }
  12629. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12630. return Ok(JsonView(true, "", new
  12631. {
  12632. Data = bytes,
  12633. strFileName,
  12634. }));
  12635. }
  12636. else
  12637. {
  12638. return Ok(JsonView(false, "团组信息不存在!"));
  12639. }
  12640. }
  12641. /// <summary>
  12642. /// 导出团组成本
  12643. /// </summary>
  12644. /// <param name="dto"></param>
  12645. /// <returns></returns>
  12646. [HttpPost]
  12647. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12648. {
  12649. var jw = JsonView(false);
  12650. if (dto.Diid == 0)
  12651. {
  12652. return Ok(JsonView(false, "请传递团组id"));
  12653. }
  12654. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12655. if (deleInfo.Code != 0)
  12656. {
  12657. return Ok(JsonView(false, "团组信息查询失败!"));
  12658. }
  12659. var di = deleInfo.Data as DelegationInfoWebView;
  12660. if (di == null)
  12661. {
  12662. return Ok(JsonView(false, "团组信息查询失败!"));
  12663. }
  12664. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12665. WorkbookDesigner designer = new WorkbookDesigner();
  12666. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12667. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12668. for (int i = 0; i < List_GC.Count; i++)
  12669. {
  12670. GroupCost_Excel gc = new GroupCost_Excel();
  12671. gc.Id = List_GC[i].Id;
  12672. gc.Diid = List_GC[i].Diid.ToString();
  12673. gc.DAY = List_GC[i].DAY;
  12674. string week = "";
  12675. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12676. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12677. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12678. gc.ITIN = List_GC[i].ITIN;
  12679. gc.CarType = List_GC[i].CarType;
  12680. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12681. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12682. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12683. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12684. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12685. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12686. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12687. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12688. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12689. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12690. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12691. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12692. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12693. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12694. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12695. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12696. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12697. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12698. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12699. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12700. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12701. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12702. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12703. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12704. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12705. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12706. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12707. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12708. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12709. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12710. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12711. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12712. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12713. List_GC1.Add(gc);
  12714. }
  12715. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12716. dt.TableName = "TB";
  12717. //报表标题等不用dt的值
  12718. designer.SetDataSource("TeamName", dto.title.TeamName);
  12719. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12720. designer.SetDataSource("Tax", dto.title.Tax);
  12721. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12722. designer.SetDataSource("Currency", dto.title.Currency);
  12723. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12724. designer.SetDataSource("Rate", dto.title.Rate);
  12725. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12726. var Aparams = hotels.Find(x => x.Type == "Default");
  12727. if (Aparams == null)
  12728. {
  12729. return Ok(jw);
  12730. }
  12731. //酒店数量
  12732. var txtSGRNumber = Aparams.SGR.ToString();
  12733. var txtTBRNumber = Aparams.TBR.ToString();
  12734. var txtJSESNumber = Aparams.JSES.ToString();
  12735. var txtSUITENumbe = Aparams.SUITE.ToString();
  12736. if (dto.costType == "B")
  12737. {
  12738. Aparams = hotels.Find(x => x.Type == "A");
  12739. var Bparams = hotels.Find(x => x.Type == "B");
  12740. if (Aparams == null || Bparams == null)
  12741. {
  12742. return Ok(jw);
  12743. }
  12744. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12745. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12746. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12747. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12748. }
  12749. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12750. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12751. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12752. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12753. var ws = designer.Workbook.Worksheets[0];
  12754. int Row = List_GC.Count;
  12755. int startIndex = 11;
  12756. int HideRows = 0;
  12757. List<int> hideRowsList = new List<int>();
  12758. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12759. #region A段left数据
  12760. var left = dto.leftInfo.Find(x => x.Type == "A");
  12761. if (left == null)
  12762. {
  12763. return Ok(jw);
  12764. }
  12765. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12766. if (leftBindData != null)
  12767. {
  12768. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12769. designer.SetDataSource("VisaRS", leftBindData.rs);
  12770. designer.SetDataSource("VisaXS", leftBindData.xs);
  12771. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12772. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12773. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12774. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12775. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12776. }
  12777. else
  12778. {
  12779. hideRowsList.Add(Row + startIndex + HideRows);
  12780. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12781. }
  12782. HideRows += 2;
  12783. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12784. if (leftBindData != null)
  12785. {
  12786. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12787. designer.SetDataSource("BXRS", leftBindData.rs);
  12788. designer.SetDataSource("BXXS", leftBindData.xs);
  12789. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12790. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12791. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12792. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12793. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12794. }
  12795. else
  12796. {
  12797. hideRowsList.Add(Row + startIndex + HideRows);
  12798. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12799. }
  12800. HideRows += 2;
  12801. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12802. if (leftBindData != null)
  12803. {
  12804. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12805. designer.SetDataSource("HSRS", leftBindData.rs);
  12806. designer.SetDataSource("HSXS", leftBindData.xs);
  12807. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12808. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12809. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12811. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12812. }
  12813. else
  12814. {
  12815. hideRowsList.Add(Row + startIndex + HideRows);
  12816. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12817. }
  12818. HideRows += 2;
  12819. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12820. if (leftBindData != null)
  12821. {
  12822. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12823. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12824. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12825. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12826. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12827. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12828. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12829. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12830. }
  12831. else
  12832. {
  12833. hideRowsList.Add(Row + startIndex + HideRows);
  12834. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12835. }
  12836. HideRows += 2;
  12837. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12838. if (leftBindData != null)
  12839. {
  12840. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12841. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12842. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12843. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12844. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12845. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12846. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12847. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12848. }
  12849. else
  12850. {
  12851. hideRowsList.Add(Row + startIndex + HideRows);
  12852. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12853. }
  12854. HideRows += 2;
  12855. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12856. if (leftBindData != null)
  12857. {
  12858. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12859. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12860. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12861. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12862. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12863. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12864. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12865. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12866. }
  12867. else
  12868. {
  12869. hideRowsList.Add(Row + startIndex + HideRows);
  12870. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12871. }
  12872. HideRows += 2;
  12873. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12874. if (leftBindData != null)
  12875. {
  12876. ////TBR
  12877. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12878. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12879. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12880. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12881. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12882. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12883. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12884. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12885. }
  12886. else
  12887. {
  12888. hideRowsList.Add(Row + startIndex + HideRows);
  12889. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12890. }
  12891. HideRows += 2;
  12892. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12893. if (leftBindData != null)
  12894. {
  12895. ////SGR
  12896. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12897. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12898. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12899. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12900. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12901. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12902. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12903. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12904. }
  12905. else
  12906. {
  12907. hideRowsList.Add(Row + startIndex + HideRows);
  12908. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12909. }
  12910. HideRows += 2;
  12911. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12912. if (leftBindData != null)
  12913. {
  12914. ////JS/ES
  12915. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12916. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12917. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12918. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12919. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12920. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12921. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12922. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12923. }
  12924. else
  12925. {
  12926. hideRowsList.Add(Row + startIndex + HideRows);
  12927. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12928. }
  12929. HideRows += 2;
  12930. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12931. if (leftBindData != null)
  12932. {
  12933. ////SUITE
  12934. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12935. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12936. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12937. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12938. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12939. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12940. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12941. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12942. }
  12943. else
  12944. {
  12945. hideRowsList.Add(Row + startIndex + HideRows);
  12946. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12947. }
  12948. HideRows += 2;
  12949. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12950. if (leftBindData != null)
  12951. {
  12952. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12953. designer.SetDataSource("DJRS", leftBindData.rs);
  12954. designer.SetDataSource("DJXS", leftBindData.xs);
  12955. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12956. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12957. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12958. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12959. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12960. }
  12961. else
  12962. {
  12963. hideRowsList.Add(Row + startIndex + HideRows);
  12964. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12965. }
  12966. HideRows += 2;
  12967. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12968. if (leftBindData != null)
  12969. {
  12970. designer.SetDataSource("HCPCB", leftBindData.cb);
  12971. designer.SetDataSource("HCPRS", leftBindData.rs);
  12972. designer.SetDataSource("HCPXS", leftBindData.xs);
  12973. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12974. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12975. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12976. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12977. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12978. }
  12979. else
  12980. {
  12981. hideRowsList.Add(Row + startIndex + HideRows);
  12982. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12983. }
  12984. HideRows += 2;
  12985. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12986. if (leftBindData != null)
  12987. {
  12988. designer.SetDataSource("CPCB", leftBindData.cb);
  12989. designer.SetDataSource("CPRS", leftBindData.rs);
  12990. designer.SetDataSource("CPXS", leftBindData.xs);
  12991. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12992. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12993. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12994. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12995. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12996. }
  12997. else
  12998. {
  12999. hideRowsList.Add(Row + startIndex + HideRows);
  13000. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13001. }
  13002. HideRows += 2;
  13003. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13004. if (leftBindData != null)
  13005. {
  13006. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13007. designer.SetDataSource("GWRS", leftBindData.rs);
  13008. designer.SetDataSource("GWXS", leftBindData.xs);
  13009. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13010. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13011. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13012. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13013. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13014. }
  13015. else
  13016. {
  13017. hideRowsList.Add(Row + startIndex + HideRows);
  13018. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13019. }
  13020. HideRows += 2;
  13021. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13022. if (leftBindData != null)
  13023. {
  13024. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13025. designer.SetDataSource("LYJRS", leftBindData.rs);
  13026. designer.SetDataSource("LYJXS", leftBindData.xs);
  13027. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13028. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13029. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13030. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13031. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13032. }
  13033. else
  13034. {
  13035. hideRowsList.Add(Row + startIndex + HideRows);
  13036. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13037. }
  13038. #endregion
  13039. #region A段Right信息
  13040. var right = dto.rightInfo.Find(x => x.Type == "A");
  13041. if (right == null)
  13042. {
  13043. return Ok(jw);
  13044. }
  13045. HideRows += 4;
  13046. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13047. if (rightBindData != null)
  13048. {
  13049. //经济舱 + 双人间 TBR
  13050. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13051. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13052. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13053. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13054. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13055. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13056. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13057. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13058. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13059. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13060. }
  13061. else
  13062. {
  13063. hideRowsList.Add(Row + startIndex + HideRows);
  13064. }
  13065. HideRows += 2;
  13066. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13067. if (rightBindData != null)
  13068. {
  13069. //经济舱 + 单人间 SGR
  13070. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13071. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13072. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13073. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13074. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13075. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13076. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13077. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13078. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13079. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13080. }
  13081. else
  13082. {
  13083. hideRowsList.Add(Row + startIndex + HideRows);
  13084. }
  13085. HideRows += 2;
  13086. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13087. if (rightBindData != null)
  13088. {
  13089. //公务舱 + 单人间 SGR
  13090. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13091. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13092. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13093. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13094. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13095. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13096. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13097. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13098. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13099. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13100. }
  13101. else
  13102. {
  13103. hideRowsList.Add(Row + startIndex + HideRows);
  13104. }
  13105. HideRows += 2;
  13106. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13107. if (rightBindData != null)
  13108. {
  13109. //公务舱 + 小套房 JSES
  13110. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13111. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13112. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13113. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13114. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13115. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13116. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13117. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13118. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13119. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13120. }
  13121. else
  13122. {
  13123. hideRowsList.Add(Row + startIndex + HideRows);
  13124. }
  13125. HideRows += 2;
  13126. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13127. if (rightBindData != null)
  13128. {
  13129. //公务舱 + 小套房 JSES
  13130. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13131. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13132. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13133. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13134. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13135. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13136. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13137. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13138. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13139. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13140. }
  13141. else
  13142. {
  13143. hideRowsList.Add(Row + startIndex + HideRows);
  13144. }
  13145. HideRows += 2;
  13146. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13147. if (rightBindData != null)
  13148. {
  13149. //经济舱 + 大套房
  13150. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13151. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13152. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13153. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13154. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13155. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13156. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13157. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13158. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13159. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13160. }
  13161. else
  13162. {
  13163. hideRowsList.Add(Row + startIndex + HideRows);
  13164. }
  13165. HideRows += 2;
  13166. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13167. if (rightBindData != null)
  13168. {
  13169. //头等舱 + 小套房 JSES
  13170. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13171. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13172. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13173. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13174. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13175. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13176. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13177. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13178. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13179. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13180. }
  13181. else
  13182. {
  13183. hideRowsList.Add(Row + startIndex + HideRows);
  13184. }
  13185. HideRows += 2;
  13186. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13187. if (rightBindData != null)
  13188. {
  13189. //头等舱 + 大套房
  13190. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13191. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13192. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13193. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13194. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13195. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13196. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13197. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13198. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13199. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13200. }
  13201. else
  13202. {
  13203. hideRowsList.Add(Row + startIndex + HideRows);
  13204. }
  13205. #endregion
  13206. #region B段标题清空
  13207. designer.SetDataSource("CostBDRCB", "");
  13208. designer.SetDataSource("CostBRS", "");
  13209. designer.SetDataSource("CostBXS", "");
  13210. designer.SetDataSource("CostBZCB", "");
  13211. designer.SetDataSource("CostBDRBJ", "");
  13212. designer.SetDataSource("CostBZBJ", "");
  13213. designer.SetDataSource("CostBDRLR", "");
  13214. designer.SetDataSource("CostBZLR", "");
  13215. designer.SetDataSource("CostBDRCBOM", "");
  13216. designer.SetDataSource("CostBRSOM", "");
  13217. designer.SetDataSource("CostBZCBOM", "");
  13218. designer.SetDataSource("CostBDRBJOM", "");
  13219. designer.SetDataSource("CostBZBJOM", "");
  13220. designer.SetDataSource("CostBDRLROM", "");
  13221. designer.SetDataSource("CostBZLROM", "");
  13222. #endregion
  13223. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13224. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13225. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13226. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13227. designer.SetDataSource("DJName", "地接(CNY)");
  13228. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13229. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13230. designer.SetDataSource("GWName", "公务(CNY)");
  13231. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13232. designer.SetDataSource("LYJName", "零用金(CNY)");
  13233. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13234. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13235. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13236. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13237. designer.SetDataSource("BXName", "保险(CNY)");
  13238. designer.SetDataSource("VisaName", "签证(CNY)");
  13239. #region B段基本数据
  13240. if (dto.costType == "B")
  13241. {
  13242. left = dto.leftInfo.Find(x => x.Type == "B");
  13243. if (left == null)
  13244. {
  13245. return Ok(jw);
  13246. }
  13247. #region B段left数据
  13248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13249. if (leftBindData != null)
  13250. {
  13251. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13252. designer.SetDataSource("BHSRS", leftBindData.rs);
  13253. designer.SetDataSource("BHSXS", leftBindData.xs);
  13254. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13255. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13256. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13257. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13258. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13259. }
  13260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13261. if (leftBindData != null)
  13262. {
  13263. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13264. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13265. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13266. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13267. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13268. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13269. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13270. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13271. }
  13272. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13273. if (leftBindData != null)
  13274. {
  13275. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13276. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13277. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13278. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13279. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13280. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13281. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13282. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13283. }
  13284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13285. if (leftBindData != null)
  13286. {
  13287. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13288. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13289. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13290. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13291. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13292. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13293. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13294. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13295. }
  13296. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13297. if (leftBindData != null)
  13298. {
  13299. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13300. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13301. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13302. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13303. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13304. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13305. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13306. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13307. }
  13308. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13309. if (leftBindData != null)
  13310. {
  13311. designer.SetDataSource("BCPCB", leftBindData.cb);
  13312. designer.SetDataSource("BCPRS", leftBindData.rs);
  13313. designer.SetDataSource("BCPXS", leftBindData.xs);
  13314. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13315. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13316. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13317. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13318. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13319. }
  13320. //TBR
  13321. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13322. if (leftBindData != null)
  13323. {
  13324. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13325. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13326. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13327. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13328. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13329. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13330. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13331. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13332. }
  13333. //SGR
  13334. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13335. if (leftBindData != null)
  13336. {
  13337. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13338. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13339. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13340. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13341. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13342. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13343. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13344. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13345. }
  13346. //JS/ES
  13347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13348. if (leftBindData != null)
  13349. {
  13350. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13351. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13352. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13353. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13354. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13355. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13356. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13357. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13358. }
  13359. //SUITE
  13360. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13361. if (leftBindData != null)
  13362. {
  13363. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13364. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13365. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13366. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13367. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13368. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13369. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13370. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13371. }
  13372. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13373. if (leftBindData != null)
  13374. {
  13375. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13376. designer.SetDataSource("BDJRS", leftBindData.rs);
  13377. designer.SetDataSource("BDJXS", leftBindData.xs);
  13378. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13379. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13380. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13381. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13382. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13383. }
  13384. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13385. if (leftBindData != null)
  13386. {
  13387. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13388. designer.SetDataSource("BGWRS", leftBindData.rs);
  13389. designer.SetDataSource("BGWXS", leftBindData.xs);
  13390. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13391. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13392. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13393. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13394. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13395. }
  13396. #region 优化方案
  13397. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13398. //excelBind.Add("零用金", new {
  13399. //cb="",
  13400. //rs="",
  13401. //xs ="",
  13402. //zcb = "",
  13403. //});
  13404. #endregion
  13405. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13406. if (leftBindData != null)
  13407. {
  13408. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13409. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13410. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13411. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13412. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13413. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13414. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13415. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13416. }
  13417. #endregion
  13418. #region B段Right信息
  13419. right = dto.rightInfo.Find(x => x.Type == "B");
  13420. if (right == null)
  13421. {
  13422. return Ok(jw);
  13423. }
  13424. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13425. if (rightBindData != null)
  13426. {
  13427. //经济舱 + 双人间 TBR
  13428. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13429. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13430. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13431. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13432. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13433. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13434. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13435. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13436. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13437. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13438. }
  13439. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13440. if (rightBindData != null)
  13441. {
  13442. //经济舱 + 单人间 SGR
  13443. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13444. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13445. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13446. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13447. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13448. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13449. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13450. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13451. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13452. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13453. }
  13454. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13455. if (rightBindData != null)
  13456. {
  13457. //公务舱 + 单人间 SGR
  13458. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13459. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13460. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13461. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13462. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13463. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13464. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13465. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13466. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13467. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13468. }
  13469. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13470. if (rightBindData != null)
  13471. {
  13472. //公务舱 + 小套房 JSES
  13473. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13474. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13475. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13476. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13477. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13478. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13479. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13480. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13481. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13482. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13483. }
  13484. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13485. if (rightBindData != null)
  13486. {
  13487. //公务舱 + 小套房 JSES
  13488. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13489. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13490. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13491. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13492. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13493. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13494. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13495. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13496. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13497. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13498. }
  13499. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13500. if (rightBindData != null)
  13501. {
  13502. //经济舱 + 大套房
  13503. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13504. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13505. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13506. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13507. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13508. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13509. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13510. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13511. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13512. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13513. }
  13514. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13515. if (rightBindData != null)
  13516. {
  13517. //头等舱 + 小套房 JSES
  13518. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13519. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13520. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13521. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13522. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13523. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13524. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13525. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13526. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13527. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13528. }
  13529. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13530. if (rightBindData != null)
  13531. {
  13532. //头等舱 + 大套房
  13533. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13534. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13535. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13536. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13537. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13538. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13539. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13540. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13541. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13542. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13543. }
  13544. #endregion
  13545. #region 标题
  13546. designer.SetDataSource("CostBDRCB", "单人成本");
  13547. designer.SetDataSource("CostBRS", "人数");
  13548. designer.SetDataSource("CostBXS", "系数");
  13549. designer.SetDataSource("CostBZCB", "总成本");
  13550. designer.SetDataSource("CostBDRBJ", "单人报价");
  13551. designer.SetDataSource("CostBZBJ", "总报价");
  13552. designer.SetDataSource("CostBDRLR", "单人利润");
  13553. designer.SetDataSource("CostBZLR", "总利润");
  13554. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13555. designer.SetDataSource("CostBRSOM", "人数");
  13556. designer.SetDataSource("CostBZCBOM", "总成本");
  13557. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13558. designer.SetDataSource("CostBZBJOM", "总报价");
  13559. designer.SetDataSource("CostBDRLROM", "单人利润");
  13560. designer.SetDataSource("CostBZLROM", "总利润");
  13561. #endregion
  13562. }
  13563. #endregion
  13564. designer.SetDataSource("TzZCB2", TzZCB2);
  13565. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13566. designer.SetDataSource("TzZLR2", TzZLR2);
  13567. string[] dataSourceKeys = new string[]
  13568. {
  13569. "VF",
  13570. "TGS",
  13571. "TGOF",
  13572. "TGM",
  13573. "TGA",
  13574. "TGTF",
  13575. "TGEF",
  13576. "CFM",
  13577. "CFOF",
  13578. "B",
  13579. "L",
  13580. "D",
  13581. "TBR",
  13582. "SGR",
  13583. "JSES",
  13584. "Suite",
  13585. "TV",
  13586. "1L",
  13587. "IF",
  13588. "EF",
  13589. "BRF",
  13590. "TE",
  13591. "TGT",
  13592. "DRVT",
  13593. "PC",
  13594. "TLF",
  13595. "ECT"
  13596. };
  13597. foreach (var item in dataSourceKeys)
  13598. {
  13599. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13600. if (find != null)
  13601. {
  13602. designer.SetDataSource(item, find.text);
  13603. }
  13604. else
  13605. {
  13606. designer.SetDataSource(item, 0);
  13607. }
  13608. }
  13609. designer.SetDataSource(dt);
  13610. //根据数据源处理生成报表内容
  13611. designer.Process();
  13612. designer.Workbook.Worksheets[0].Name = "清单";
  13613. Worksheet sheet = designer.Workbook.Worksheets[0];
  13614. foreach (var Rowindex in hideRowsList)
  13615. {
  13616. ws.Cells.HideRows(Rowindex, 2);
  13617. }
  13618. byte[] bytes = null;
  13619. string strFileName = di.TeamName + "-团组-成本.xls";
  13620. using (MemoryStream stream = new MemoryStream())
  13621. {
  13622. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13623. bytes = stream.ToArray();
  13624. }
  13625. return Ok(JsonView(true, "", new
  13626. {
  13627. Data = bytes,
  13628. strFileName,
  13629. }));
  13630. }
  13631. /// <summary>
  13632. /// 导出客户报表
  13633. /// </summary>
  13634. /// <returns></returns>
  13635. [HttpPost]
  13636. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13637. {
  13638. var jw = JsonView(false);
  13639. if (dto.Diid == 0)
  13640. {
  13641. return Ok(JsonView(false, "请传递团组id"));
  13642. }
  13643. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13644. if (deleInfo.Code != 0)
  13645. {
  13646. return Ok(JsonView(false, "团组信息查询失败!"));
  13647. }
  13648. var di = deleInfo.Data as DelegationInfoWebView;
  13649. if (di == null)
  13650. {
  13651. return Ok(JsonView(false, "团组信息查询失败!"));
  13652. }
  13653. //文件名
  13654. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13655. //获取模板
  13656. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13657. //载入模板
  13658. Document doc = new Document(tmppath);
  13659. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13660. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13661. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13662. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13663. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13664. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13665. if (AParameter == null)
  13666. {
  13667. return Ok(JsonView(false, "系数不存在!"));
  13668. }
  13669. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13670. , TzAirDesc, TzZCost;
  13671. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13672. = TzAirDesc = TzZCost = string.Empty;
  13673. TzNumber = AParameter.CostTypenumber.ToString();
  13674. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13675. CarGuides1 = dto.CarGuides1;
  13676. Meal = dto.Meal;
  13677. SubsidizedMeals = dto.SubsidizedMeals;
  13678. NightRepair = dto.NightRepair;
  13679. AttractionsTickets = dto.AttractionsTickets;
  13680. MiscellaneousFees = dto.MiscellaneousFees;
  13681. ATip = dto.ATip;
  13682. TzHotelDesc = "";
  13683. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13684. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13685. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13686. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13687. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13688. TzAirDesc = "";
  13689. TzZCost = dto.TzZCost;
  13690. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13691. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13692. var index = 1;
  13693. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13694. foreach (var item in TzHotelDescArr)
  13695. {
  13696. if (AinfoArr != null)
  13697. {
  13698. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13699. if (Ainfo != null)
  13700. {
  13701. if (int.Parse(Ainfo.rs) <= 0)
  13702. {
  13703. continue;
  13704. }
  13705. var hotelText = string.Empty;
  13706. switch (item)
  13707. {
  13708. case "SGR":
  13709. hotelText = "单人间";
  13710. break;
  13711. case "JSES":
  13712. hotelText = "小套房";
  13713. break;
  13714. case "SUITE":
  13715. hotelText = "套房";
  13716. break;
  13717. case "TBR":
  13718. hotelText = "双人间";
  13719. break;
  13720. }
  13721. if (item != "TBR")
  13722. {
  13723. 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";
  13724. }
  13725. else
  13726. {
  13727. 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";
  13728. }
  13729. index++;
  13730. }
  13731. }
  13732. }
  13733. index = 1;
  13734. foreach (var item in TzAirDescArr)
  13735. {
  13736. if (AinfoArr != null)
  13737. {
  13738. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13739. if (Ainfo != null)
  13740. {
  13741. if (int.Parse(Ainfo.rs) <= 0)
  13742. {
  13743. continue;
  13744. }
  13745. 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";
  13746. index++;
  13747. }
  13748. }
  13749. }
  13750. if (dto.costType == "B")
  13751. {
  13752. if (BParameter == null)
  13753. {
  13754. return Ok(JsonView(false, "B段系数不存在!"));
  13755. }
  13756. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13757. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13758. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13759. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13760. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13761. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13762. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13763. foreach (var item in TzHotelDescArr)
  13764. {
  13765. if (AinfoArr != null)
  13766. {
  13767. TzHotelDesc += "B段信息 \r\n";
  13768. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13769. if (Ainfo != null)
  13770. {
  13771. if (int.Parse(Ainfo.rs) <= 0)
  13772. {
  13773. continue;
  13774. }
  13775. var hotelText = string.Empty;
  13776. switch (item)
  13777. {
  13778. case "SGR":
  13779. hotelText = "单人间";
  13780. break;
  13781. case "JSES":
  13782. hotelText = "小套房";
  13783. break;
  13784. case "SUITE":
  13785. hotelText = "套房";
  13786. break;
  13787. case "TBR":
  13788. hotelText = "双人间";
  13789. break;
  13790. }
  13791. if (item != "TBR")
  13792. {
  13793. 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";
  13794. }
  13795. else
  13796. {
  13797. 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";
  13798. }
  13799. index++;
  13800. }
  13801. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13802. }
  13803. }
  13804. index = 1;
  13805. foreach (var item in TzAirDescArr)
  13806. {
  13807. if (AinfoArr != null)
  13808. {
  13809. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13810. if (Ainfo != null)
  13811. {
  13812. if (int.Parse(Ainfo.rs) <= 0)
  13813. {
  13814. continue;
  13815. }
  13816. 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";
  13817. index++;
  13818. }
  13819. }
  13820. }
  13821. }
  13822. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13823. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13824. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13825. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13826. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13827. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13828. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13829. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13830. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13831. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13832. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13833. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13834. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13835. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13836. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13837. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13838. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13839. DickeyValue.Add("TzZCost", TzZCost);
  13840. foreach (var key in DickeyValue.Keys)
  13841. {
  13842. if (doc.Range.Bookmarks[key] != null)
  13843. {
  13844. Bookmark mark = doc.Range.Bookmarks[key];
  13845. mark.Text = DickeyValue[key];
  13846. }
  13847. }
  13848. byte[] bytes = null;
  13849. string strFileName = di.TeamName + "-客户报价.doc";
  13850. using (MemoryStream stream = new MemoryStream())
  13851. {
  13852. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13853. bytes = stream.ToArray();
  13854. }
  13855. return Ok(JsonView(true, "", new
  13856. {
  13857. Data = bytes,
  13858. strFileName,
  13859. }));
  13860. }
  13861. /// <summary>
  13862. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13863. /// </summary>
  13864. /// <param name="dto"></param>
  13865. /// <returns></returns>
  13866. [HttpPost]
  13867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13868. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13869. {
  13870. try
  13871. {
  13872. #region 参数验证
  13873. if (dto.DiId < 0)
  13874. {
  13875. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13876. }
  13877. List<int> cTableIds = new List<int>() {
  13878. 76 ,//酒店预订
  13879. 77 ,//行程
  13880. 79 ,//车/导游地接
  13881. 80 ,//签证
  13882. 81 ,//邀请/公务活
  13883. 82 ,//团组客户保险
  13884. 85 ,//机票预订
  13885. 98 ,//其他款项
  13886. 285 ,//收款退还
  13887. 751 ,//酒店早餐
  13888. 1015 // 超支费用
  13889. };
  13890. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13891. {
  13892. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13893. }
  13894. #endregion
  13895. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13896. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13897. if (_GroupCostParameters.Count <= 0)
  13898. {
  13899. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13900. }
  13901. if (_GroupCostParameters[0].IsShare == 0)
  13902. {
  13903. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13904. }
  13905. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13906. //处理date为空问题
  13907. if (_GroupCosts.Count > 0)
  13908. {
  13909. for (int i = 0; i < _GroupCosts.Count; i++)
  13910. {
  13911. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13912. {
  13913. if (i > 0)
  13914. {
  13915. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13916. }
  13917. }
  13918. }
  13919. }
  13920. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13921. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13922. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13923. string currCode = "";
  13924. #region currCode 验证
  13925. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13926. if (isInt)
  13927. {
  13928. var currData = currDatas.Find(it => it.Id == intCurrency);
  13929. if (currData != null)
  13930. {
  13931. currCode = currData.Name;
  13932. }
  13933. }
  13934. else
  13935. {
  13936. currCode = _GroupCostParameters[0].Currency.Trim();
  13937. }
  13938. #endregion
  13939. //op,酒店单段模式存储
  13940. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13941. {
  13942. CurrencyCode = currCode,
  13943. Rate = _GroupCostParameters[0].Rate,
  13944. CostType = _GroupCostParameters[0].CostType,
  13945. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13946. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13947. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13948. };
  13949. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13950. if (_GroupCostParameters.Count == 2)
  13951. {
  13952. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13953. }
  13954. foreach (var item in _GroupCostParameters)
  13955. {
  13956. decimal _rate = 1;
  13957. decimal _rate1 = item.Rate;
  13958. decimal _scale = 1;
  13959. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13960. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13961. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13962. //if (userInfo != null)
  13963. //{
  13964. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13965. // {
  13966. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13967. // {
  13968. // _scale = 1.00M;
  13969. // }
  13970. // }
  13971. //}
  13972. #endregion
  13973. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13974. {
  13975. CurrencyCode = currCode,
  13976. Rate = _rate1,
  13977. CostType = item.CostType,
  13978. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13979. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13980. CostTypeNumber = item.CostTypenumber
  13981. };
  13982. if (_GroupCostParameters.Count > 1)
  13983. {
  13984. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13985. }
  13986. else
  13987. {
  13988. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13989. }
  13990. if (dto.CTable == 79)//
  13991. {
  13992. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13993. modulePromptInfo.TotalCost = item.DJCB;
  13994. }
  13995. List<string> costTypes = new List<string>() { "A", "B" };
  13996. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13997. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13998. if (_GroupCostsDuplicates.Count() == 1)
  13999. {
  14000. _GroupCostsTypeData = _GroupCosts;
  14001. }
  14002. else
  14003. {
  14004. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14005. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14006. }
  14007. /*
  14008. * 76 酒店预订
  14009. * 77 行程
  14010. * 79 车/导游地接
  14011. * 80 签证
  14012. * 81 邀请/公务活动
  14013. * 82 团组客户保险
  14014. * 85 机票预订
  14015. * 98 其他款项
  14016. * 285 收款退还
  14017. * 751 酒店早餐
  14018. * 1015 超支费用
  14019. */
  14020. switch (dto.CTable)
  14021. {
  14022. case 76: // 酒店预订
  14023. _ModuleSubPromptInfo.AddRange(
  14024. _GroupCostsTypeData.Select(it => new
  14025. {
  14026. it.DAY,
  14027. it.Date,
  14028. it.ACCON,
  14029. it.ITIN,
  14030. it.SGR,
  14031. it.TBR,
  14032. it.JS_ES,
  14033. it.Suite
  14034. })
  14035. );
  14036. break;
  14037. case 79: // 车/导游地接
  14038. _ModuleSubPromptInfo.AddRange(
  14039. _GroupCostsTypeData.Select(it => new
  14040. {
  14041. Date = it.Date, //日期
  14042. CarFee = it.CarCost * _rate * _scale, //车费用
  14043. CarType = it.CarType, //车型
  14044. DriverFee = it.CFS * _rate * _scale, //司机工资
  14045. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14046. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14047. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14048. GuideFee = it.TGS * _rate * _scale, //导游费用
  14049. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14050. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14051. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14052. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14053. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14054. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14055. Breakfast = it.B * _rate * _scale, //早餐费
  14056. Lunch = it.L * _rate * _scale, //午餐费
  14057. Dinner = it.D * _rate * _scale, //晚餐费
  14058. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14059. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14060. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14061. TicketFee = it.EF * _rate * _scale, //门票费
  14062. TicketRemark = it.EFR, //门票费描述
  14063. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14064. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14065. SpentCash = it.PC * _rate * _scale, //零用金
  14066. LeadersFee = it.TLF * _rate * _scale, //领队费
  14067. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14068. })
  14069. );
  14070. break;
  14071. case 85: // 机票
  14072. List<dynamic> datas = new List<dynamic>();
  14073. datas.Add(
  14074. new
  14075. {
  14076. AirType = "经济舱",
  14077. AirNum = item.JJCRS,
  14078. AirDRCB = item.JJCCB,
  14079. AirZCB = (item.JJCRS * item.JJCCB)
  14080. }
  14081. );
  14082. datas.Add(
  14083. new
  14084. {
  14085. AirType = "公务舱",
  14086. AirNum = item.GWCRS,
  14087. AirDRCB = item.GWCCB,
  14088. AirZCB = (item.GWCRS * item.GWCCB)
  14089. }
  14090. );
  14091. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14092. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14093. modulePromptInfo.Data = new
  14094. {
  14095. airFeeData = datas,
  14096. airInitData = initDatas
  14097. };
  14098. _ModulePromptInfos.Add(modulePromptInfo);
  14099. break;
  14100. default:
  14101. break;
  14102. }
  14103. }
  14104. if (dto.CTable != 85)
  14105. {
  14106. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14107. _ModulePromptInfos.Add(_ModulePromptInfo);
  14108. }
  14109. _view.ModulePromptInfos = _ModulePromptInfos;
  14110. return Ok(JsonView(true, "操作成功!", _view));
  14111. }
  14112. catch (Exception ex)
  14113. {
  14114. return Ok(JsonView(false, ex.Message));
  14115. }
  14116. }
  14117. /// <summary>
  14118. /// 根据黑屏代码重新生成行程
  14119. /// </summary>
  14120. /// <param name="dto"></param>
  14121. /// <returns></returns>
  14122. [HttpPost]
  14123. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14124. {
  14125. var jw = JsonView(false);
  14126. var Create = _GroupCostRepository.
  14127. CreateGroupCostByBlackCode(dto.Diid);
  14128. jw.Msg = Create.Msg;
  14129. if (Create.Code == 0)
  14130. {
  14131. jw.Code = 200;
  14132. jw.Data = new
  14133. {
  14134. groupCost = Create.Data,
  14135. blackCodeIsTrue = true
  14136. };
  14137. }
  14138. else
  14139. {
  14140. jw.Code = 400;
  14141. jw.Data = new
  14142. {
  14143. groupCost = Create.Data,
  14144. blackCodeIsTrue = false,
  14145. };
  14146. }
  14147. return Ok(jw);
  14148. }
  14149. /// <summary>
  14150. /// 成本获取OP历史车费用
  14151. /// </summary>
  14152. /// <param name="dto"></param>
  14153. /// <returns></returns>
  14154. [HttpPost]
  14155. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14156. {
  14157. var jw = JsonView(false);
  14158. try
  14159. {
  14160. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14161. //获取现有所有车的数据
  14162. if (!dto.Param.IsNullOrWhiteSpace())
  14163. {
  14164. string sql = $@"
  14165. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14166. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14167. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14168. 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
  14169. AND gctggr.ServiceEndTime is not NULL
  14170. ORDER by gctggrc.id DESC
  14171. ";
  14172. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14173. var numeberResult = await Task.Run(() =>
  14174. {
  14175. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14176. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14177. return numberArr;
  14178. });
  14179. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14180. foreach (var item in numeberResult)
  14181. {
  14182. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14183. {
  14184. Country = "数据异常!",
  14185. City = string.Empty,
  14186. };
  14187. item.Area = find.Country + " " + find.City;
  14188. }
  14189. dbResult.AddRange(numeberResult);
  14190. if (dto.Param.Contains("、"))
  14191. {
  14192. var sp = dto.Param.Split("、");
  14193. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14194. .Where(x =>
  14195. {
  14196. return System.Array.Exists(sp, e =>
  14197. {
  14198. bool where = false;
  14199. if (x.Area != null)
  14200. {
  14201. where = x.Area.Contains(e);
  14202. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14203. {
  14204. return false;
  14205. }
  14206. }
  14207. if (x.PriceName != null && !where)
  14208. {
  14209. where = x.PriceName.Contains(e);
  14210. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14211. {
  14212. return false;
  14213. }
  14214. }
  14215. return where;
  14216. });
  14217. }).ToList();
  14218. }
  14219. else
  14220. {
  14221. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14222. .Where(x =>
  14223. {
  14224. bool where = false;
  14225. if (x.Area != null)
  14226. {
  14227. where = x.Area.Contains(dto.Param);
  14228. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14229. {
  14230. return false;
  14231. }
  14232. }
  14233. if (x.PriceName != null && !where)
  14234. {
  14235. where = x.PriceName.Contains(dto.Param);
  14236. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14237. {
  14238. return false;
  14239. }
  14240. }
  14241. return where;
  14242. }
  14243. )
  14244. .ToList();
  14245. }
  14246. }
  14247. var view = dbResult.Select(x =>
  14248. {
  14249. decimal dp = 0.00M;
  14250. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14251. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14252. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14253. {
  14254. if (startB && endB)
  14255. {
  14256. var timesp = endD.Subtract(startD);
  14257. if ((timesp.Days + 1) != 0)
  14258. {
  14259. dp = x.Price / (timesp.Days + 1);
  14260. }
  14261. }
  14262. }
  14263. else
  14264. {
  14265. dp = x.Price;
  14266. }
  14267. return new
  14268. {
  14269. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14270. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14271. x.Area,
  14272. x.id,
  14273. price = x.Price.ToString("F2"),
  14274. x.PriceName,
  14275. x.PriceContent,
  14276. x.TeamName,
  14277. x.DatePrice,
  14278. dayPrice = dp.ToString("F2"),
  14279. };
  14280. }).OrderByDescending(x => x.id).ToList();
  14281. jw = JsonView(true, "获取成功!", view);
  14282. }
  14283. catch (Exception e)
  14284. {
  14285. jw = JsonView(false, e.Message);
  14286. }
  14287. return Ok(jw);
  14288. }
  14289. #endregion
  14290. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14291. /// <summary>
  14292. /// 酒店预订
  14293. /// 酒店费用列表 根据团组Id查询
  14294. /// </summary>
  14295. /// <param name="_dto"></param>
  14296. /// <returns></returns>
  14297. [HttpPost]
  14298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14299. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14300. {
  14301. #region 参数验证
  14302. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14303. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14304. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14305. #region 团组操作权限验证 76 酒店预定模块
  14306. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14307. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14308. #endregion
  14309. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14310. #region 页面操作权限验证
  14311. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14312. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14313. #endregion
  14314. #endregion
  14315. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14316. }
  14317. /// <summary>
  14318. /// 酒店预订
  14319. /// 基础数据
  14320. /// </summary>
  14321. /// <param name="_dto"></param>
  14322. /// <returns></returns>
  14323. [HttpPost]
  14324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14325. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14326. {
  14327. #region 参数验证
  14328. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14329. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14330. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14331. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14332. #region 页面操作权限验证
  14333. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14334. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14335. #endregion
  14336. #region 团组操作权限验证 76 酒店预定模块
  14337. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14338. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14339. #endregion
  14340. #endregion
  14341. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14342. }
  14343. /// <summary>
  14344. /// 酒店预订
  14345. /// 创建 入住卷号码
  14346. /// </summary>
  14347. /// <param name="_dto"></param>
  14348. /// <returns></returns>
  14349. [HttpPost]
  14350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14351. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14352. {
  14353. #region 参数验证
  14354. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14355. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14356. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14357. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14358. #region 页面操作权限验证
  14359. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14360. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14361. #endregion
  14362. #region 团组操作权限验证 76 酒店预定模块
  14363. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14364. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14365. #endregion
  14366. #endregion
  14367. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14368. if (data.Code != 0)
  14369. {
  14370. return Ok(JsonView(false, data.Msg));
  14371. }
  14372. return Ok(JsonView(true, data.Msg, data.Data));
  14373. }
  14374. /// <summary>
  14375. /// 酒店预订
  14376. /// 详情
  14377. /// </summary>
  14378. /// <param name="_dto"></param>
  14379. /// <returns></returns>
  14380. [HttpPost]
  14381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14382. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14383. {
  14384. #region 参数验证
  14385. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14386. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14387. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14388. #region 团组操作权限验证 76 酒店预定模块
  14389. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14390. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14391. #endregion
  14392. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14393. #region 页面操作权限验证
  14394. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14395. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14396. #endregion
  14397. #endregion
  14398. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14399. }
  14400. /// <summary>
  14401. /// 酒店预订
  14402. /// Add Or Edit
  14403. /// </summary>
  14404. /// <param name="_dto"></param>
  14405. /// <returns></returns>
  14406. [HttpPost]
  14407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14408. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14409. {
  14410. #region 参数验证
  14411. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14412. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14413. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14414. #region 团组操作权限验证 76 酒店预定模块
  14415. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14416. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14417. #endregion
  14418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14419. #region 页面操作权限验证
  14420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14421. if (_dto.Id == 0) // Add
  14422. {
  14423. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14424. }
  14425. else if (_dto.Id > 1) // Edit
  14426. {
  14427. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14428. }
  14429. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14430. #endregion
  14431. #endregion
  14432. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14433. if (_view.Code != 200)
  14434. {
  14435. return Ok(_view);
  14436. }
  14437. #region 成本无酒店价格数据进入超支
  14438. _sqlSugar.BeginTran();
  14439. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14440. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14441. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14442. for (int i = 0; i < groupCost.Count; i++)
  14443. {
  14444. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14445. {
  14446. groupCost[i].Date = groupCost[i - 1].Date;
  14447. }
  14448. }
  14449. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14450. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14451. List<Fin_GroupExtraCostDto_OP>();
  14452. if (start_Bool && end_Bool)
  14453. {
  14454. while (start_Time < end_Time)
  14455. {
  14456. foreach (var item in groupCost_Grp)
  14457. {
  14458. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14459. {
  14460. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14461. {
  14462. extraCostList.Add(new
  14463. Fin_GroupExtraCostDto_OP
  14464. {
  14465. Area = _dto.AreaId,
  14466. coefficient = 1.5M,
  14467. createUser = _dto.UserId,
  14468. currency = _dto.CardPriceCurrency,
  14469. diId = _dto.DiId,
  14470. ManagerConfirm = 0,
  14471. SupervisorConfirm = 0,
  14472. SYsupervisorConfirm = 0,
  14473. editType = 1,
  14474. PortType = 1,
  14475. price = _dto.CardPrice,
  14476. PriceCount = 1,
  14477. priceType = 1027,
  14478. priceDetailType = 1044,
  14479. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14480. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14481. });
  14482. }
  14483. }
  14484. }
  14485. start_Time = start_Time.AddDays(1);
  14486. }
  14487. }
  14488. if (extraCostList.Any())
  14489. {
  14490. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14491. }
  14492. _sqlSugar.CommitTran();
  14493. #endregion
  14494. #region 应用推送
  14495. try
  14496. {
  14497. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14498. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14499. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14500. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14501. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14502. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14503. var diId = _dto.DiId;
  14504. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14505. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14506. #region 操作记录
  14507. var opInfo = new Crm_TableOperationRecord()
  14508. {
  14509. TableName = "Grp_HotelReservations",
  14510. PortType = _dto.PortType,
  14511. DataId = hotelId,
  14512. CreateUserId = _dto.UserId
  14513. };
  14514. //var opStatus = OperationEnum.NoOperation;
  14515. if (_dto.Id < 1) //添加操作
  14516. {
  14517. opInfo.OperationItem = OperationEnum.Add;
  14518. }
  14519. else if (_dto.Id > 0)
  14520. {
  14521. opInfo.OperationItem = OperationEnum.Edit;
  14522. }
  14523. string opRemark = string.Empty;
  14524. if (ccpInfo != null)
  14525. {
  14526. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14527. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14528. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14529. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14530. }
  14531. opInfo.Remark = opRemark;
  14532. await _tableorRep.AddAsync(opInfo);
  14533. #endregion
  14534. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14535. //2024-10-21 新增LZ UID
  14536. var userIds = new List<int>() { 21 };
  14537. string title = $"费用审核";
  14538. string content = "";
  14539. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14540. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14541. try
  14542. {
  14543. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14544. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14545. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14546. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14547. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14548. }
  14549. catch (Exception ex)
  14550. {
  14551. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14552. }
  14553. }
  14554. catch (Exception ex)
  14555. {
  14556. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14557. }
  14558. try
  14559. {
  14560. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14561. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14562. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14563. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14564. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14565. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14566. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14567. //自动审核
  14568. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14569. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14570. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14571. //2024-10-21 新增LZ UID
  14572. var userIds = new List<int>() { 21 };
  14573. string title = $"系统通知";
  14574. var diId = _dto.DiId;
  14575. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14576. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14577. string content = "";
  14578. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14579. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14580. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14581. }
  14582. catch (Exception ex)
  14583. {
  14584. }
  14585. #endregion
  14586. return Ok(_view);
  14587. }
  14588. /// <summary>
  14589. /// 酒店自动审核测试
  14590. /// Add Or Edit
  14591. /// </summary>
  14592. /// <param name="diid"></param>
  14593. /// <param name="dataId"></param>
  14594. /// <returns></returns>
  14595. [HttpPost]
  14596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14597. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14598. {
  14599. #region 应用推送
  14600. try
  14601. {
  14602. //自动审核
  14603. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14604. }
  14605. catch (Exception ex)
  14606. {
  14607. return Ok(JsonView(false, "操作失败"));
  14608. }
  14609. #endregion
  14610. return Ok(JsonView(false, "操作成功"));
  14611. }
  14612. /// <summary>
  14613. /// 酒店预订
  14614. /// Del
  14615. /// </summary>
  14616. /// <param name="_dto"></param>
  14617. /// <returns></returns>
  14618. [HttpPost]
  14619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14620. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14621. {
  14622. #region 参数验证
  14623. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14624. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14625. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14626. #region 团组操作权限验证 76 酒店预定模块
  14627. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14628. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14629. #endregion
  14630. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14631. #region 页面操作权限验证
  14632. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14633. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14634. #endregion
  14635. #endregion
  14636. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14637. #region 操作记录
  14638. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14639. {
  14640. TableName = "Grp_HotelReservations",
  14641. PortType = _dto.PortType,
  14642. OperationItem = OperationEnum.Del,
  14643. DataId = _dto.Id,
  14644. CreateUserId = _dto.UserId
  14645. });
  14646. #endregion
  14647. return Ok(data);
  14648. }
  14649. /// <summary>
  14650. /// 酒店预订
  14651. /// 生成VOUCHER
  14652. /// 2024.05.06 之前版本
  14653. /// </summary>
  14654. /// <param name="_dto"></param>
  14655. /// <returns></returns>
  14656. [HttpPost]
  14657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14658. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14659. {
  14660. try
  14661. {
  14662. #region 参数验证
  14663. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14664. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14665. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14666. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14667. #region 团组操作权限验证 76 酒店预定模块
  14668. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14669. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14670. #endregion
  14671. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14672. #region 页面操作权限验证
  14673. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14674. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14675. #endregion
  14676. #endregion
  14677. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14678. //判断数据是否完整
  14679. if (hr != null)
  14680. {
  14681. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14682. {
  14683. string strFileName = "HotelStatement/";
  14684. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14685. if (dele != null)
  14686. strFileName += dele.TourCode;
  14687. //载入模板
  14688. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14689. Document doc = new Document(sss);
  14690. DocumentBuilder builder = new DocumentBuilder(doc);
  14691. #region 替换Word模板书签内容
  14692. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14693. //入住卷预定号码
  14694. if (doc.Range.Bookmarks["VNO"] != null)
  14695. {
  14696. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14697. mark.Text = hr.CheckNumber;
  14698. }
  14699. //酒店时间
  14700. if (doc.Range.Bookmarks["Date"] != null)
  14701. {
  14702. Bookmark mark = doc.Range.Bookmarks["Date"];
  14703. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14704. }
  14705. //团号
  14706. if (doc.Range.Bookmarks["TNo"] != null)
  14707. {
  14708. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14709. mark.Text = dele.TourCode;
  14710. }
  14711. //预定号码
  14712. if (doc.Range.Bookmarks["BookingId"] != null)
  14713. {
  14714. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14715. mark.Text = hr.ReservationsNo;
  14716. }
  14717. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14718. {
  14719. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14720. mark.Text = hr.DetermineNo;
  14721. }
  14722. //酒店城市
  14723. if (doc.Range.Bookmarks["City"] != null)
  14724. {
  14725. Bookmark mark = doc.Range.Bookmarks["City"];
  14726. mark.Text = hr.City;
  14727. }
  14728. //酒店名称
  14729. if (doc.Range.Bookmarks["HName"] != null)
  14730. {
  14731. Bookmark mark = doc.Range.Bookmarks["HName"];
  14732. mark.Text = hr.HotelName;
  14733. }
  14734. //酒店地址
  14735. if (doc.Range.Bookmarks["Address"] != null)
  14736. {
  14737. Bookmark mark = doc.Range.Bookmarks["Address"];
  14738. mark.Text = hr.HotelAddress;
  14739. }
  14740. //酒店电话
  14741. if (doc.Range.Bookmarks["Tel"] != null)
  14742. {
  14743. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14744. mark.Text = hr.HotelTel;
  14745. }
  14746. //酒店传真
  14747. if (doc.Range.Bookmarks["Fax"] != null)
  14748. {
  14749. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14750. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14751. {
  14752. mark.Text = hr.HotelFax;
  14753. }
  14754. }
  14755. //入住时间
  14756. if (doc.Range.Bookmarks["CIn"] != null)
  14757. {
  14758. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14759. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14760. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14761. }
  14762. //退房时间
  14763. if (doc.Range.Bookmarks["COut"] != null)
  14764. {
  14765. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14766. Bookmark mark = doc.Range.Bookmarks["COut"];
  14767. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14768. }
  14769. //客户名称
  14770. if (doc.Range.Bookmarks["GName"] != null)
  14771. {
  14772. string guestName = "";
  14773. string[] clients = new string[] { };
  14774. if (hr.GuestName.Contains(","))
  14775. {
  14776. clients = hr.GuestName.Split(",");
  14777. }
  14778. else
  14779. {
  14780. clients = new string[] { hr.GuestName };
  14781. }
  14782. List<int> clientIds_int = new List<int>();
  14783. if (clients.Length > 0)
  14784. {
  14785. foreach (var item in clients)
  14786. {
  14787. if (item.IsNumeric())
  14788. {
  14789. clientIds_int.Add(int.Parse(item));
  14790. }
  14791. }
  14792. }
  14793. if (clientIds_int.Count > 0)
  14794. {
  14795. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14796. foreach (var client in _clientDatas)
  14797. {
  14798. //男
  14799. if (client.Sex == 0) guestName += $"Mr.";
  14800. //女
  14801. else if (client.Sex == 1) guestName += $"Ms.";
  14802. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14803. {
  14804. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14805. }
  14806. //guestName += $"{client.Pinyin},";
  14807. }
  14808. if (guestName.Length > 0)
  14809. {
  14810. guestName = guestName.Substring(0, guestName.Length - 1);
  14811. }
  14812. }
  14813. else
  14814. {
  14815. guestName = hr.GuestName;
  14816. }
  14817. Bookmark mark = doc.Range.Bookmarks["GName"];
  14818. mark.Text = guestName;
  14819. }
  14820. //房间介绍
  14821. if (doc.Range.Bookmarks["ROOM"] != null)
  14822. {
  14823. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14824. mark.Text = hr.RoomExplanation;
  14825. }
  14826. //报价描述
  14827. if (doc.Range.Bookmarks["NOTE"] != null)
  14828. {
  14829. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14830. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14831. if (ss != null)
  14832. mark.Text = ss.Name;
  14833. }
  14834. //入住时间
  14835. if (doc.Range.Bookmarks["CheckIn"] != null)
  14836. {
  14837. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14838. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14839. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14840. }
  14841. //退房时间
  14842. if (doc.Range.Bookmarks["CheckOut"] != null)
  14843. {
  14844. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14845. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14846. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14847. }
  14848. //日期
  14849. if (doc.Range.Bookmarks["DT"] != null)
  14850. {
  14851. Bookmark mark = doc.Range.Bookmarks["DT"];
  14852. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14853. }
  14854. //名称
  14855. if (doc.Range.Bookmarks["VName"] != null)
  14856. {
  14857. Bookmark mark = doc.Range.Bookmarks["VName"];
  14858. mark.Text = hr.HotelName;
  14859. }
  14860. //号码
  14861. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14862. {
  14863. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14864. mark.Text = hr.CheckNumber;
  14865. }
  14866. #endregion
  14867. strFileName += "VOUCHER.doc";
  14868. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14869. doc.Save(fileDir);
  14870. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14871. return Ok(JsonView(true, "操作成功!", Url));
  14872. }
  14873. else
  14874. {
  14875. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14876. }
  14877. }
  14878. else
  14879. {
  14880. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14881. }
  14882. }
  14883. catch (Exception ex)
  14884. {
  14885. return Ok(JsonView(false, ex.Message));
  14886. }
  14887. }
  14888. /// <summary>
  14889. /// 酒店预订
  14890. /// 生成VOUCHER
  14891. /// 2024.05.06 之后版本
  14892. /// </summary>
  14893. /// <param name="_dto"></param>
  14894. /// <returns></returns>
  14895. [HttpPost]
  14896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14897. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14898. {
  14899. #region 参数验证
  14900. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14901. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14902. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14903. #region 团组操作权限验证 76 酒店预定模块
  14904. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14905. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14906. #endregion
  14907. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14908. #region 页面操作权限验证
  14909. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14910. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14911. #endregion
  14912. #endregion
  14913. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14914. //判断数据是否完整
  14915. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14916. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14917. string strFileName = "HotelStatement/";
  14918. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14919. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14920. #region 数据处理
  14921. List<int> guestIds = new List<int>();
  14922. //int index = 0;
  14923. foreach (var item in hrDtas)
  14924. {
  14925. if (item.GuestName.Contains(","))
  14926. {
  14927. string[] guestIdArr = item.GuestName.Split(',');
  14928. foreach (var guestIdStr in guestIdArr)
  14929. {
  14930. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14931. if (guestBool)
  14932. {
  14933. guestIds.Add(guestId);
  14934. }
  14935. }
  14936. }
  14937. else guestNames += item.GuestName;
  14938. var voucherInfo = new HotelVoucherInfoView()
  14939. {
  14940. HotelName = item.HotelName,
  14941. CheckInDate = item.CheckInDate,
  14942. CheckOutDate = item.CheckOutDate,
  14943. ConfirmationNumber = item.DetermineNo.Trim(),
  14944. RoomType = item.RoomExplanation
  14945. };
  14946. vouchers.Add(voucherInfo);
  14947. }
  14948. if (guestIds.Count > 0)
  14949. {
  14950. guestIds = guestIds.Distinct().ToList();
  14951. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14952. if (guestDatas.Count > 0)
  14953. {
  14954. guestNames = "";
  14955. foreach (var guest in guestDatas)
  14956. {
  14957. string guestName = "";
  14958. if (guest.Sex == 0) guestName += @"MR.";
  14959. else if (guest.Sex == 1) guestName += @"MS.";
  14960. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14961. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14962. guestNames += @$"{guestName.Trim()}、";
  14963. }
  14964. if (guestNames.Length > 0)
  14965. {
  14966. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14967. }
  14968. }
  14969. }
  14970. #endregion
  14971. //载入模板
  14972. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14973. Document doc = new Document(sss);
  14974. DocumentBuilder builder = new DocumentBuilder(doc);
  14975. if (doc.Range.Bookmarks["GuestName"] != null)
  14976. {
  14977. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14978. mark.Text = guestNames;
  14979. }
  14980. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14981. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14982. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14983. for (int i = 1; i <= vouchers.Count; i++)
  14984. {
  14985. HotelVoucherInfoView hviv = vouchers[i - 1];
  14986. builder.MoveToCell(0, i, 0, 0);
  14987. builder.Write(hviv.HotelName);
  14988. builder.MoveToCell(0, i, 1, 0);
  14989. builder.Write(hviv.CheckInDate);
  14990. builder.MoveToCell(0, i, 2, 0);
  14991. builder.Write(hviv.CheckOutDate);
  14992. builder.MoveToCell(0, i, 3, 0);
  14993. builder.Write(hviv.RoomType);
  14994. builder.MoveToCell(0, i, 4, 0);
  14995. builder.Write(hviv.ConfirmationNumber);
  14996. }
  14997. //删除多余行
  14998. int currRowIndex = vouchers.Count + 1;
  14999. int delRows = 21 - currRowIndex;
  15000. if (delRows > 0)
  15001. {
  15002. for (int i = 0; i < delRows; i++)
  15003. {
  15004. table.Rows.RemoveAt(currRowIndex);
  15005. //cultivateRowIndex++;
  15006. }
  15007. }
  15008. strFileName += "VOUCHER.docx";
  15009. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15010. doc.Save(fileDir);
  15011. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15012. return Ok(JsonView(true, "操作成功!", Url));
  15013. }
  15014. /// <summary>
  15015. /// 酒店预订
  15016. /// 生成VOUCHER 批量生成
  15017. /// New
  15018. /// </summary>
  15019. /// <param name="_dto"></param>
  15020. /// <returns></returns>
  15021. [HttpPost]
  15022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15023. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15024. {
  15025. #region 参数验证
  15026. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15027. if (_dto.PageId < 1) _dto.PageId = 28;
  15028. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15029. #region 团组操作权限验证 76 酒店预定模块
  15030. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15031. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15032. #endregion
  15033. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15034. #region 页面操作权限验证
  15035. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15036. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15037. #endregion
  15038. #endregion
  15039. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15040. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15041. .OrderBy(x => x.CheckInDate)
  15042. .ToListAsync();
  15043. //判断数据是否完整
  15044. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15045. string strFileName = "HotelStatement/";
  15046. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15047. if (dele != null)
  15048. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15049. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15050. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15051. .Where(it => it.IsDel == 0)
  15052. .ToListAsync();
  15053. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15054. for (int i = 0; i < hrDtas.Count; i++)
  15055. {
  15056. string guestNames = string.Empty;
  15057. List<int> guestIds = new List<int>();
  15058. var item = hrDtas[i];
  15059. //处理客户姓名
  15060. if (item.GuestName.Contains(","))
  15061. {
  15062. string[] guestIdArr = item.GuestName.Split(',');
  15063. foreach (var guestIdStr in guestIdArr)
  15064. if (int.TryParse(guestIdStr, out int guestId))
  15065. guestIds.Add(guestId);
  15066. }
  15067. else
  15068. {
  15069. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15070. if (guestIdBool)
  15071. {
  15072. guestIds.Add(guestId);
  15073. }
  15074. //NaN
  15075. if (item.GuestName.Contains("NaN"))
  15076. {
  15077. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15078. }
  15079. }
  15080. if (guestIds.Count > 0)
  15081. {
  15082. guestIds = guestIds.Distinct().ToList();
  15083. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15084. if (guestDatas1.Count > 0)
  15085. {
  15086. guestNames = "";
  15087. foreach (var guest in guestDatas1)
  15088. {
  15089. string guestName = "";
  15090. if (guest.Sex == 0) guestName += @"MR.";
  15091. else if (guest.Sex == 1) guestName += @"MS.";
  15092. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15093. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15094. guestNames += @$"{guestName.Trim()}、";
  15095. }
  15096. if (guestNames.Length > 0)
  15097. {
  15098. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15099. }
  15100. }
  15101. }
  15102. //if (!string.IsNullOrEmpty(guestNames))
  15103. //{
  15104. hrDtas[i].GuestName = guestNames;
  15105. //}
  15106. }
  15107. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15108. Document doc = new Document();
  15109. DocumentBuilder builder = new DocumentBuilder(doc);
  15110. try
  15111. {
  15112. builder.MoveToDocumentStart();
  15113. foreach (var item in hrDtas)
  15114. {
  15115. //标题
  15116. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15117. builder.ParagraphFormat.LineSpacing = 1;
  15118. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15119. builder.ParagraphFormat.Style.Font.Size = 9;
  15120. builder.ParagraphFormat.Style.Font.Bold = true;
  15121. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15122. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15123. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15124. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15125. builder.ParagraphFormat.LineSpacing = 1;
  15126. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15127. builder.ParagraphFormat.Style.Font.Size = 9;
  15128. builder.ParagraphFormat.Style.Font.Bold = true;
  15129. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15130. builder.StartTable();
  15131. // 设置边框颜色
  15132. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15133. //设置边框样式
  15134. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15135. //表格
  15136. #region 第一行
  15137. builder.InsertCell();
  15138. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15139. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15140. //builder.CellFormat.AllowAutoFit = false;
  15141. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15142. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15143. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15144. builder.CellFormat.WrapText = true; //自动换行
  15145. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15146. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15147. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15148. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15149. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15150. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15151. builder.Write("TOUR NO:");
  15152. builder.InsertCell();
  15153. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15154. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15155. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15156. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15157. builder.ParagraphFormat.Style.Font.Bold = false;
  15158. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15159. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15160. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15161. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15162. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15163. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15164. builder.Write($"{dele?.TourCode ?? "-"}");
  15165. builder.InsertCell();
  15166. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15167. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15168. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15169. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15170. builder.ParagraphFormat.Style.Font.Bold = false;
  15171. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15172. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15173. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15174. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15175. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15176. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15177. builder.Write($"CITY:");
  15178. builder.InsertCell();
  15179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15180. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15181. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15182. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15183. builder.ParagraphFormat.Style.Font.Bold = false;
  15184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15185. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15186. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15187. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15188. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15189. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15190. builder.Write($"{item.City}");
  15191. builder.EndRow();
  15192. #endregion
  15193. #region 第二行
  15194. builder.InsertCell();
  15195. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15196. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15197. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15198. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15199. builder.ParagraphFormat.Style.Font.Bold = false;
  15200. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15201. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15202. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15203. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15204. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15205. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15206. builder.Write("CONFIRMATION NO:");
  15207. builder.InsertCell();
  15208. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15209. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15210. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15211. builder.ParagraphFormat.Style.Font.Bold = false;
  15212. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15213. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15214. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15215. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15216. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15217. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15218. builder.CellFormat.VerticalMerge = CellMerge.None;
  15219. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15220. builder.Write($"{item.DetermineNo}");
  15221. builder.InsertCell();
  15222. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15223. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15224. builder.InsertCell();
  15225. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15226. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15227. builder.EndRow();
  15228. #endregion
  15229. #region 第三行
  15230. builder.InsertCell();
  15231. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15232. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15233. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15234. builder.ParagraphFormat.Style.Font.Bold = false;
  15235. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15236. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15237. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15238. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15239. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15240. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15241. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15242. builder.Write($"HOTEL NAME:");
  15243. builder.InsertCell();
  15244. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15245. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15246. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15247. builder.ParagraphFormat.Style.Font.Bold = false;
  15248. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15249. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15250. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15251. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15252. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15253. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15254. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15255. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15256. builder.Write($"{item.HotelName}");
  15257. builder.InsertCell();
  15258. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15259. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15260. builder.InsertCell();
  15261. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15262. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15263. builder.EndRow();
  15264. #endregion
  15265. #region 第四行
  15266. builder.InsertCell();
  15267. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15268. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15269. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15270. builder.ParagraphFormat.Style.Font.Bold = false;
  15271. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15272. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15273. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15274. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15275. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15276. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15277. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15278. builder.Write($"HOTEL ADDRESS:");
  15279. builder.InsertCell();
  15280. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15282. builder.ParagraphFormat.Style.Font.Size = 8;
  15283. builder.ParagraphFormat.Style.Font.Bold = false;
  15284. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15285. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15286. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15287. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15288. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15289. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15290. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15291. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15292. builder.Write($"{item.HotelAddress}");
  15293. builder.InsertCell();
  15294. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15295. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15296. builder.InsertCell();
  15297. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15298. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15299. builder.EndRow();
  15300. #endregion
  15301. #region 第五行
  15302. builder.InsertCell();
  15303. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15304. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15305. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15306. builder.ParagraphFormat.Style.Font.Bold = false;
  15307. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15308. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15309. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15310. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15311. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15312. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15313. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15314. builder.Write("TEL:");
  15315. builder.InsertCell();
  15316. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15317. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15318. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15319. builder.ParagraphFormat.Style.Font.Bold = false;
  15320. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15321. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15322. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15323. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15324. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15325. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15326. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15327. builder.Write($"{item.HotelTel}");
  15328. builder.InsertCell();
  15329. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15330. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15331. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15332. builder.ParagraphFormat.Style.Font.Bold = false;
  15333. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15334. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15335. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15336. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15337. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15338. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15339. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15340. builder.Write($"FAX:");
  15341. builder.InsertCell();
  15342. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15343. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15344. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15345. builder.ParagraphFormat.Style.Font.Bold = false;
  15346. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15347. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15348. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15349. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15350. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15351. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15352. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15353. builder.Write($"{item.HotelFax}");
  15354. builder.EndRow();
  15355. #endregion
  15356. #region 第六行
  15357. builder.InsertCell();
  15358. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15359. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15360. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15361. builder.ParagraphFormat.Style.Font.Bold = false;
  15362. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15363. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15364. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15365. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15366. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15367. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15368. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15369. builder.Write("CHECK IN:");
  15370. builder.InsertCell();
  15371. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15372. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15373. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15374. builder.ParagraphFormat.Style.Font.Bold = false;
  15375. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15376. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15377. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15378. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15379. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15380. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15381. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15382. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15383. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15384. builder.Write($"{checkInStr}");
  15385. builder.InsertCell();
  15386. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15387. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15388. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15389. builder.ParagraphFormat.Style.Font.Bold = false;
  15390. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15391. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15392. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15393. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15394. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15395. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15396. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15397. builder.Write($"CHECK OUT:");
  15398. builder.InsertCell();
  15399. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15400. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15401. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15402. builder.ParagraphFormat.Style.Font.Bold = false;
  15403. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15404. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15405. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15406. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15407. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15408. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15409. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15410. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15411. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15412. builder.Write($"{checkOutStr}");
  15413. builder.EndRow();
  15414. #endregion
  15415. #region 第七行
  15416. builder.InsertCell();
  15417. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15418. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15419. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15420. builder.ParagraphFormat.Style.Font.Bold = false;
  15421. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15422. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15423. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15424. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15425. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15426. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15427. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15428. builder.Write($"GUEST NAME:");
  15429. builder.InsertCell();
  15430. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15431. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15432. builder.ParagraphFormat.Style.Font.Size = 8;
  15433. builder.ParagraphFormat.Style.Font.Bold = false;
  15434. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15435. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15436. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15437. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15438. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15439. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15440. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15441. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15442. builder.Write($"{item.GuestName}");
  15443. builder.InsertCell();
  15444. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15445. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15446. builder.InsertCell();
  15447. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15448. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15449. builder.EndRow();
  15450. #endregion
  15451. #region 第八行
  15452. builder.InsertCell();
  15453. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15454. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15455. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15456. builder.ParagraphFormat.Style.Font.Bold = false;
  15457. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15458. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15459. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15460. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15461. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15462. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15463. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15464. builder.Write($"ROOM TYPE:");
  15465. builder.InsertCell();
  15466. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15467. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15468. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15469. builder.ParagraphFormat.Style.Font.Bold = false;
  15470. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15471. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15472. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15473. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15474. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15475. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15476. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15477. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15478. builder.Write($"{item.RoomExplanation}");
  15479. builder.InsertCell();
  15480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15481. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15482. builder.InsertCell();
  15483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15484. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15485. builder.EndRow();
  15486. #endregion
  15487. #region 第九行
  15488. builder.InsertCell();
  15489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15490. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15491. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15492. builder.ParagraphFormat.Style.Font.Bold = false;
  15493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15500. builder.Write($"NOTE:");
  15501. builder.InsertCell();
  15502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15504. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15505. builder.ParagraphFormat.Style.Font.Bold = false;
  15506. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15509. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15510. 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.");
  15511. builder.InsertCell();
  15512. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15513. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15514. builder.InsertCell();
  15515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15516. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15517. builder.EndRow();
  15518. #endregion
  15519. builder.EndTable();
  15520. //换行
  15521. builder.Writeln("");
  15522. builder.Writeln("");
  15523. }
  15524. #region 获取文档中的所有表格 设置文字自适应
  15525. // 获取文档中的所有表格。
  15526. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15527. {
  15528. // 遍历表格中的所有行。
  15529. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15530. {
  15531. foreach (Cell cell in row.Cells)
  15532. {
  15533. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15534. cellFormat.Width = 0;
  15535. }
  15536. }
  15537. }
  15538. #endregion
  15539. #region 设置页眉
  15540. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15541. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15542. if (System.IO.File.Exists(voucherHeaderPath))
  15543. {
  15544. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15545. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15546. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15547. Shape shape = builder.InsertImage(imageBytes);
  15548. // 调整图片位置
  15549. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15550. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15551. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15552. shape.Left = 0; // 将图片距离页面左边缘的距离
  15553. shape.Width = 81; // 设置图片宽度
  15554. shape.Height = 36; // 设置图片高度
  15555. }
  15556. //靠右
  15557. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15558. //// 设置页脚上下边距
  15559. //builder.PageSetup.HeaderDistance = 42;
  15560. // 添加页眉线
  15561. Aspose.Words.Border borderHeader = null;
  15562. try
  15563. {
  15564. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15565. }
  15566. catch (Exception e)
  15567. {
  15568. // TODO Auto-generated catch block
  15569. //e.printStackTrace();
  15570. }
  15571. borderHeader.Shadow = true;
  15572. borderHeader.DistanceFromText = 2;
  15573. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15574. #endregion
  15575. }
  15576. catch (Exception ex)
  15577. {
  15578. }
  15579. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15580. doc.Save(fileDir);
  15581. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15582. return Ok(JsonView(true, "操作成功!", Url));
  15583. }
  15584. /// <summary>
  15585. /// 酒店预订
  15586. /// 生成 预定成本 Excel
  15587. /// </summary>
  15588. /// <param name="_dto"></param>
  15589. /// <returns></returns>
  15590. [HttpPost]
  15591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15592. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15593. {
  15594. #region 参数验证
  15595. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15596. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15597. if (!vadalitorRes.IsValid)
  15598. {
  15599. var errors = new StringBuilder();
  15600. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15601. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15602. }
  15603. #region 团组操作权限验证 76 酒店预定模块
  15604. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15605. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15606. #endregion
  15607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15608. #region 页面操作权限验证
  15609. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15610. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15611. #endregion
  15612. #endregion
  15613. decimal _rate = 1.00M;
  15614. string _currency = string.Empty;
  15615. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15616. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15617. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15618. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15619. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15620. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15621. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15622. if (_GroupCostParameter == null)
  15623. {
  15624. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15625. bool isIntType = int.TryParse(_currency, out int currId);
  15626. if (isIntType)
  15627. {
  15628. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15629. }
  15630. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15631. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15632. if (currInfo == null)
  15633. {
  15634. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15635. }
  15636. else _rate = currInfo.Rate;
  15637. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15638. {
  15639. _rate = _GroupCostParameter.Rate;
  15640. }
  15641. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15642. //string strFileName = "HotelStatement/";
  15643. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15644. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15645. var rateDatas = new List<dynamic>();
  15646. #region 数据处理
  15647. foreach (var item in hrDtas)
  15648. {
  15649. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15650. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15651. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15652. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15653. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15654. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15655. {
  15656. continue;
  15657. }
  15658. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15659. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15660. string singleRoomFeeStr = string.Empty,
  15661. doubleRoomFeeStr = string.Empty,
  15662. suiteRoomFeeStr = string.Empty,
  15663. otherRoomFeeStr = string.Empty,
  15664. payMoneyStr = string.Empty,
  15665. cardPriceStr = string.Empty;
  15666. if (roomCurr.Equals("CNY"))
  15667. {
  15668. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15669. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15670. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15671. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15672. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15673. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15674. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15675. }
  15676. else
  15677. {
  15678. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15679. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15680. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15681. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15682. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15683. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15684. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15685. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15686. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15687. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15688. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15689. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15690. if (ccpPaymentCurrency.Equals("CNY"))
  15691. {
  15692. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15693. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15694. }
  15695. else
  15696. {
  15697. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15698. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15699. }
  15700. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15701. if (hotelcardPriceCurrency.Equals("CNY"))
  15702. {
  15703. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15704. }
  15705. else
  15706. {
  15707. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15708. }
  15709. }
  15710. string breakfastPriceStr = string.Empty,
  15711. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15712. governmentRentStr = string.Empty,
  15713. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15714. cityTaxStr = string.Empty,
  15715. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15716. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15717. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15718. {
  15719. if (breakfastCurrency1.Equals("CNY"))
  15720. {
  15721. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15722. }
  15723. else
  15724. {
  15725. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15726. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15727. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15728. }
  15729. }
  15730. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15731. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15732. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15733. {
  15734. if (governmentRentCurrency.Equals("CNY"))
  15735. {
  15736. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15737. }
  15738. else
  15739. {
  15740. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15741. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15742. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15743. }
  15744. }
  15745. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15746. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15747. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15748. {
  15749. if (cityTaxStrCurrency1.Equals("CNY"))
  15750. {
  15751. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15752. }
  15753. else
  15754. {
  15755. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15756. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15757. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15758. }
  15759. }
  15760. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15761. int payDId = roomInfo?.PayDId ?? 0;
  15762. pcfds.Add(new HotelReservations_PCFD_View()
  15763. {
  15764. City = item.City,
  15765. HotelName = item.HotelName,
  15766. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15767. // SingleRoomCount = item.SingleRoomCount,
  15768. SingleRoomPrice = singleRoomFeeStr,
  15769. // DoubleRoomCount = item.DoubleRoomCount,
  15770. DoubleRoomPrice = doubleRoomFeeStr,
  15771. //SuiteRoomCount = item.SuiteRoomCount,
  15772. SuiteRoomPrice = suiteRoomFeeStr,
  15773. OtherRoomPrice = otherRoomFeeStr,
  15774. //OtherRoomCount = item.OtherRoomCount,
  15775. BreakfastPrice = breakfastPriceStr,
  15776. GovernmentRent = governmentRentStr,
  15777. CityTax = cityTaxStr,
  15778. RoomExplanation = item.RoomExplanation,
  15779. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15780. PayTime = roomInfo?.ConsumptionDate,
  15781. BankNo = roomInfo?.BankNo,
  15782. PayMoney = payMoneyStr,
  15783. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15784. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15785. CardPrice = cardPriceStr,
  15786. Remark = ccpInfo.Remark
  15787. });
  15788. }
  15789. #endregion
  15790. //载入模板
  15791. WorkbookDesigner designer = new WorkbookDesigner();
  15792. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15793. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15794. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15795. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15796. var rateDatas1 = rateDatas.Distinct();
  15797. var rateStr = string.Empty;
  15798. foreach (var item in rateDatas1)
  15799. {
  15800. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15801. }
  15802. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15803. designer.SetDataSource("Opertor", userInfo.CnName);
  15804. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15805. dt.TableName = "ViewMyHotelReservations";
  15806. designer.SetDataSource(dt);
  15807. designer.Process();
  15808. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15809. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15810. designer.Workbook.Save(serverPath);
  15811. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15812. #region 删除指定行
  15813. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15814. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15815. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15816. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15817. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15818. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15819. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15820. cssIndex = dt.Columns["CityTax"].Ordinal,
  15821. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15822. remarkIndex = dt.Columns["Remark"].Ordinal;
  15823. //删除指定列
  15824. foreach (DataRow item in dt.Rows)
  15825. {
  15826. string singleStr = item["SingleRoomPrice"].ToString();
  15827. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15828. if (containsDigitButNotZero1) singleDel = false;
  15829. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15830. string doubleStr = item["DoubleRoomPrice"].ToString();
  15831. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15832. if (containsDigitButNotZero2) doubleDel = false;
  15833. string suiteStr = item["SuiteRoomPrice"].ToString();
  15834. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15835. if (containsDigitButNotZero3) suiteDel = false;
  15836. string otherStr = item["OtherRoomPrice"].ToString();
  15837. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15838. if (containsDigitButNotZero4) otherDel = false;
  15839. string zcStr = item["BreakfastPrice"].ToString();
  15840. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15841. if (containsDigitButNotZero5) zcDel = false;
  15842. string dsStr = item["GovernmentRent"].ToString();
  15843. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15844. if (containsDigitButNotZero6) dsDel = false;
  15845. string cssStr = item["CityTax"].ToString();
  15846. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15847. if (containsDigitButNotZero7) cssDel = false;
  15848. string cpStr = item["ConsumptionPatterns"].ToString();
  15849. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15850. string remarkStr = item["Remark"].ToString();
  15851. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15852. }
  15853. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15854. DeleteColumn(serverPath, cpIndex, cpDel);
  15855. DeleteColumn(serverPath, dsIndex, dsDel);
  15856. DeleteColumn(serverPath, cssIndex, cssDel);
  15857. DeleteColumn(serverPath, zcIndex, zcDel);
  15858. DeleteColumn(serverPath, otherIndex, otherDel);
  15859. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15860. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15861. DeleteColumn(serverPath, singleIndex, singleDel);
  15862. #endregion
  15863. //只保留第一个表格
  15864. DeleteSheet(serverPath);
  15865. return Ok(JsonView(true, "操作成功", url = rst));
  15866. }
  15867. else
  15868. {
  15869. _currency = _GroupCostParameter.Currency;
  15870. bool isIntType = int.TryParse(_currency, out int currId);
  15871. if (isIntType)
  15872. {
  15873. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15874. }
  15875. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15876. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15877. if (currInfo == null)
  15878. {
  15879. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15880. }
  15881. if (!_currency.ToUpper().Equals("CNY"))
  15882. {
  15883. _rate = _GroupCostParameter.Rate;
  15884. }
  15885. _rate = currInfo.Rate;
  15886. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15887. //string strFileName = "HotelStatement/";
  15888. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15889. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15890. #region 数据处理
  15891. foreach (var item in hrDtas)
  15892. {
  15893. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15894. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15895. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15896. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15897. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15898. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15899. string singleRoomFeeStr = string.Empty,
  15900. doubleRoomFeeStr = string.Empty,
  15901. suiteRoomFeeStr = string.Empty,
  15902. otherRoomFeeStr = string.Empty,
  15903. payMoneyStr = string.Empty,
  15904. cardPriceStr = string.Empty;
  15905. if (roomCurr.Equals(_currency))
  15906. {
  15907. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15908. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15909. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15910. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15911. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15912. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15913. }
  15914. else
  15915. {
  15916. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15917. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15918. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15919. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15920. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15921. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15922. }
  15923. string breakfastPriceStr = string.Empty,
  15924. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15925. governmentRentStr = string.Empty,
  15926. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15927. cityTaxStrStr = string.Empty,
  15928. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15929. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15930. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15931. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15932. int payDId = roomInfo?.PayDId ?? 0;
  15933. pcfds.Add(new HotelReservations_PCFD_View()
  15934. {
  15935. City = item.City,
  15936. HotelName = item.HotelName,
  15937. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15938. // SingleRoomCount = item.SingleRoomCount,
  15939. SingleRoomPrice = singleRoomFeeStr,
  15940. // DoubleRoomCount = item.DoubleRoomCount,
  15941. DoubleRoomPrice = doubleRoomFeeStr,
  15942. //SuiteRoomCount = item.SuiteRoomCount,
  15943. SuiteRoomPrice = suiteRoomFeeStr,
  15944. OtherRoomPrice = otherRoomFeeStr,
  15945. //OtherRoomCount = item.OtherRoomCount,
  15946. BreakfastPrice = breakfastPriceStr,
  15947. GovernmentRent = governmentRentStr,
  15948. CityTax = cityTaxStrStr,
  15949. RoomExplanation = item.RoomExplanation,
  15950. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15951. PayTime = roomInfo?.ConsumptionDate,
  15952. BankNo = roomInfo?.BankNo,
  15953. PayMoney = payMoneyStr,
  15954. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15955. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15956. CardPrice = cardPriceStr,
  15957. Remark = ccpInfo.Remark
  15958. });
  15959. }
  15960. #endregion
  15961. //载入模板
  15962. WorkbookDesigner designer = new WorkbookDesigner();
  15963. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15964. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15965. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15966. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15967. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15968. designer.SetDataSource("Opertor", userInfo.CnName);
  15969. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15970. dt.TableName = "ViewMyHotelReservations";
  15971. designer.SetDataSource(dt);
  15972. designer.Process();
  15973. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15974. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15975. designer.Workbook.Save(serverPath);
  15976. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15977. #region 删除指定行
  15978. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15979. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15980. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15981. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15982. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15983. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15984. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15985. cssIndex = dt.Columns["CityTax"].Ordinal,
  15986. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15987. remarkIndex = dt.Columns["Remark"].Ordinal;
  15988. //删除指定列
  15989. foreach (DataRow item in dt.Rows)
  15990. {
  15991. string singleStr = item["SingleRoomPrice"].ToString();
  15992. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15993. if (containsDigitButNotZero1) singleDel = false;
  15994. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15995. string doubleStr = item["DoubleRoomPrice"].ToString();
  15996. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15997. if (containsDigitButNotZero2) doubleDel = false;
  15998. string suiteStr = item["SuiteRoomPrice"].ToString();
  15999. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16000. if (containsDigitButNotZero3) suiteDel = false;
  16001. string otherStr = item["OtherRoomPrice"].ToString();
  16002. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16003. if (containsDigitButNotZero4) otherDel = false;
  16004. string zcStr = item["BreakfastPrice"].ToString();
  16005. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16006. if (containsDigitButNotZero5) zcDel = false;
  16007. string dsStr = item["GovernmentRent"].ToString();
  16008. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16009. if (containsDigitButNotZero6) dsDel = false;
  16010. string cssStr = item["CityTax"].ToString();
  16011. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16012. if (containsDigitButNotZero7) cssDel = false;
  16013. string cpStr = item["ConsumptionPatterns"].ToString();
  16014. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16015. string remarkStr = item["Remark"].ToString();
  16016. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16017. }
  16018. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16019. DeleteColumn(serverPath, cpIndex, cpDel);
  16020. DeleteColumn(serverPath, dsIndex, dsDel);
  16021. DeleteColumn(serverPath, cssIndex, cssDel);
  16022. DeleteColumn(serverPath, zcIndex, zcDel);
  16023. DeleteColumn(serverPath, otherIndex, otherDel);
  16024. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16025. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16026. DeleteColumn(serverPath, singleIndex, singleDel);
  16027. #endregion
  16028. //只保留第一个表格
  16029. DeleteSheet(serverPath);
  16030. return Ok(JsonView(true, "操作成功", url = rst));
  16031. }
  16032. //return Ok(JsonView(false));
  16033. }
  16034. /// <summary>
  16035. /// 删除指定列
  16036. /// </summary>
  16037. /// <param name="file"></param>
  16038. /// <param name="columnIndex"></param>
  16039. /// <param name="isDel"></param>
  16040. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16041. {
  16042. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16043. //wb.Save(file);
  16044. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16045. if (sheet1 != null)
  16046. {
  16047. if (isDel)
  16048. {
  16049. Cells cells = sheet1.Cells;
  16050. cells.DeleteColumn(columnIndex);
  16051. }
  16052. }
  16053. wb.Save(file);
  16054. }
  16055. /// <summary>
  16056. /// 删除sheet
  16057. /// </summary>
  16058. /// <param name="file"></param>
  16059. /// <param name="sheetName"></param>
  16060. private void DeleteSheet(string file, string sheetName = "")
  16061. {
  16062. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16063. //wb.Save(file);
  16064. List<string> sheets = new List<string>();
  16065. foreach (var item in wb.Worksheets)
  16066. {
  16067. sheets.Add(item.Name);
  16068. }
  16069. if (sheets.Count > 0)
  16070. {
  16071. sheets.RemoveAt(0);//不删除第一个sheet
  16072. foreach (var item in sheets)
  16073. {
  16074. wb.Worksheets.RemoveAt(item);
  16075. }
  16076. }
  16077. wb.Save(file);
  16078. }
  16079. /// <summary>
  16080. /// 酒店预订
  16081. /// 确认单
  16082. /// </summary>
  16083. /// <param name="_dto"></param>
  16084. /// <returns></returns>
  16085. [HttpPost]
  16086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16087. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16088. {
  16089. try
  16090. {
  16091. #region 参数验证
  16092. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16093. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16094. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16095. #region 团组操作权限验证 76 酒店预定模块
  16096. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16097. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16098. #endregion
  16099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16100. #region 页面操作权限验证
  16101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16102. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16103. #endregion
  16104. #endregion
  16105. //团组信息
  16106. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16107. //酒店数据
  16108. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16109. if (listhoteldata.Count < 0)
  16110. {
  16111. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16112. }
  16113. //利datatable存储
  16114. DataTable dt = new DataTable();
  16115. dt.Columns.Add("CheckInDate", typeof(string));
  16116. dt.Columns.Add("City", typeof(string));
  16117. dt.Columns.Add("Hotel", typeof(string));
  16118. dt.Columns.Add("Room", typeof(string));
  16119. for (int i = 0; i < listhoteldata.Count; i++)
  16120. {
  16121. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16122. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16123. while (dayStart < dayEnd)
  16124. {
  16125. string temp = "";
  16126. DataRow row = dt.NewRow();
  16127. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16128. row["City"] = listhoteldata[i].City;
  16129. row["Hotel"] = listhoteldata[i].HotelName;
  16130. if (listhoteldata[i].SingleRoomCount > 0)
  16131. {
  16132. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16133. }
  16134. if (listhoteldata[i].DoubleRoomCount > 0)
  16135. {
  16136. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16137. }
  16138. if (listhoteldata[i].SuiteRoomCount > 0)
  16139. {
  16140. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16141. }
  16142. if (listhoteldata[i].OtherRoomCount > 0)
  16143. {
  16144. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16145. }
  16146. row["Room"] = temp;
  16147. dt.Rows.Add(row);
  16148. dayStart = dayStart.AddDays(1);
  16149. }
  16150. }
  16151. Dictionary<string, string> dic = new Dictionary<string, string>();
  16152. dic.Add("Dele", di.TeamName);
  16153. dic.Add("City", di.VisitCountry);
  16154. //模板路径
  16155. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16156. //载入模板
  16157. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16158. DocumentBuilder builder = new DocumentBuilder(doc);
  16159. foreach (var key in dic.Keys)
  16160. {
  16161. builder.MoveToBookmark(key);
  16162. builder.Write(dic[key]);
  16163. }
  16164. //获取word里所有表格
  16165. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16166. //获取所填表格的序数
  16167. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16168. var rowStart = tableOne.Rows[0]; //获取第1行
  16169. //循环赋值
  16170. for (int i = 0; i < dt.Rows.Count; i++)
  16171. {
  16172. builder.MoveToCell(0, i + 1, 0, 0);
  16173. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16174. builder.MoveToCell(0, i + 1, 1, 0);
  16175. builder.Write(dt.Rows[i]["City"].ToString());
  16176. builder.MoveToCell(0, i + 1, 2, 0);
  16177. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16178. builder.MoveToCell(0, i + 1, 3, 0);
  16179. builder.Write(dt.Rows[i]["Room"].ToString());
  16180. }
  16181. //删除多余行
  16182. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16183. {
  16184. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16185. }
  16186. string strFileName = di.TeamName + "酒店确认单.doc";
  16187. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16188. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16189. return Ok(JsonView(true, "成功", url));
  16190. }
  16191. catch (Exception ex)
  16192. {
  16193. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16194. }
  16195. }
  16196. #endregion
  16197. #region 团组状态
  16198. /// <summary>
  16199. /// 团组状态列表 Page
  16200. /// </summary>
  16201. /// <param name="dto">团组列表请求dto</param>
  16202. /// <returns></returns>
  16203. [HttpPost]
  16204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16205. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16206. {
  16207. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16208. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16209. {
  16210. string sqlWhere = string.Empty;
  16211. if (dto.IsSure == 0) //未完成
  16212. {
  16213. sqlWhere += string.Format(@" And IsSure = 0");
  16214. }
  16215. else if (dto.IsSure == 1) //已完成
  16216. {
  16217. sqlWhere += string.Format(@" And IsSure = 1");
  16218. }
  16219. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16220. {
  16221. string tj = dto.SearchCriteria;
  16222. 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}%')",
  16223. tj, tj, tj, tj, tj);
  16224. }
  16225. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16226. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16227. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16228. From (
  16229. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16230. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16231. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16232. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16233. From Grp_DelegationInfo gdi
  16234. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16235. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16236. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16237. Where gdi.IsDel = 0 {0}
  16238. ) temp ", sqlWhere);
  16239. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16240. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16241. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16242. }
  16243. else
  16244. {
  16245. return Ok(JsonView(false, "查询失败"));
  16246. }
  16247. }
  16248. /// <summary>
  16249. /// 团组状态
  16250. /// 设置操作完成
  16251. /// </summary>
  16252. /// <param name="dto">团组列表请求dto</param>
  16253. /// <returns></returns>
  16254. [HttpPost]
  16255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16256. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16257. {
  16258. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16259. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16260. {
  16261. Id = dto.Id,
  16262. IsSure = 1
  16263. };
  16264. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16265. .UpdateColumns(it => new { it.IsSure })
  16266. .WhereColumns(it => new { it.Id })
  16267. .ExecuteCommandAsync();
  16268. if (result > 0)
  16269. {
  16270. return Ok(JsonView(true, "操作完成!"));
  16271. }
  16272. return Ok(JsonView(false, "操作失败!"));
  16273. }
  16274. #endregion
  16275. #region 保险费用录入
  16276. /// <summary>
  16277. /// 根据团组Id查询保险费用列表
  16278. /// </summary>
  16279. /// <param name="dto"></param>
  16280. /// <returns></returns>
  16281. [HttpPost]
  16282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16283. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16284. {
  16285. Result groupData = await _customersRep.CustomersByDiId(dto);
  16286. if (groupData.Code != 0)
  16287. {
  16288. return Ok(JsonView(false, groupData.Msg));
  16289. }
  16290. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16291. }
  16292. /// <summary>
  16293. /// 根据保险费用Id查询保险费用详细
  16294. /// </summary>
  16295. /// <param name="dto"></param>
  16296. /// <returns></returns>
  16297. [HttpPost]
  16298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16299. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16300. {
  16301. try
  16302. {
  16303. Result groupData = await _customersRep.CustomersById(dto);
  16304. if (groupData.Code != 0)
  16305. {
  16306. return Ok(JsonView(false, groupData.Msg));
  16307. }
  16308. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16309. }
  16310. catch (Exception ex)
  16311. {
  16312. return Ok(JsonView(false, ex.Message));
  16313. }
  16314. }
  16315. /// <summary>
  16316. /// 保险费用录入页面初始化绑定
  16317. /// </summary>
  16318. /// <param name="dto"></param>
  16319. /// <returns></returns>
  16320. [HttpPost]
  16321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16322. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16323. {
  16324. try
  16325. {
  16326. Result groupData = await _customersRep.CustomersInitialize(dto);
  16327. if (groupData.Code != 0)
  16328. {
  16329. return Ok(JsonView(false, groupData.Msg));
  16330. }
  16331. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16332. }
  16333. catch (Exception ex)
  16334. {
  16335. return Ok(JsonView(false, ex.Message));
  16336. }
  16337. }
  16338. /// <summary>
  16339. /// 保险费用操作(Status:1.新增,2.修改)
  16340. /// </summary>
  16341. /// <param name="dto"></param>
  16342. /// <returns></returns>
  16343. [HttpPost]
  16344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16345. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16346. {
  16347. Result groupData = await _customersRep.OpCustomers(dto);
  16348. if (groupData.Code != 0)
  16349. {
  16350. return Ok(JsonView(false, groupData.Msg));
  16351. }
  16352. #region 应用推送
  16353. try
  16354. {
  16355. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16356. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16357. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16358. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16359. //自动审核
  16360. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16361. //2024-10-21 新增LZ UID
  16362. var userIds = new List<int>() { 21 };
  16363. string title = $"系统通知";
  16364. var diId = dto.DiId;
  16365. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16366. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16367. string content = "";
  16368. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16369. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16370. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16371. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16372. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16373. }
  16374. catch (Exception ex)
  16375. {
  16376. }
  16377. #endregion
  16378. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16379. }
  16380. /// <summary>
  16381. /// 保险文件上传
  16382. /// </summary>
  16383. /// <param name="file"></param>
  16384. /// <returns></returns>
  16385. [HttpPost]
  16386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16387. public async Task<IActionResult> UploadCus(IFormFile file)
  16388. {
  16389. try
  16390. {
  16391. if (file != null)
  16392. {
  16393. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16394. //文件名称
  16395. string projectFileName = file.FileName;
  16396. //上传的文件的路径
  16397. string filePath = "";
  16398. if (!Directory.Exists(fileDir))
  16399. {
  16400. Directory.CreateDirectory(fileDir);
  16401. }
  16402. //上传的文件的路径
  16403. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16404. using (FileStream fs = System.IO.File.Create(filePath))
  16405. {
  16406. file.CopyTo(fs);
  16407. fs.Flush();
  16408. }
  16409. return Ok(JsonView(true, "上传成功!", projectFileName));
  16410. }
  16411. else
  16412. {
  16413. return Ok(JsonView(false, "上传失败!"));
  16414. }
  16415. }
  16416. catch (Exception ex)
  16417. {
  16418. return Ok(JsonView(false, "程序错误!"));
  16419. throw;
  16420. }
  16421. }
  16422. /// <summary>
  16423. /// 保险删除指定文件
  16424. /// </summary>
  16425. /// <param name="dto"></param>
  16426. /// <returns></returns>
  16427. [HttpPost]
  16428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16429. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16430. {
  16431. try
  16432. {
  16433. string filePath = "";
  16434. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16435. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16436. //int id = 0;
  16437. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16438. // 删除该文件
  16439. try
  16440. {
  16441. System.IO.File.Delete(filePath);
  16442. 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()
  16443. {
  16444. Attachment = "",
  16445. }).ExecuteCommandAsync();
  16446. if (result != 0)
  16447. {
  16448. return Ok(JsonView(true, "成功!"));
  16449. }
  16450. else
  16451. {
  16452. return Ok(JsonView(false, "失败!"));
  16453. }
  16454. }
  16455. catch (Exception)
  16456. {
  16457. 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()
  16458. {
  16459. Attachment = "",
  16460. }).ExecuteCommandAsync();
  16461. if (result != 0)
  16462. {
  16463. return Ok(JsonView(true, "成功!"));
  16464. }
  16465. else
  16466. {
  16467. return Ok(JsonView(false, "失败!"));
  16468. }
  16469. }
  16470. }
  16471. catch (Exception ex)
  16472. {
  16473. return Ok(JsonView(false, "程序错误!"));
  16474. throw;
  16475. }
  16476. }
  16477. /// <summary>
  16478. /// 保险费用操作(删除)
  16479. /// </summary>
  16480. /// <param name="dto"></param>
  16481. /// <returns></returns>
  16482. [HttpPost]
  16483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16484. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16485. {
  16486. try
  16487. {
  16488. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16489. if (!res)
  16490. {
  16491. return Ok(JsonView(false, "删除失败"));
  16492. }
  16493. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16494. {
  16495. IsDel = 1,
  16496. DeleteUserId = dto.DeleteUserId,
  16497. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16498. }).ExecuteCommandAsync();
  16499. return Ok(JsonView(true, "删除成功!"));
  16500. }
  16501. catch (Exception ex)
  16502. {
  16503. return Ok(JsonView(false, "程序错误!"));
  16504. throw;
  16505. }
  16506. }
  16507. #endregion
  16508. #region 接团客户名单 PageId 104
  16509. /// <summary>
  16510. /// 接团客户名单
  16511. /// 迁移数据(慎用!)
  16512. /// </summary>
  16513. /// <returns></returns>
  16514. [HttpPost]
  16515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16516. public async Task<IActionResult> PostTourClientListChange()
  16517. {
  16518. try
  16519. {
  16520. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16521. //var groupClinetData1
  16522. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16523. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16524. int updateCount = 0;
  16525. if (oldOAClientList.Count > 0)
  16526. {
  16527. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16528. _sqlSugar.BeginTran();
  16529. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16530. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16531. foreach (var item in oldOAClientList)
  16532. {
  16533. int comId = 0;
  16534. string format = "yyyy-MM-dd HH:mm:ss";
  16535. string data11 = "1990-01-01 00:00";
  16536. var data1 = IsValidDate(item.OPdate, format);
  16537. if (data1) data11 = item.OPdate;
  16538. //客户公司验证
  16539. if (!string.IsNullOrEmpty(item.Company))
  16540. {
  16541. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16542. if (clientComInfo == null) // add
  16543. {
  16544. var addInfo = new Crm_CustomerCompany()
  16545. {
  16546. CompanyAbbreviation = "",
  16547. CompanyFullName = item.Company,
  16548. Address = "",
  16549. PostCodes = "",
  16550. LastedOpUserId = item.OPer,
  16551. LastedOpDt = Convert.ToDateTime(data11),
  16552. CreateUserId = item.OPer,
  16553. CreateTime = Convert.ToDateTime(data11),
  16554. IsDel = 0
  16555. };
  16556. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16557. if (comId1 > 0) comId = comId1;
  16558. }
  16559. else comId = clientComInfo.Id;
  16560. }
  16561. //客户人员验证
  16562. int clientId = 0;
  16563. string name = item.LastName + item.Name;
  16564. if (!string.IsNullOrEmpty(name))
  16565. {
  16566. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16567. if (clientInfo == null)
  16568. {
  16569. DateTime? dateTime = null;
  16570. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16571. if (isDt) dateTime = birthDayDt;
  16572. var addInfo1 = new Crm_DeleClient()
  16573. {
  16574. CrmCompanyId = comId,
  16575. DiId = -1,
  16576. LastName = item.LastName,
  16577. FirstName = item.Name,
  16578. OldName = "",
  16579. Pinyin = item.Pinyin,
  16580. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16581. Marriage = 0,
  16582. Phone = item.Phone,
  16583. Job = item.Job,
  16584. BirthDay = dateTime
  16585. };
  16586. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16587. if (clientId1 > 0) clientId = clientId1;
  16588. }
  16589. else clientId = clientInfo.Id;
  16590. }
  16591. if (clientId < 1)
  16592. {
  16593. continue;
  16594. }
  16595. int airType = 0;
  16596. if (item.AirType == "超经舱") airType = 459;
  16597. else if (item.AirType == "公务舱") airType = 458;
  16598. else if (item.AirType == "经济舱") airType = 460;
  16599. else if (item.AirType == "其他") airType = 565;
  16600. else if (item.AirType == "头等舱") airType = 457;
  16601. var _TourClientListEntity = new Grp_TourClientList()
  16602. {
  16603. DiId = item.Diid,
  16604. ClientId = clientId,
  16605. CreateUserId = item.OPer,
  16606. CreateTime = Convert.ToDateTime(data11),
  16607. Remark = item.Remark,
  16608. IsDel = item.Isdel,
  16609. ShippingSpaceTypeId = airType,
  16610. ShippingSpaceSpecialNeeds = item.AirRemark,
  16611. HotelSpecialNeeds = item.RoomType
  16612. };
  16613. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16614. if (_TourClientList > 0)
  16615. {
  16616. updateCount++;
  16617. }
  16618. }
  16619. _sqlSugar.CommitTran();
  16620. }
  16621. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16622. }
  16623. catch (Exception ex)
  16624. {
  16625. _sqlSugar.RollbackTran();
  16626. return Ok(JsonView(false, ex.Message));
  16627. }
  16628. //return Ok(JsonView(true));
  16629. }
  16630. private bool IsValidDate(string dateString, string format)
  16631. {
  16632. DateTime dateValue;
  16633. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16634. return valid;
  16635. }
  16636. /// <summary>
  16637. /// 接团客户名单
  16638. /// 根据团组Id查询List
  16639. /// </summary>
  16640. /// <param name="_dto"></param>
  16641. /// <returns></returns>
  16642. [HttpPost]
  16643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16644. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16645. {
  16646. #region 参数验证
  16647. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16648. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16649. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16650. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16651. #region 页面操作权限验证
  16652. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16653. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16654. #endregion
  16655. #endregion
  16656. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16657. if (viewData.Code != 0)
  16658. {
  16659. return Ok(JsonView(false, viewData.Msg));
  16660. }
  16661. return Ok(JsonView(viewData.Data));
  16662. }
  16663. /// <summary>
  16664. /// 接团客户名单
  16665. /// 基础数据 Init
  16666. /// </summary>
  16667. /// <param name="_dto"></param>
  16668. /// <returns></returns>
  16669. [HttpPost]
  16670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16671. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16672. {
  16673. #region 参数验证
  16674. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16675. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16677. #region 页面操作权限验证
  16678. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16679. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16680. #endregion
  16681. #endregion
  16682. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16683. }
  16684. /// <summary>
  16685. /// 接团客户名单
  16686. /// 根据 Id查询 Details
  16687. /// </summary>
  16688. /// <param name="_dto"></param>
  16689. /// <returns></returns>
  16690. [HttpPost]
  16691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16692. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16693. {
  16694. #region 参数验证
  16695. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16696. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16697. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16699. #region 页面操作权限验证
  16700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16701. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16702. #endregion
  16703. #endregion
  16704. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16705. if (viewData.Code != 0)
  16706. {
  16707. return Ok(JsonView(false, viewData.Msg));
  16708. }
  16709. return Ok(JsonView(viewData.Data));
  16710. }
  16711. /// <summary>
  16712. /// 接团客户名单
  16713. /// Add Or Edit
  16714. /// </summary>
  16715. /// <param name="_dto"></param>
  16716. /// <returns></returns>
  16717. [HttpPost]
  16718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16719. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16720. {
  16721. #region 参数验证
  16722. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16723. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16724. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16725. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16726. #region 页面操作权限验证
  16727. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16728. if (_dto.Id == 0) //添加
  16729. {
  16730. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16731. }
  16732. else if (_dto.Id >= 0) //修改
  16733. {
  16734. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16735. }
  16736. #endregion
  16737. #endregion
  16738. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16739. if (viewData.Code != 0)
  16740. {
  16741. return Ok(JsonView(false, viewData.Msg));
  16742. }
  16743. return Ok(JsonView(true));
  16744. }
  16745. /// <summary>
  16746. /// 接团客户名单
  16747. /// json字符串 AddMultiple(添加多个)
  16748. /// </summary>
  16749. /// <param name="_dto"></param>
  16750. /// <returns></returns>
  16751. [HttpPost]
  16752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16753. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16754. {
  16755. #region 参数验证
  16756. string jsonLabel = _dto.JsonLabel;
  16757. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16758. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16760. #region 页面操作权限验证
  16761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16762. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16763. #endregion
  16764. #endregion
  16765. var request = new TourClientListAddMultipleDto();
  16766. request.DiId = _dto.DiId;
  16767. request.UserId = _dto.UserId;
  16768. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16769. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16770. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16771. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16772. var infos = new List<TourClientListInfo>();
  16773. foreach (var data in datas)
  16774. {
  16775. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16776. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16777. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16778. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16779. {
  16780. continue;
  16781. }
  16782. infos.Add(new TourClientListInfo()
  16783. {
  16784. IsAccompany = 1,
  16785. LastName = lastName,
  16786. FirstName = firstName,
  16787. Pinyin = lastNameEn + @"/" + firstNameEn,
  16788. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16789. CompanyFullName = data.CompanyFullName,
  16790. Job = data.Job
  16791. });
  16792. }
  16793. if (infos.Any())
  16794. {
  16795. var viewData = await _tourClientListRep._AddMultiple(request);
  16796. if (viewData.Code != 0)
  16797. {
  16798. return Ok(JsonView(false, viewData.Msg));
  16799. }
  16800. return Ok(JsonView(true));
  16801. }
  16802. return Ok(JsonView(false));
  16803. }
  16804. /// <summary>
  16805. /// 接团客户名单
  16806. /// AddMultiple(添加多个)
  16807. /// </summary>
  16808. /// <param name="_dto"></param>
  16809. /// <returns></returns>
  16810. [HttpPost]
  16811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16812. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16813. {
  16814. #region 参数验证
  16815. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16816. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16817. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16818. #region 页面操作权限验证
  16819. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16820. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16821. #endregion
  16822. #endregion
  16823. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16824. if (viewData.Code != 0)
  16825. {
  16826. return Ok(JsonView(false, viewData.Msg));
  16827. }
  16828. return Ok(JsonView(true));
  16829. }
  16830. /// <summary>
  16831. /// 接团客户名单
  16832. /// Del
  16833. /// </summary>
  16834. /// <param name="_dto"></param>
  16835. /// <returns></returns>
  16836. [HttpPost]
  16837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16838. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16839. {
  16840. #region 参数验证
  16841. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16842. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16844. #region 页面操作权限验证
  16845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16846. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16847. #endregion
  16848. #endregion
  16849. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16850. if (viewData.Code != 0)
  16851. {
  16852. return Ok(JsonView(false, viewData.Msg));
  16853. }
  16854. return Ok(JsonView(true));
  16855. }
  16856. /// <summary>
  16857. /// 接团客户名单
  16858. /// 文件下载 客户名单
  16859. /// </summary>
  16860. /// <param name="_dto"></param>
  16861. /// <returns></returns>
  16862. [HttpPost]
  16863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16864. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16865. {
  16866. #region 参数验证
  16867. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16868. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16869. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16870. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16871. #region 页面操作权限验证
  16872. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16873. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16874. #endregion
  16875. #endregion
  16876. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16877. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16878. From Grp_TourClientList tcl
  16879. Left Join
  16880. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16881. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16882. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16883. From Crm_DeleClient dc
  16884. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16885. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16886. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16887. Where dc.IsDel = 0) temp
  16888. On temp.DcId =tcl.ClientId
  16889. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16890. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16891. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16892. //载入模板
  16893. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16894. if (_dto.Language == 1)
  16895. {
  16896. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16897. }
  16898. //载入模板
  16899. var doc = new Document(tempPath);
  16900. DocumentBuilder builder = new DocumentBuilder(doc);
  16901. //获取word里所有表格
  16902. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16903. //获取所填表格的序数
  16904. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16905. var rowStart = tableOne.Rows[0]; //获取第1行
  16906. if (_dto.Language == 0)
  16907. {
  16908. //循环赋值
  16909. for (int i = 0; i < DcList.Count; i++)
  16910. {
  16911. EncryptionProcessor.DecryptProperties(DcList[i]);
  16912. builder.MoveToCell(0, i + 1, 0, 0);
  16913. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16914. builder.MoveToCell(0, i + 1, 1, 0);
  16915. int sex = DcList[i].Sex;
  16916. string sexStr = string.Empty;
  16917. if (sex == 0) sexStr = "男";
  16918. else if (sex == 1) sexStr = "女";
  16919. else sexStr = "未设置";
  16920. builder.Write(sexStr);
  16921. builder.MoveToCell(0, i + 1, 2, 0);
  16922. string birthDay = DcList[i].BirthDay;
  16923. string birthDayStr = string.Empty;
  16924. if (!string.IsNullOrEmpty(birthDay))
  16925. {
  16926. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16927. }
  16928. builder.Write(birthDayStr);
  16929. builder.MoveToCell(0, i + 1, 3, 0);
  16930. string company = "";
  16931. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16932. {
  16933. company = DcList[i].CompanyFullName.ToString();
  16934. }
  16935. builder.Write(company);
  16936. builder.MoveToCell(0, i + 1, 4, 0);
  16937. builder.Write(DcList[i].Job);
  16938. }
  16939. }
  16940. else if (_dto.Language == 1)
  16941. {
  16942. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16943. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16944. List<string> transArrayStr = new List<string>();
  16945. string transStrRes1 = "";
  16946. for (int i = 0; i < DcList.Count; i++)
  16947. {
  16948. var dc = DcList[i];
  16949. EncryptionProcessor.DecryptProperties(dc);
  16950. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16951. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16952. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16953. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16954. else transStrRes1 += $"{str1}|";
  16955. }
  16956. //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";
  16957. string transStrRes = "";
  16958. if (transStrRes1.Length > 0)
  16959. {
  16960. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16961. }
  16962. //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
  16963. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16964. //List<string> transArray = new List<string> { };
  16965. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16966. if (transStrRes.Contains("|"))
  16967. {
  16968. string[] transArray1 = transStrRes.Split('|');
  16969. if (transArray1.Length > 0)
  16970. {
  16971. foreach (var item in transArray1)
  16972. {
  16973. if (item.Contains("&"))
  16974. {
  16975. string[] transArray2 = item.Split('&');
  16976. int index = 0;
  16977. string companyName = "", job = "";
  16978. if (transArray2.Length > 0)
  16979. {
  16980. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16981. if (1 < transArray2.Length) companyName = transArray2[1];
  16982. if (2 < transArray2.Length) job = transArray2[2];
  16983. }
  16984. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16985. }
  16986. }
  16987. }
  16988. }
  16989. //循环赋值
  16990. for (int i = 0; i < DcList.Count; i++)
  16991. {
  16992. string PYName = "";
  16993. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16994. {
  16995. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16996. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16997. PYName = PY_First + " " + PY_Last;
  16998. }
  16999. else
  17000. {
  17001. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17002. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17003. PYName = PY_First + " " + PY_Last;
  17004. }
  17005. builder.MoveToCell(0, i + 1, 0, 0);
  17006. builder.Write(PYName);
  17007. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17008. builder.MoveToCell(0, i + 1, 1, 0);
  17009. builder.Write(sex);
  17010. DateTime birthDt;
  17011. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17012. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17013. builder.MoveToCell(0, i + 1, 2, 0);
  17014. builder.Write(birthday);
  17015. string company = string.Empty, job = string.Empty;
  17016. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17017. if (dcTransInfo != null)
  17018. {
  17019. company = dcTransInfo.CompanyName;
  17020. job = dcTransInfo.Job;
  17021. }
  17022. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17023. {
  17024. //查询对照表
  17025. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17026. if (tempCec != null)
  17027. {
  17028. company = tempCec.enName;
  17029. }
  17030. //翻译
  17031. else
  17032. {
  17033. }
  17034. }
  17035. builder.MoveToCell(0, i + 1, 3, 0);
  17036. builder.Write(company);
  17037. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17038. {
  17039. //查询对照表
  17040. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17041. if (tempPec != null)
  17042. {
  17043. job = tempPec.enName;
  17044. }
  17045. //翻译
  17046. else
  17047. {
  17048. }
  17049. }
  17050. builder.MoveToCell(0, i + 1, 4, 0);
  17051. builder.Write(job);
  17052. }
  17053. }
  17054. //删除多余行
  17055. while (tableOne.Rows.Count > DcList.Count + 1)
  17056. {
  17057. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17058. }
  17059. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17060. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17061. doc.Save(fileDir);
  17062. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17063. return Ok(JsonView(true, "操作成功!", Url));
  17064. }
  17065. private class TranslateInfo
  17066. {
  17067. public int Index { get; set; }
  17068. public string CompanyName { get; set; }
  17069. public string Job { get; set; }
  17070. }
  17071. #endregion
  17072. #region 团组倒推表
  17073. /// <summary>
  17074. /// 倒推表基础数据
  17075. /// Init
  17076. /// </summary>
  17077. /// <returns></returns>
  17078. [HttpPost]
  17079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17080. public async Task<IActionResult> PostInvertedListInit()
  17081. {
  17082. var viewData = await _invertedListRep._Init();
  17083. if (viewData.Code != 0)
  17084. {
  17085. return Ok(JsonView(false, viewData.Msg));
  17086. }
  17087. return Ok(JsonView(viewData.Data));
  17088. }
  17089. /// <summary>
  17090. /// 倒推表
  17091. /// Info
  17092. /// </summary>
  17093. /// <param name="dto"></param>
  17094. /// <returns></returns>
  17095. [HttpPost]
  17096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17097. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17098. {
  17099. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17100. if (viewData.Code != 0)
  17101. {
  17102. return Ok(JsonView(false, viewData.Msg));
  17103. }
  17104. return Ok(JsonView(viewData.Data));
  17105. }
  17106. /// <summary>
  17107. /// 倒推表
  17108. /// Create
  17109. /// </summary>
  17110. /// <param name="dto"></param>
  17111. /// <returns></returns>
  17112. [HttpPost]
  17113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17114. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17115. {
  17116. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17117. if (viewData.Code != 0)
  17118. {
  17119. return Ok(JsonView(false, viewData.Msg));
  17120. }
  17121. return Ok(JsonView(viewData.Data));
  17122. }
  17123. /// <summary>
  17124. /// 倒推表
  17125. /// Update
  17126. /// </summary>
  17127. /// <param name="dto"></param>
  17128. /// <returns></returns>
  17129. [HttpPost]
  17130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17131. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17132. {
  17133. var viewData = await _invertedListRep._Update(dto);
  17134. if (viewData.Code != 0)
  17135. {
  17136. return Ok(JsonView(false, viewData.Msg));
  17137. }
  17138. return Ok(JsonView(viewData.Data));
  17139. }
  17140. /// <summary>
  17141. /// 倒推表
  17142. /// File Download
  17143. /// </summary>
  17144. /// <param name="dto"></param>
  17145. /// <returns></returns>
  17146. [HttpPost]
  17147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17148. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17149. {
  17150. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17151. if (info2.Code != 0)
  17152. {
  17153. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17154. }
  17155. var info1 = info2.Data as InvertedListInfoView;
  17156. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17157. string teamName = "";
  17158. if (info != null) teamName = info.TeamName;
  17159. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17160. var doc = new Document();
  17161. var builder = new DocumentBuilder(doc);
  17162. #region old insert
  17163. ////载入模板
  17164. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17165. //Document doc = new Document(tempPath);
  17166. //DocumentBuilder builder = new DocumentBuilder(doc);
  17167. //利用键值对存放数据
  17168. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17169. //dic.Add("TeamName", teamName);
  17170. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17171. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17172. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17173. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17174. //dic.Add("SQRemark", info1.ApprovalRemark);
  17175. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17176. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17177. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17178. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17179. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17180. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17181. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17182. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17183. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17184. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17185. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17186. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17187. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17188. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17189. //#region 填充word模板书签内容
  17190. //foreach (var key in dic.Keys)
  17191. //{
  17192. // builder.MoveToBookmark(key);
  17193. // builder.Write(dic[key]);
  17194. //}
  17195. //#endregion
  17196. #endregion
  17197. #region New Insert
  17198. string titleFont = $"仿宋",
  17199. contentFont = $"仿宋";
  17200. var fontColor = Color.FromArgb(64, 64, 64);
  17201. //设置标题 团组名称
  17202. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17203. builder.Font.Name = titleFont;
  17204. builder.Font.Color = fontColor;
  17205. builder.Font.Size = 12;
  17206. builder.Font.Bold = true;
  17207. builder.Writeln(teamName);
  17208. //设置副标题 团组出访时间
  17209. builder.Font.Size = 12;
  17210. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17211. builder.Writeln();
  17212. var backgroundColor = Color.FromArgb(199, 199, 199);
  17213. var table = builder.StartTable();
  17214. builder.InsertCell();
  17215. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17216. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17217. builder.CellFormat.Borders.LineWidth = 1;
  17218. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17219. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17220. builder.RowFormat.Height = 40;
  17221. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17222. builder.Font.Name = contentFont;
  17223. builder.Font.Size = 12;
  17224. builder.Font.Bold = true;
  17225. builder.Font.Color = fontColor;
  17226. builder.Write("时间");
  17227. builder.InsertCell();
  17228. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17229. builder.Write("流程");
  17230. builder.InsertCell();
  17231. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17232. builder.Write("说明");
  17233. builder.EndRow();
  17234. //报批资料准备
  17235. if (info1.IsSelectedAirportd)
  17236. {
  17237. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17238. }
  17239. //报批/提供送签资料
  17240. if (info1.IsSelectedApprovalData)
  17241. {
  17242. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17243. }
  17244. //出批件护照办理
  17245. if (info1.IsSelectedIssueApproval)
  17246. {
  17247. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17248. }
  17249. //签证资料准备
  17250. if (info1.IsSelectedVisaInfo)
  17251. {
  17252. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17253. }
  17254. //送签
  17255. if (info1.IsSelectedSendVisa)
  17256. {
  17257. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17258. }
  17259. //出签
  17260. if (info1.IsSelectedIssueVisa)
  17261. {
  17262. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17263. }
  17264. //机票
  17265. if (info1.IsSelectedAirTicket)
  17266. {
  17267. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17268. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17269. }
  17270. //酒店
  17271. if (info1.IsSelectedHotel)
  17272. {
  17273. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17274. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17275. }
  17276. //开行前会
  17277. if (info1.IsSelectedPreTripMeeting)
  17278. {
  17279. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17280. }
  17281. //送机
  17282. if (info1.IsSelectedAirportdDropOff)
  17283. {
  17284. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17285. }
  17286. builder.EndTable();
  17287. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17288. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17289. for (int i = 0; i < table.Rows.Count; i++)
  17290. {
  17291. var row = table.Rows[i];
  17292. //设置宽度
  17293. row.Cells[0].CellFormat.Width = 20.00;
  17294. row.Cells[1].CellFormat.Width = 30.00;
  17295. row.Cells[2].CellFormat.Width = 50.00;
  17296. if (i != 0)
  17297. {
  17298. //边框设置
  17299. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17300. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17301. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17302. }
  17303. }
  17304. #region 页脚插入图片
  17305. // 创建页脚
  17306. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17307. doc.FirstSection.HeadersFooters.Add(footer);
  17308. Paragraph para = new Paragraph(doc);
  17309. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17310. footer.AppendChild(para);
  17311. builder.MoveTo(para);
  17312. string imagePath = "./Images/FMGJ_Log.png";
  17313. builder.InsertImage(imagePath);
  17314. #endregion
  17315. #endregion
  17316. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17317. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17318. string filePath = fileDir + $@"InvertedList/{fileName}";
  17319. doc.Save(filePath);
  17320. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17321. return Ok(JsonView(true, "操作成功!", Url));
  17322. }
  17323. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17324. {
  17325. var fontColor = Color.FromArgb(64, 64, 64);
  17326. builder.InsertCell();
  17327. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17328. builder.RowFormat.Height = 40;
  17329. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17330. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17331. builder.Font.Name = fontName;
  17332. builder.Font.Size = 8;
  17333. builder.Font.Bold = true;
  17334. builder.Font.Color = fontColor;
  17335. builder.Write(dateTime);
  17336. builder.InsertCell();
  17337. builder.Font.Size = 9;
  17338. builder.Font.Bold = true;
  17339. builder.Font.Color = fontColor;
  17340. builder.Write(content);
  17341. builder.InsertCell();
  17342. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17343. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17344. builder.Font.Size = 9;
  17345. builder.Font.Bold = false;
  17346. builder.Font.Color = fontColor;
  17347. builder.Write(reamrk);
  17348. builder.EndRow();
  17349. }
  17350. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17351. {
  17352. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17353. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17354. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17355. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17356. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17357. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17358. }
  17359. #endregion
  17360. #region 会务倒推表
  17361. /// <summary>
  17362. /// 会务倒推表
  17363. /// Init
  17364. /// </summary>
  17365. /// <returns></returns>
  17366. [HttpPost]
  17367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17368. public async Task<IActionResult> InforRetrogressTableInit()
  17369. {
  17370. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17371. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17372. return Ok(JsonView(false, groupData.Msg));
  17373. }
  17374. /// <summary>
  17375. /// 会务倒推表
  17376. /// ExcelDownload
  17377. /// </summary>
  17378. /// <param name="dto"></param>
  17379. /// <returns></returns>
  17380. [HttpPost]
  17381. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17383. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17384. {
  17385. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17386. var validatorRes = await validator.ValidateAsync(dto);
  17387. if (!validatorRes.IsValid)
  17388. {
  17389. StringBuilder sb = new StringBuilder();
  17390. foreach (var item in validatorRes.Errors)
  17391. {
  17392. sb.AppendLine(item.ErrorMessage);
  17393. }
  17394. return Ok(JsonView(false, sb.ToString()));
  17395. }
  17396. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17397. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17398. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17399. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17400. #region Excel
  17401. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17402. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17403. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17404. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17405. var fileNamePrefix = string.Empty;
  17406. if (days >= 30)
  17407. {
  17408. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17409. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17410. }
  17411. else if (days < 30 && days > 7)
  17412. {
  17413. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17414. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17415. }
  17416. else if (days <= 7)
  17417. {
  17418. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17419. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17420. }
  17421. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17422. fileName = CommonFun.ValidFileName(fileName);
  17423. //载入模板
  17424. WorkbookDesigner designer = new WorkbookDesigner();
  17425. designer.Workbook = new Workbook(tempPath);
  17426. designer.Process();
  17427. if (!Directory.Exists(savePath))
  17428. {
  17429. Directory.CreateDirectory(savePath);
  17430. }
  17431. string serverPath = $"{savePath}{fileName}";
  17432. designer.Workbook.Save(serverPath);
  17433. string rst = $"{servicePath}{ftpPath}{fileName}";
  17434. #endregion
  17435. return Ok(JsonView(new { url = rst }));
  17436. }
  17437. #endregion
  17438. #region 三公签证费用(签证费、代办费)
  17439. /// <summary>
  17440. /// 三公签证费用(签证费、代办费)
  17441. /// List
  17442. /// </summary>
  17443. /// <returns></returns>
  17444. [HttpPost]
  17445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17446. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17447. {
  17448. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17449. if (_view.Code != 0)
  17450. {
  17451. return Ok(JsonView(false, _view.Msg));
  17452. }
  17453. return Ok(JsonView(true, "操作成功!", _view.Data));
  17454. }
  17455. /// <summary>
  17456. /// 三公签证费用(签证费、代办费)
  17457. /// Add Or Update
  17458. /// </summary>
  17459. /// <returns></returns>
  17460. [HttpPost]
  17461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17462. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17463. {
  17464. var _view = await _visaFeeInfoRep._Update(_dto);
  17465. if (_view.Code != 0)
  17466. {
  17467. return Ok(JsonView(false, _view.Msg));
  17468. }
  17469. return Ok(JsonView(true, _view.Msg));
  17470. }
  17471. #endregion
  17472. #region 酒店询价
  17473. /// <summary>
  17474. /// 酒店询价
  17475. /// Init
  17476. /// </summary>
  17477. /// <returns></returns>
  17478. [HttpPost]
  17479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17480. public async Task<IActionResult> PostHotelInquiryInit()
  17481. {
  17482. var res = await _hotelInquiryRep._Init();
  17483. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17484. return Ok(JsonView(true, res.Msg, res.Data));
  17485. }
  17486. /// <summary>
  17487. /// 酒店询价
  17488. /// page Item
  17489. /// </summary>
  17490. /// <param name="_dto"></param>
  17491. /// <returns></returns>
  17492. [HttpPost]
  17493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17494. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17495. {
  17496. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17497. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17498. var view = res.Data as PageDataViewBase;
  17499. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17500. }
  17501. /// <summary>
  17502. /// 酒店询价
  17503. /// info
  17504. /// </summary>
  17505. /// <param name="_dto"></param>
  17506. /// <returns></returns>
  17507. [HttpPost]
  17508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17509. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17510. {
  17511. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17512. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17513. return Ok(JsonView(true, res.Msg, res.Data));
  17514. }
  17515. /// <summary>
  17516. /// 酒店询价
  17517. /// Add Or Edit
  17518. /// </summary>
  17519. /// <param name="_dto"></param>
  17520. /// <returns></returns>
  17521. [HttpPost]
  17522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17523. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17524. {
  17525. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17526. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17527. return Ok(JsonView(true, res.Msg, res.Data));
  17528. }
  17529. /// <summary>
  17530. /// 酒店询价
  17531. /// Del
  17532. /// </summary>
  17533. /// <param name="_dto"></param>
  17534. /// <returns></returns>
  17535. [HttpPost]
  17536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17537. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17538. {
  17539. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17540. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17541. return Ok(JsonView(true, res.Msg, res.Data));
  17542. }
  17543. #endregion
  17544. #region 下载匹配op行程单
  17545. /// <summary>
  17546. /// 匹配op行程单
  17547. /// Init
  17548. /// </summary>
  17549. /// <param name="dto">团组列表请求dto</param>
  17550. /// <returns></returns>
  17551. [HttpPost]
  17552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17553. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17554. {
  17555. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17556. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17557. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17558. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17559. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17560. .Where(it => it.IsDel == 0)
  17561. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17562. .OrderByDescending(it => it.VisitStartDate)
  17563. .ToList();
  17564. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17565. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17566. var diids = groupInfos.Select(it => it.Id).ToList();
  17567. List<string> countrys = new List<string>();
  17568. foreach (var item in country)
  17569. {
  17570. var data = _groupRepository.FormartTeamName(item);
  17571. var dataArray = _groupRepository.GroupSplitCountry(data);
  17572. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17573. }
  17574. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17575. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17576. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17577. foreach (var item in areaItem)
  17578. {
  17579. string areaStr = item.Value;
  17580. if (!string.IsNullOrEmpty(areaStr))
  17581. {
  17582. string[] str1 = areaStr.Split("-");
  17583. if (str1.Length > 0)
  17584. {
  17585. areaArray.AddRange(str1);
  17586. }
  17587. }
  17588. }
  17589. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17590. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17591. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17592. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17593. .ToList();
  17594. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17595. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17596. .Where(it => countriesIds.Contains(it.Id))
  17597. .Select(it => new { it.Id, Name = it.Name_CN })
  17598. .ToList();
  17599. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17600. .Select(it => it.TeamName).ToList();
  17601. stopwatch.Stop();
  17602. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17603. }
  17604. ///// <summary>
  17605. ///// 匹配op行程单
  17606. ///// Init 查询区域数据
  17607. ///// </summary>
  17608. ///// <param name="dto">团组列表请求dto</param>
  17609. ///// <returns></returns>
  17610. //[HttpPost]
  17611. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17612. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17613. //{
  17614. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17615. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17616. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17617. // if (string.IsNullOrEmpty(countriesDataStr))
  17618. // {
  17619. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17620. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17621. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17622. // }
  17623. // else
  17624. // {
  17625. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17626. // }
  17627. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17628. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17629. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17630. // List<dynamic> childList = new List<dynamic>();
  17631. // int parentId = dto.CountriesId;
  17632. // if (provinceData.Count > 1)
  17633. // {
  17634. // foreach (var item1 in provinceData)
  17635. // {
  17636. // List<dynamic> childList1 = new List<dynamic>();
  17637. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17638. // foreach (var item2 in citiesData1)
  17639. // {
  17640. // List<dynamic> childList2 = new List<dynamic>();
  17641. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17642. // foreach (var item3 in countiesData1)
  17643. // {
  17644. // childList2.Add(new
  17645. // {
  17646. // id = item3.Id,
  17647. // parentId = item2.Id,
  17648. // level = "district",
  17649. // name = item3.Name_CN,
  17650. // });
  17651. // }
  17652. // childList1.Add(new
  17653. // {
  17654. // id = item2.Id,
  17655. // parentId = item1.Id,
  17656. // level = "city",
  17657. // name = item2.Name_CN,
  17658. // childList = childList2
  17659. // });
  17660. // }
  17661. // childList.Add(new
  17662. // {
  17663. // id = item1.Id,
  17664. // parentId = parentId,
  17665. // level = "province",
  17666. // name = item1.Name_CN,
  17667. // childList = childList1
  17668. // });
  17669. // }
  17670. // //城市
  17671. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17672. // foreach (var item2 in citiesData2)
  17673. // {
  17674. // List<dynamic> childList22 = new List<dynamic>();
  17675. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17676. // foreach (var item3 in countiesData1)
  17677. // {
  17678. // childList22.Add(new
  17679. // {
  17680. // id = item3.Id,
  17681. // parentId = item2.Id,
  17682. // level = "district",
  17683. // name = item3.Name_CN,
  17684. // });
  17685. // }
  17686. // childList.Add(new
  17687. // {
  17688. // id = item2.Id,
  17689. // parentId = parentId,
  17690. // level = "city",
  17691. // name = item2.Name_CN,
  17692. // childList = childList22
  17693. // });
  17694. // }
  17695. // }
  17696. // else
  17697. // {
  17698. // foreach (var item2 in citiesData)
  17699. // {
  17700. // string cname = item2.Name_CN;
  17701. // List<dynamic> childList1 = new List<dynamic>();
  17702. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17703. // foreach (var item3 in countiesData1)
  17704. // {
  17705. // childList1.Add(new
  17706. // {
  17707. // Id = item3.Id,
  17708. // parentId = item2.Id,
  17709. // level = "district",
  17710. // name = item3.Name_CN
  17711. // });
  17712. // }
  17713. // childList.Add(new
  17714. // {
  17715. // id = item2.Id,
  17716. // parentId = parentId,
  17717. // level = "city",
  17718. // name = item2.Name_CN,
  17719. // childList = childList1
  17720. // });
  17721. // }
  17722. // }
  17723. // stopwatch.Stop();
  17724. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17725. //}
  17726. /// <summary>
  17727. /// 匹配op行程单
  17728. /// 接团信息列表 Page
  17729. /// </summary>
  17730. /// <param name="dto">团组列表请求dto</param>
  17731. /// <returns></returns>
  17732. [HttpPost]
  17733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17734. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17735. {
  17736. var swatch = new Stopwatch();
  17737. swatch.Start();
  17738. #region 参数验证
  17739. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17740. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17741. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17742. #region 页面操作权限验证
  17743. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17744. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17745. #endregion
  17746. #endregion
  17747. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17748. {
  17749. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17750. //string sqlWhere = "";
  17751. if (!string.IsNullOrEmpty(dto.Country))
  17752. {
  17753. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17754. }
  17755. if (!string.IsNullOrEmpty(dto.Area))
  17756. {
  17757. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17758. }
  17759. if (!string.IsNullOrEmpty(dto.TeamName))
  17760. {
  17761. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17762. }
  17763. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17764. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17765. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17766. swatch.Stop();
  17767. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17768. }
  17769. else
  17770. {
  17771. return Ok(JsonView(false, "查询失败"));
  17772. }
  17773. }
  17774. /// <summary>
  17775. /// 匹配op行程单
  17776. /// 行程单下载
  17777. /// </summary>
  17778. /// <param name="dto">团组列表请求dto</param>
  17779. /// <returns></returns>
  17780. [HttpPost]
  17781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17782. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17783. {
  17784. #region 参数验证
  17785. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17786. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17787. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17788. #region 页面操作权限验证
  17789. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17790. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17791. #endregion
  17792. #endregion
  17793. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17794. {
  17795. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17796. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17797. }
  17798. else
  17799. {
  17800. return Ok(JsonView(false, "下载失败!"));
  17801. }
  17802. }
  17803. #endregion
  17804. #region 国家信息 数据 注释
  17805. //[HttpPost]
  17806. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17807. //{
  17808. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17809. // foreach (var item in dto)
  17810. // {
  17811. // infos.Add(new Grp_GroupsTaskAssignment()
  17812. // {
  17813. // DIId = item,
  17814. // CTId = 82,
  17815. // UId = 248,
  17816. // IsEnable = 1,
  17817. // CreateUserId = 233,
  17818. // CreateTime = DateTime.Now,
  17819. // IsDel = 0
  17820. // });
  17821. // infos.Add(new Grp_GroupsTaskAssignment()
  17822. // {
  17823. // DIId = item,
  17824. // CTId = 82,
  17825. // UId = 286,
  17826. // IsEnable = 1,
  17827. // CreateUserId = 233,
  17828. // CreateTime = DateTime.Now,
  17829. // IsDel = 0
  17830. // });
  17831. // }
  17832. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17833. // return Ok("操作成功");
  17834. //}
  17835. //public class paramJsonDto
  17836. //{
  17837. // public List<CountriesInfo> str { get; set; }
  17838. //}
  17839. //[HttpPost]
  17840. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17841. //{
  17842. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17843. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17844. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17845. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17846. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17847. // _sqlSugar.BeginTran();
  17848. // int countitiesIndex = 0;
  17849. // foreach (var item in dto.str)
  17850. // {
  17851. // dynamic data = item.c;
  17852. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17853. // if (data != null)
  17854. // {
  17855. // countitiesIndex++;
  17856. // foreach (var item1 in data)
  17857. // {
  17858. // string cnname = item1.cn;
  17859. // string enname = item1.en;
  17860. // Sys_Cities provinceInfo = new Sys_Cities()
  17861. // {
  17862. // CountriesId = countriesId,
  17863. // Name_CN = cnname,
  17864. // Name_EN = enname,
  17865. // ParentId = 0,
  17866. // IsCapital = 1,
  17867. // CreateUserId = 208,
  17868. // CreateTime = DateTime.Now,
  17869. // IsDel = 0
  17870. // };
  17871. // if (item1.lv == "province") //省份
  17872. // {
  17873. // provinceInfo.Level = 1;
  17874. // int provinceId = 0;
  17875. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17876. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17877. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17878. // var data1 = item1.c;
  17879. // foreach (var item2 in data1)
  17880. // {
  17881. // if (item2.lv == "city")
  17882. // {
  17883. // string citycnname = item2.cn;
  17884. // string cityenname = item2.en;
  17885. // Sys_Cities cityInfo = new Sys_Cities()
  17886. // {
  17887. // CountriesId = countriesId,
  17888. // ParentId = provinceId,
  17889. // Level = 2,
  17890. // Name_CN = citycnname,
  17891. // Name_EN = cityenname,
  17892. // IsCapital = 1,
  17893. // CreateUserId = 208,
  17894. // CreateTime = DateTime.Now,
  17895. // IsDel = 0
  17896. // };
  17897. // if (item2.c != null)
  17898. // {
  17899. // int cityId = 0;
  17900. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17901. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17902. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17903. // foreach (var item3 in item2.c)
  17904. // {
  17905. // if (item3.lv == "district")
  17906. // {
  17907. // var districtInfo = new Sys_Cities()
  17908. // {
  17909. // CountriesId = countriesId,
  17910. // Name_CN = item3.cn,
  17911. // Name_EN = item3.en,
  17912. // Level = 3,
  17913. // ParentId = cityId,
  17914. // IsCapital = 1,
  17915. // CreateUserId = 208,
  17916. // CreateTime = DateTime.Now,
  17917. // IsDel = 0
  17918. // };
  17919. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17920. // //{
  17921. // districts.Add(districtInfo);
  17922. // //}
  17923. // }
  17924. // }
  17925. // }
  17926. // else
  17927. // {
  17928. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17929. // //{
  17930. // cities.Add(cityInfo);
  17931. // //}
  17932. // }
  17933. // }
  17934. // }
  17935. // }
  17936. // else if (item1.lv == "city")//城市
  17937. // {
  17938. // provinceInfo.Level = 2;
  17939. // if (item1.c != null)
  17940. // {
  17941. // int cityId = 0;
  17942. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17943. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17944. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17945. // foreach (var item3 in item1.c)
  17946. // {
  17947. // if (item3.lv == "district")
  17948. // {
  17949. // var districtInfo = new Sys_Cities()
  17950. // {
  17951. // CountriesId = countriesId,
  17952. // Name_CN = item3.cn,
  17953. // Name_EN = item3.en,
  17954. // Level = 3,
  17955. // ParentId = cityId,
  17956. // IsCapital = 1,
  17957. // CreateUserId = 208,
  17958. // CreateTime = DateTime.Now,
  17959. // IsDel = 0
  17960. // };
  17961. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17962. // //{
  17963. // districts.Add(districtInfo);
  17964. // //}
  17965. // }
  17966. // }
  17967. // }
  17968. // else
  17969. // {
  17970. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17971. // //{
  17972. // cities.Add(provinceInfo);
  17973. // //}
  17974. // }
  17975. // }
  17976. // }
  17977. // }
  17978. // }
  17979. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17980. // cities = cities.Distinct().ToList();
  17981. // districts = districts.Distinct().ToList();
  17982. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17983. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17984. // cities.AddRange(districts);
  17985. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17986. // //_sqlSugar.RollbackTran();
  17987. // _sqlSugar.CommitTran();
  17988. // return Ok(JsonView(false, "操作成功!"));
  17989. //}
  17990. //[HttpPost]
  17991. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17992. //{
  17993. // List<CountitiesInfo> infos = dto.MyProperty;
  17994. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17995. // _sqlSugar.BeginTran();
  17996. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17997. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17998. // foreach (var item in infos)
  17999. // {
  18000. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18001. // if (countryInfo != null)
  18002. // {
  18003. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18004. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18005. // if (cityInfo1 != null)
  18006. // {
  18007. // cityInfo1.IsCapital = 0;
  18008. // cityInfos.Add(cityInfo1);
  18009. // }
  18010. // }
  18011. // }
  18012. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18013. // .UpdateColumns(it => it.IsCapital)
  18014. // .WhereColumns(it => it.Id)
  18015. // .ExecuteCommand();
  18016. // //_sqlSugar.RollbackTran();
  18017. // _sqlSugar.CommitTran();
  18018. // return Ok(JsonView(false, "操作成功!"));
  18019. //}
  18020. //public class CounrtiesDto
  18021. //{
  18022. // public List<CountitiesInfo> MyProperty { get; set; }
  18023. //}
  18024. //public class CountitiesInfo
  18025. //{
  18026. // /// <summary>
  18027. // /// 圣约翰
  18028. // /// </summary>
  18029. // public string capital_name_chinese { get; set; }
  18030. // /// <summary>
  18031. // ///
  18032. // /// </summary>
  18033. // public string capital_name { get; set; }
  18034. // /// <summary>
  18035. // ///
  18036. // /// </summary>
  18037. // public string country_type { get; set; }
  18038. // /// <summary>
  18039. // /// 安提瓜和巴布达
  18040. // /// </summary>
  18041. // public string country_name_chinese { get; set; }
  18042. // /// <summary>
  18043. // /// 安提瓜和巴布达
  18044. // /// </summary>
  18045. // public string country_name_chinese_short { get; set; }
  18046. // /// <summary>
  18047. // /// 安提瓜和巴布达
  18048. // /// </summary>
  18049. // public string country_name_chinese_UN { get; set; }
  18050. // /// <summary>
  18051. // ///
  18052. // /// </summary>
  18053. // public string country_name_english_abbreviation { get; set; }
  18054. // /// <summary>
  18055. // ///
  18056. // /// </summary>
  18057. // public string country_name_english_formal { get; set; }
  18058. // /// <summary>
  18059. // ///
  18060. // /// </summary>
  18061. // public string country_name_english_UN { get; set; }
  18062. // /// <summary>
  18063. // ///
  18064. // /// </summary>
  18065. // public string continent_name { get; set; }
  18066. // /// <summary>
  18067. // ///
  18068. // /// </summary>
  18069. // public string subregion_name { get; set; }
  18070. // /// <summary>
  18071. // ///
  18072. // /// </summary>
  18073. // public string country_code2 { get; set; }
  18074. // /// <summary>
  18075. // ///
  18076. // /// </summary>
  18077. // public string country_code3 { get; set; }
  18078. // /// <summary>
  18079. // ///
  18080. // /// </summary>
  18081. // public string phone_code { get; set; }
  18082. //}
  18083. //public class CountriesInfo : BasicInfo
  18084. //{
  18085. // public List<CitiesInfo> c { get; set; }
  18086. //}
  18087. //public class CitiesInfo : BasicInfo
  18088. //{
  18089. // public List<AreaInfo> c { get; set; }
  18090. //}
  18091. //public class AreaInfo : BasicInfo
  18092. //{
  18093. // public List<AreaInfo> c { get; set; }
  18094. //}
  18095. //public class BasicInfo
  18096. //{
  18097. // public string code { get; set; }
  18098. // public string cn { get; set; }
  18099. // public string lv { get; set; }
  18100. // public string en { get; set; }
  18101. //}
  18102. #endregion
  18103. #region 查看邀请方
  18104. /// <summary>
  18105. /// 查看邀请方
  18106. /// 邀请方信息 Init
  18107. /// </summary>
  18108. /// <param name="dto"></param>
  18109. /// <returns></returns>
  18110. [HttpPost]
  18111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18112. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18113. {
  18114. string sqlWhere = string.Empty;
  18115. if (!string.IsNullOrEmpty(dto.Search))
  18116. {
  18117. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18118. }
  18119. string sql = string.Format($@"Select
  18120. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18121. Id,
  18122. UnitName
  18123. From Res_InvitationOfficialActivityData
  18124. Where IsDel = 0
  18125. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18126. RefAsync<int> total = 0;
  18127. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18128. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18129. }
  18130. /// <summary>
  18131. /// 查看邀请方
  18132. /// 国家信息 Init
  18133. /// </summary>
  18134. /// <param name="dto"></param>
  18135. /// <returns></returns>
  18136. [HttpPost]
  18137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18138. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18139. {
  18140. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18141. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18142. var diids = groupInfos.Select(it => it.Id).ToList();
  18143. List<string> countrys = new List<string>();
  18144. foreach (var item in country)
  18145. {
  18146. var data = _groupRepository.FormartTeamName(item);
  18147. var dataArray = _groupRepository.GroupSplitCountry(data);
  18148. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18149. }
  18150. countrys = countrys.Distinct().ToList();
  18151. for (int i = 0; i < countrys.Count; i++)
  18152. {
  18153. string item = countrys[i];
  18154. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18155. {
  18156. countrys.Remove(item);
  18157. i--;
  18158. }
  18159. }
  18160. RefAsync<int> total = 0;
  18161. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18162. .Where(it => countrys.Contains(it.Name_CN))
  18163. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18164. .Select(it => new { id = it.Id, name = it.Name_CN })
  18165. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18166. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18167. }
  18168. /// <summary>
  18169. /// 查看邀请方
  18170. /// 城市信息 Init
  18171. /// </summary>
  18172. /// <param name="dto"></param>
  18173. /// <returns></returns>
  18174. [HttpPost]
  18175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18176. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18177. {
  18178. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18179. RefAsync<int> total = 0;
  18180. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18181. .Where(it => it.CountriesId == dto.CountiesId)
  18182. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18183. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18184. .Select(it => new { id = it.Id, name = it.Name_CN })
  18185. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18186. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18187. }
  18188. /// <summary>
  18189. /// 查看邀请方
  18190. /// 团组名称 Init
  18191. /// </summary>
  18192. /// <param name="dto"></param>
  18193. /// <returns></returns>
  18194. [HttpPost]
  18195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18196. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18197. {
  18198. var watch = new Stopwatch();
  18199. watch.Start();
  18200. RefAsync<int> total = 0;
  18201. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18202. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18203. .Where((oa, di) => oa.IsDel == 0)
  18204. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18205. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18206. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18207. .Distinct()
  18208. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18209. watch.Stop();
  18210. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18211. }
  18212. /// <summary>
  18213. /// 查看邀请方
  18214. /// 团组 & 邀请方信息
  18215. /// </summary>
  18216. /// <param name="dto"></param>
  18217. /// <returns></returns>
  18218. [HttpPost]
  18219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18220. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18221. {
  18222. var watch = new Stopwatch();
  18223. watch.Start();
  18224. RefAsync<int> total = 0;
  18225. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18226. .AS("Grp_DelegationInfo")
  18227. .Includes(x => x.InvitingInfos)
  18228. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18229. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18230. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18231. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18232. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18233. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18234. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18235. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18236. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18237. infos.ForEach(x =>
  18238. {
  18239. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18240. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18241. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18242. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18243. });
  18244. watch.Stop();
  18245. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18246. }
  18247. #endregion
  18248. #region 报批行程
  18249. /// <summary>
  18250. /// 报批行程初始化
  18251. /// </summary>
  18252. /// <param name="dto"></param>
  18253. /// <returns></returns>
  18254. [HttpPost]
  18255. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18256. {
  18257. const int chiNumber = 5;
  18258. var jw = JsonView(false);
  18259. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18260. var group = groupList.First();
  18261. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18262. group = groupList.First(x => x.Id == diid);
  18263. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18264. .Where(x => x.DiId == diid && x.IsDel == 0)
  18265. .ToArray();
  18266. var count = 1;
  18267. foreach (var item in blackCodeList)
  18268. {
  18269. if (string.IsNullOrWhiteSpace(item.Title))
  18270. {
  18271. item.Title = "未设置名称数据" + count;
  18272. }
  18273. count++;
  18274. };
  18275. if (group == null)
  18276. {
  18277. jw.Msg = "暂无团组!";
  18278. return Ok(jw);
  18279. }
  18280. var data = new
  18281. {
  18282. groupList = groupList.Select(x => new
  18283. {
  18284. x.TeamName,
  18285. x.Id
  18286. }),
  18287. content = new ArrayList(),
  18288. groupInfo = new
  18289. {
  18290. group.VisitDays,
  18291. group.TourCode,
  18292. group.VisitPNumber,
  18293. group.TeamName,
  18294. group.Id,
  18295. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18296. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18297. },
  18298. blackCodeList = blackCodeList.Select(x => new
  18299. {
  18300. x.Title,
  18301. x.Id
  18302. }),
  18303. FileTempList = new ArrayList()
  18304. {
  18305. new { Index = 1,FileName = "旧模板" },
  18306. new { Index = 2,FileName = "省外办" },
  18307. new { Index = 3,FileName = "市外办" },
  18308. }
  18309. };
  18310. var resultArr = new ArrayList();
  18311. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18312. #region 默认不生成行程
  18313. //if (content.Count == 0)
  18314. //{
  18315. // var stay = "-";
  18316. // var cityPath = "-";
  18317. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18318. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18319. // .ToList();
  18320. // //添加城市路径以及住宿地
  18321. // //黑屏代码数据
  18322. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18323. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18324. // {
  18325. // jw = JsonView(true, "黑屏代码有误!", data);
  18326. // return Ok(jw);
  18327. // }
  18328. // data = data with
  18329. // {
  18330. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18331. // {
  18332. // x.Title,
  18333. // x.Id,
  18334. // }).ToArray())
  18335. // };
  18336. // foreach (DataRow row in dtBlack.Rows)
  18337. // {
  18338. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18339. // {
  18340. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18341. // return Ok(jw);
  18342. // }
  18343. // }
  18344. // //黑屏代码获取时间区间
  18345. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18346. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18347. // _sqlSugar.BeginTran();
  18348. // for (int i = 0; i < timeArr.Count; i++)
  18349. // {
  18350. // stay = "-";
  18351. // cityPath = "-";
  18352. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18353. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18354. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18355. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18356. // if (tbSelect.Length > 0)
  18357. // {
  18358. // List<string> threeCodeStr = new List<string>();
  18359. // foreach (var item in tbSelect)
  18360. // {
  18361. // var threeCode = item["Three"].ToString() ?? "";
  18362. // if (threeCode.Length == 6)
  18363. // {
  18364. // var start = threeCode.Substring(0, 3);
  18365. // var end = threeCode.Substring(3, 3);
  18366. // if (threeCodeStr.Count == 0)
  18367. // {
  18368. // threeCodeStr.Add(start);
  18369. // threeCodeStr.Add(end);
  18370. // }
  18371. // else
  18372. // {
  18373. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18374. // {
  18375. // threeCodeStr.Add(end);
  18376. // }
  18377. // else
  18378. // {
  18379. // threeCodeStr.Add(start);
  18380. // threeCodeStr.Add(end);
  18381. // }
  18382. // }
  18383. // }
  18384. // }
  18385. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18386. // var last = threeCodeStr.Last();
  18387. // foreach (var item in threeCodeStr)
  18388. // {
  18389. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18390. // if (item.Equals(last))
  18391. // {
  18392. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18393. // }
  18394. // }
  18395. // cityPath = cityPath.Trim('-');
  18396. // }
  18397. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18398. // appro.Diid = diid ?? -1;
  18399. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18400. // appro.Id = thisId;
  18401. // appro.CreateUserId = dto.UserId;
  18402. // appro.CreateTime = DateTime.Now;
  18403. // content.Add(appro);
  18404. // }
  18405. // _sqlSugar.CommitTran();
  18406. //}
  18407. #endregion
  18408. foreach (var x in content)
  18409. {
  18410. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18411. if (chiList.Count < chiNumber)
  18412. {
  18413. for (int i = chiList.Count; i < chiNumber; i++)
  18414. {
  18415. chiList.Add(new Grp_ApprovalTravelDetails());
  18416. }
  18417. }
  18418. resultArr.Add(new
  18419. {
  18420. x.Id,
  18421. x.Date,
  18422. x.Diid,
  18423. chiList = chiList.Select(x1 => new
  18424. {
  18425. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18426. x1.Details,
  18427. x1.ParentId,
  18428. x1.Id
  18429. })
  18430. });
  18431. }
  18432. data = data with
  18433. {
  18434. content = resultArr,
  18435. };
  18436. jw = JsonView(true, "获取成功!", data);
  18437. return Ok(jw);
  18438. }
  18439. /// <summary>
  18440. /// 报批行程删除
  18441. /// </summary>
  18442. /// <param name="dto"></param>
  18443. /// <returns></returns>
  18444. [HttpPost]
  18445. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18446. {
  18447. var jw = JsonView(false);
  18448. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18449. if (group == null)
  18450. {
  18451. jw.Msg = "团组参数有误!";
  18452. return Ok(jw);
  18453. }
  18454. try
  18455. {
  18456. _sqlSugar.BeginTran();
  18457. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18458. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18459. {
  18460. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18461. DeleteUserId = dto.uesrId,
  18462. IsDel = 1
  18463. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18464. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18465. {
  18466. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18467. DeleteUserId = dto.uesrId,
  18468. IsDel = 1
  18469. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18470. _sqlSugar.CommitTran();
  18471. jw = JsonView(true, "删除成功");
  18472. }
  18473. catch (Exception ex)
  18474. {
  18475. jw = JsonView(false, ex.Message);
  18476. }
  18477. return Ok(jw);
  18478. }
  18479. /// <summary>
  18480. /// 报批行程保存
  18481. /// </summary>
  18482. /// <param name="dto"></param>
  18483. /// <returns></returns>
  18484. [HttpPost]
  18485. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18486. {
  18487. var jw = JsonView(false);
  18488. var Find = dto.Arr.Find(x => x.id == 0);
  18489. if (Find != null)
  18490. {
  18491. jw.Msg = "生成的ID为0!";
  18492. return Ok(jw);
  18493. }
  18494. foreach (var item in dto.Arr)
  18495. {
  18496. foreach (var chi in item.chiList)
  18497. {
  18498. if (chi.parentId == 0)
  18499. {
  18500. chi.parentId = item.id;
  18501. }
  18502. }
  18503. }
  18504. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18505. _sqlSugar.BeginTran();
  18506. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18507. {
  18508. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18509. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18510. {
  18511. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18512. DeleteUserId = dto.UserId,
  18513. IsDel = 1
  18514. }).ExecuteCommand();
  18515. }
  18516. try
  18517. {
  18518. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18519. {
  18520. CreateTime = DateTime.Now,
  18521. CreateUserId = dto.UserId,
  18522. Details = x.details,
  18523. ParentId = x.parentId,
  18524. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18525. Remark = "",
  18526. IsDel = 0
  18527. }).ToList()).ExecuteCommand();
  18528. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18529. {
  18530. Id = x.id,
  18531. Details = x.details,
  18532. ParentId = x.parentId,
  18533. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18534. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18535. {
  18536. Details = x.Details,
  18537. ParentId = x.ParentId,
  18538. Time = x.Time
  18539. }).ExecuteCommand();
  18540. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18541. {
  18542. Id = x.id,
  18543. Date = x.date,
  18544. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18545. {
  18546. Date = x.Date
  18547. }).ExecuteCommand();
  18548. _sqlSugar.CommitTran();
  18549. jw = JsonView(true, "保存成功!");
  18550. }
  18551. catch (Exception ex)
  18552. {
  18553. _sqlSugar.RollbackTran();
  18554. jw = JsonView(false, "保存失败!" + ex.Message);
  18555. }
  18556. return Ok(jw);
  18557. }
  18558. /// <summary>
  18559. /// 报批行程生成
  18560. /// </summary>
  18561. /// <param name="dto"></param>
  18562. /// <returns></returns>
  18563. [HttpPost]
  18564. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18565. {
  18566. var jw = JsonView(false);
  18567. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18568. if (group == null)
  18569. {
  18570. jw.Msg = "暂无该团组!";
  18571. return Ok(jw);
  18572. }
  18573. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18574. //黑屏代码数据
  18575. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18576. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18577. {
  18578. jw.Msg = "黑屏代码有误!";
  18579. return Ok(jw);
  18580. }
  18581. foreach (DataRow row in dtBlack.Rows)
  18582. {
  18583. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18584. {
  18585. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18586. return Ok(jw);
  18587. }
  18588. }
  18589. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18590. var resultArr = new ArrayList();
  18591. //if (officialActivitiesArr.Count == 0)
  18592. //{
  18593. // jw.Msg = "暂无公务出访信息!";
  18594. // return Ok(jw);
  18595. //}
  18596. try
  18597. {
  18598. _sqlSugar.BeginTran();
  18599. DeleteApprovalJourney(new
  18600. Domain.Dtos.Groups.DeleteApprovalJourney
  18601. {
  18602. Diid = dto.Diid,
  18603. uesrId = dto.Userid
  18604. });
  18605. var stay = "-";
  18606. var cityPath = "-";
  18607. //添加城市路径以及住宿地
  18608. //黑屏代码获取时间区间
  18609. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18610. var empty = "【未收入该三字码!请机票同事录入】";
  18611. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18612. for (int i = 0; i < timeArr.Count; i++)
  18613. {
  18614. stay = "-";
  18615. cityPath = "-";
  18616. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18617. DateTime NewData = DateTime.Parse(timeArr[i]);
  18618. //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();
  18619. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18620. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18621. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18622. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18623. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18624. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18625. if (tbSelect.Length > 0)
  18626. {
  18627. List<string> threeCodeStr = new List<string>();
  18628. bool isTrade = false;
  18629. string trip = string.Empty;
  18630. var rowLast = tbSelect.Last();
  18631. var rowFirst = tbSelect.First();
  18632. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18633. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18634. var takeOffTime = DateTime.Parse(timeArr[i]);
  18635. var fallToTime = DateTime.Parse(timeArr[i]);
  18636. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18637. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18638. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18639. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18640. foreach (var item in tbSelect)
  18641. {
  18642. var start = string.Empty;
  18643. var end = string.Empty;
  18644. var threeCode = item["Three"].ToString() ?? "";
  18645. if (threeCode.Length == 6)
  18646. {
  18647. start = threeCode.Substring(0, 3);
  18648. end = threeCode.Substring(3, 3);
  18649. if (threeCodeStr.Count == 0)
  18650. {
  18651. threeCodeStr.Add(start);
  18652. threeCodeStr.Add(end);
  18653. }
  18654. else
  18655. {
  18656. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18657. {
  18658. threeCodeStr.Add(end);
  18659. }
  18660. else
  18661. {
  18662. threeCodeStr.Add(start);
  18663. threeCodeStr.Add(end);
  18664. }
  18665. }
  18666. }
  18667. //处理机票信息
  18668. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18669. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18670. if (start_Object == null)
  18671. {
  18672. start_Object = new Res_ThreeCode()
  18673. {
  18674. AirPort = empty,
  18675. AirPort_En = empty,
  18676. City = empty,
  18677. Country = empty,
  18678. Four = empty,
  18679. Three = empty,
  18680. };
  18681. }
  18682. if (end_Object == null)
  18683. {
  18684. end_Object = new Res_ThreeCode()
  18685. {
  18686. AirPort = empty,
  18687. AirPort_En = empty,
  18688. City = empty,
  18689. Country = empty,
  18690. Four = empty,
  18691. Three = empty,
  18692. };
  18693. }
  18694. //机型判断
  18695. string airModel = item["AirModel"].ToString();
  18696. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18697. string flightTime = item["FlightTime"].ToString();
  18698. if (flightTime!.Contains(":"))
  18699. {
  18700. flightTime = flightTime.Replace(":", "小时");
  18701. flightTime += "分钟";
  18702. }
  18703. if (flightTime.Contains("H"))
  18704. {
  18705. flightTime = flightTime.Replace("H", "小时");
  18706. }
  18707. if (flightTime.Contains("M"))
  18708. {
  18709. flightTime = flightTime.Replace("M", "分钟");
  18710. }
  18711. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18712. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18713. {
  18714. flightTime = flightDataTime.Hour > 0
  18715. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18716. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18717. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18718. }
  18719. //航班号
  18720. string flightcode = item["Fliagtcode"].ToString();
  18721. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18722. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18723. if (aircompany == null)
  18724. {
  18725. aircompany = new Res_AirCompany
  18726. {
  18727. CnName = hsEmpty,
  18728. EnName = hsEmpty,
  18729. ShortCode = hsEmpty,
  18730. };
  18731. }
  18732. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18733. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18734. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18735. if (isTrade)
  18736. {
  18737. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18738. }
  18739. else
  18740. {
  18741. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18742. }
  18743. }
  18744. chiarr.Add(new Grp_ApprovalTravelDetails
  18745. {
  18746. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18747. CreateTime = DateTime.Now,
  18748. CreateUserId = dto.Userid,
  18749. ParentId = 0,
  18750. Details = trip
  18751. });
  18752. //添加乘车语句
  18753. chiarr.Add(new Grp_ApprovalTravelDetails
  18754. {
  18755. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18756. CreateTime = DateTime.Now,
  18757. CreateUserId = dto.Userid,
  18758. ParentId = 0,
  18759. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18760. });
  18761. if (i != timeArr.Count - 1)
  18762. {
  18763. fallToTime = fallToTime.AddHours(2.5);
  18764. foreach (var item in Times)
  18765. {
  18766. //排列公务时间
  18767. if (fallToTime.Hour < item.Item1)
  18768. {
  18769. chiarr.Add(new Grp_ApprovalTravelDetails
  18770. {
  18771. Time = $"{item.Item2} - {item.Item3}",
  18772. CreateTime = DateTime.Now,
  18773. CreateUserId = dto.Userid,
  18774. ParentId = 0,
  18775. Details = "公务活动"
  18776. });
  18777. }
  18778. }
  18779. }
  18780. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18781. var last = threeCodeStr.Last();
  18782. foreach (var item in threeCodeStr)
  18783. {
  18784. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18785. if (item.Equals(last))
  18786. {
  18787. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18788. }
  18789. }
  18790. cityPath = cityPath.Trim('-');
  18791. }
  18792. else
  18793. {
  18794. foreach (var item in Times)
  18795. {
  18796. chiarr.Add(new Grp_ApprovalTravelDetails
  18797. {
  18798. Time = $"{item.Item2} - {item.Item3}",
  18799. CreateTime = DateTime.Now,
  18800. CreateUserId = dto.Userid,
  18801. ParentId = 0,
  18802. Details = "公务活动"
  18803. });
  18804. }
  18805. }
  18806. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18807. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18808. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18809. appro.Diid = dto.Diid;
  18810. appro.CreateUserId = dto.Userid;
  18811. appro.CreateTime = DateTime.Now;
  18812. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18813. appro.Id = thisId;
  18814. //foreach (var item in gwinfo)
  18815. //{
  18816. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18817. // chi.Details = "拜访" + item.Client;
  18818. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18819. // {
  18820. // chi.Details += "," + item.ReqSample;
  18821. // }
  18822. // chi.ParentId = thisId;
  18823. // chi.Time = item.Time;
  18824. // chiarr.Add(chi);
  18825. //}
  18826. if (chiarr.Count < 6)
  18827. {
  18828. for (int j = chiarr.Count; j < 6; j++)
  18829. {
  18830. chiarr.Add(new
  18831. Grp_ApprovalTravelDetails());
  18832. }
  18833. }
  18834. resultArr.Add(new
  18835. {
  18836. appro.Id,
  18837. appro.Date,
  18838. appro.Diid,
  18839. chiList = chiarr.Select(x1 => new
  18840. {
  18841. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18842. x1.Details,
  18843. x1.ParentId,
  18844. x1.Id
  18845. })
  18846. });
  18847. }
  18848. _sqlSugar.CommitTran();
  18849. jw = JsonView(true, "生成成功!", resultArr);
  18850. }
  18851. catch (Exception ex)
  18852. {
  18853. jw.Code = 400;
  18854. jw.Msg = "生成失败!" + ex.Message;
  18855. }
  18856. return Ok(jw);
  18857. }
  18858. /// <summary>
  18859. /// 报批行程word导出
  18860. /// </summary>
  18861. /// <param name="dto"></param>
  18862. /// <returns></returns>
  18863. [HttpPost]
  18864. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18865. {
  18866. var jw = JsonView(false);
  18867. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18868. if (group == null)
  18869. {
  18870. jw.Msg = "暂无该团组!";
  18871. return Ok(jw);
  18872. }
  18873. //模板路径
  18874. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18875. var fileName = string.Empty;
  18876. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18877. bool bold = false;
  18878. if (dto.FileIndex == 1)
  18879. {
  18880. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18881. }
  18882. else if (dto.FileIndex == 2)
  18883. {
  18884. fileName = "省外办-报批.docx";
  18885. bold = false;
  18886. titleFont = "方正黑体简体";
  18887. timeFont = "Times New Roman";
  18888. contentFont = "方正仿宋_GBK";
  18889. }
  18890. else if (dto.FileIndex == 3)
  18891. {
  18892. fileName = "市外办-报批.docx";
  18893. titleFont = "方正黑体简体";
  18894. timeFont = "Times New Roman";
  18895. contentFont = "方正仿宋简体";
  18896. }
  18897. tempPath = tempPath + fileName;
  18898. //载入模板
  18899. Document doc = new Document(tempPath);
  18900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18901. //获取所填表格的序数
  18902. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18903. Aspose.Words.Tables.Row titleRowClone = null;
  18904. Aspose.Words.Tables.Row CenterRowClone = null;
  18905. int index = 0;
  18906. int indexChi = 0;
  18907. int SetIndex = 0;
  18908. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18909. //获取数据,放到datatable
  18910. foreach (var item in ApprovalTravelArr)
  18911. {
  18912. if (index > 0)
  18913. {
  18914. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18915. tableOne.AppendChild(titleRowClone);
  18916. }
  18917. var textTime = item.Date;
  18918. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18919. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18920. SetIndex++;
  18921. if (ChiRep.Count > 0)
  18922. {
  18923. foreach (var itemChi in ChiRep)
  18924. {
  18925. var txtTime = itemChi.Time;
  18926. var txtDetail = itemChi.Details;
  18927. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18928. {
  18929. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18930. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18931. //indexChi++;
  18932. //SetIndex++;
  18933. break;
  18934. }
  18935. if (indexChi > 0)
  18936. {
  18937. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18938. tableOne.AppendChild(CenterRowClone);
  18939. }
  18940. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  18941. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  18942. indexChi++;
  18943. SetIndex++;
  18944. }
  18945. }
  18946. //else
  18947. //{
  18948. // if (indexChi > 0)
  18949. // {
  18950. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18951. // tableOne.AppendChild(CenterRowClone);
  18952. // }
  18953. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  18954. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18955. // indexChi++;
  18956. // SetIndex++;
  18957. //}
  18958. index++;
  18959. }
  18960. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  18961. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18962. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18963. jw.Code = 200;
  18964. jw.Msg = "";
  18965. return Ok(jw);
  18966. }
  18967. private string intToString(int numberVal)
  18968. {
  18969. string numberval = numberVal.ToString();
  18970. Dictionary<char, string> Number = new Dictionary<char, string>();
  18971. Number.Add('1', "一");
  18972. Number.Add('2', "二");
  18973. Number.Add('3', "三");
  18974. Number.Add('4', "四");
  18975. Number.Add('5', "五");
  18976. Number.Add('6', "六");
  18977. Number.Add('7', "七");
  18978. Number.Add('8', "八");
  18979. Number.Add('9', "九");
  18980. string stringNumberVal = string.Empty;
  18981. for (int i = 0; i < numberval.Length; i++)
  18982. {
  18983. if (i == 0)
  18984. {
  18985. stringNumberVal += Number[numberval[i]];
  18986. }
  18987. else if (i >= 1)
  18988. {
  18989. if (numberval[i] == '0')
  18990. {
  18991. stringNumberVal = "十";
  18992. }
  18993. else
  18994. {
  18995. stringNumberVal += "十" + Number[numberval[i]];
  18996. }
  18997. }
  18998. }
  18999. return stringNumberVal;
  19000. }
  19001. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  19002. {
  19003. //获取table中的某个单元格,从0开始
  19004. Cell lshCell = table.Rows[rows].Cells[cells];
  19005. //将单元格中段落移除
  19006. foreach (Paragraph item in lshCell.Paragraphs)
  19007. {
  19008. lshCell.Paragraphs.Remove(item);
  19009. }
  19010. if (val.Contains("\r\n"))
  19011. {
  19012. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19013. foreach (var item in spArr)
  19014. {
  19015. //新建一个段落
  19016. Paragraph p = new Paragraph(doc);
  19017. var r = new Run(doc, item);
  19018. //设置字体
  19019. if (!string.IsNullOrEmpty(font))
  19020. {
  19021. r.Font.Name = font;
  19022. }
  19023. r.Font.Bold = bold;
  19024. //把设置的值赋给之前新建的段落
  19025. p.AppendChild(r);
  19026. //将此段落加到单元格内
  19027. lshCell.AppendChild(p);
  19028. }
  19029. }
  19030. else
  19031. {
  19032. //新建一个段落
  19033. Paragraph p = new Paragraph(doc);
  19034. var r = new Run(doc, val);
  19035. //设置字体
  19036. if (!string.IsNullOrEmpty(font))
  19037. {
  19038. r.Font.Name = font;
  19039. }
  19040. r.Font.Bold = bold;
  19041. //把设置的值赋给之前新建的段落
  19042. p.AppendChild(r);
  19043. //将此段落加到单元格内
  19044. lshCell.AppendChild(p);
  19045. }
  19046. }
  19047. [HttpPost]
  19048. public async Task<IActionResult> ServerHttp(string paramStr)
  19049. {
  19050. paramStr = paramStr.TrimEnd('\'');
  19051. paramStr = paramStr.TrimStart('\'');
  19052. JsonView jw = JsonView(false);
  19053. JObject param = JObject.Parse(paramStr);
  19054. if (!param.ContainsKey("url"))
  19055. {
  19056. jw.Msg = "url null";
  19057. return Ok(jw);
  19058. }
  19059. string url = param["url"]!.ToString();
  19060. var methon = "get";
  19061. Dictionary<string, string> headValues = null;
  19062. string bodyStr = string.Empty;
  19063. if (param.ContainsKey("methon"))
  19064. {
  19065. methon = param["methon"]!.ToString().ToLower();
  19066. }
  19067. if (param.ContainsKey("header"))
  19068. {
  19069. var header = param["header"]!.ToString();
  19070. JObject headerJobject = JObject.Parse(header);
  19071. headValues = new Dictionary<string, string>();
  19072. foreach (JProperty item in headerJobject.Properties())
  19073. {
  19074. var value = item.Value.ToString();
  19075. var head = item.Path;
  19076. headValues.Add(head, value);
  19077. }
  19078. }
  19079. HttpClient client = new HttpClient();
  19080. string responseString = string.Empty;
  19081. StringContent content = null;
  19082. if (headValues != null)
  19083. {
  19084. foreach (var item in headValues.Keys)
  19085. {
  19086. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19087. {
  19088. if (param.ContainsKey("body"))
  19089. {
  19090. bodyStr = param["body"]!.ToString();
  19091. }
  19092. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19093. }
  19094. else
  19095. {
  19096. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19097. }
  19098. }
  19099. }
  19100. try
  19101. {
  19102. if (methon == "get")
  19103. {
  19104. responseString = await client.GetStringAsync(url);
  19105. }
  19106. else if (methon == "post")
  19107. {
  19108. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19109. {
  19110. Content = content
  19111. };
  19112. var response = await client.SendAsync(request);
  19113. try
  19114. {
  19115. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19116. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19117. {
  19118. using (StreamReader reader = new StreamReader(gzipStream))
  19119. {
  19120. responseString = await reader.ReadToEndAsync();
  19121. }
  19122. }
  19123. }
  19124. catch (Exception)
  19125. {
  19126. responseString = await response.Content.ReadAsStringAsync();
  19127. }
  19128. }
  19129. else
  19130. {
  19131. responseString = "methon error";
  19132. }
  19133. jw = JsonView(true, "success", responseString);
  19134. }
  19135. catch (Exception ex)
  19136. {
  19137. jw.Msg = "error " + ex.Message;
  19138. jw.Data = ex.StackTrace;
  19139. }
  19140. finally
  19141. {
  19142. client.Dispose();
  19143. }
  19144. return Ok(jw);
  19145. }
  19146. #endregion
  19147. #region 团组接待意见调查
  19148. /// <summary>
  19149. /// 团组接待意见调查 - 信息管理
  19150. /// 基础数据(团组)
  19151. /// </summary>
  19152. /// <returns></returns>
  19153. [HttpGet]
  19154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19155. public async Task<IActionResult> OpinionaireInit()
  19156. {
  19157. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19158. .Select(x => new
  19159. {
  19160. x.Id,
  19161. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19162. })
  19163. .OrderByDescending(x => x.Id)
  19164. .ToListAsync();
  19165. return Ok(JsonView(groupData, groupData.Count));
  19166. }
  19167. /// <summary>
  19168. /// 团组接待意见调查 - 信息管理
  19169. /// 列表
  19170. /// </summary>
  19171. /// <param name="groupId"></param>
  19172. /// <returns></returns>
  19173. [HttpGet("{groupId}")]
  19174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19175. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19176. {
  19177. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19178. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19179. .Select(x => new
  19180. {
  19181. x.Id,
  19182. x.TourGuideName,
  19183. x.CityName,
  19184. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19185. x.CreateTime
  19186. })
  19187. .OrderBy(x => x.Id)
  19188. .ToListAsync();
  19189. return Ok(JsonView(data));
  19190. }
  19191. /// <summary>
  19192. /// 团组接待意见调查 - 信息管理
  19193. /// 保存
  19194. /// </summary>
  19195. /// <param name="dto"></param>
  19196. /// <returns></returns>
  19197. [HttpPost]
  19198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19199. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19200. {
  19201. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19202. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19203. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19204. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19205. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19206. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19207. _opinionaireRep.BeginTran();
  19208. if (addData != null && addData.Count > 0)
  19209. {
  19210. foreach (var item in addData)
  19211. {
  19212. item.CreateUserId = currUserInfo.UserId;
  19213. item.DiId = dto.DiId;
  19214. }
  19215. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19216. }
  19217. if (updData != null && updData.Count > 0)
  19218. {
  19219. var upd = await _opinionaireRep._sqlSugar
  19220. .Updateable(updData)
  19221. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19222. .WhereColumns(x => new { x.Id })
  19223. .ExecuteCommandAsync();
  19224. }
  19225. _opinionaireRep.CommitTran();
  19226. return Ok(JsonView("操作成功!"));
  19227. }
  19228. /// <summary>
  19229. /// 团组接待意见调查 - 信息管理
  19230. /// 删除
  19231. /// </summary>
  19232. /// <param name="id"></param>
  19233. /// <returns></returns>
  19234. [HttpDelete("{id}")]
  19235. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19236. public async Task<IActionResult> OpinionaireManageDel(int id)
  19237. {
  19238. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19239. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19240. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19241. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19242. if (!del) return Ok(JsonView("操作失败!"));
  19243. return Ok(JsonView("操作成功!"));
  19244. }
  19245. /// <summary>
  19246. /// 团组接待意见调查 - 用户
  19247. /// 列表
  19248. /// </summary>
  19249. /// <param name="diId"></param>
  19250. /// <returns></returns>
  19251. [HttpGet("{diId}")]
  19252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19253. public async Task<IActionResult> OpinionaireUserList(int diId)
  19254. {
  19255. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19256. var sql = string.Format(@"
  19257. SELECT
  19258. o.Id,
  19259. o.DiId,
  19260. di.TeamName AS 'GroupName',
  19261. di.VisitPNumber AS 'PeopleNumber',
  19262. di.ClientName AS 'LeadGroup',
  19263. di.VisitCountry AS 'Travel',
  19264. di.VisitDays AS 'Days',
  19265. o.CityName,
  19266. o.TourGuideName,
  19267. o.Catering,
  19268. o.CateringReason,
  19269. o.Stay,
  19270. o.StayReason,
  19271. o.[Route],
  19272. o.RouteReason,
  19273. o.OfficialActivity,
  19274. o.OfficialActivityReason,
  19275. o.TourGuide,
  19276. o.TourGuideReason,
  19277. o.[Translate],
  19278. o.TranslateReason,
  19279. o.Trip,
  19280. o.TripReason,
  19281. o.ESFileName,
  19282. o.SignatureDate,
  19283. o.Remark
  19284. FROM
  19285. Grp_Opinionaire o
  19286. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19287. WHERE
  19288. o.IsDel = 0
  19289. AND o.DiId = {0}
  19290. ORDER BY
  19291. o.Id ASC", diId);
  19292. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19293. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19294. return Ok(JsonView(data));
  19295. }
  19296. /// <summary>
  19297. /// 团组接待意见调查 - 用户
  19298. /// 保存
  19299. /// </summary>
  19300. /// <param name="dto"></param>
  19301. /// <returns></returns>
  19302. [HttpPost]
  19303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19304. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19305. {
  19306. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19307. foreach (var item in dto)
  19308. {
  19309. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19310. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19311. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19312. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19313. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19314. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19315. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19316. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19317. }
  19318. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19319. if (!Directory.Exists(filePathBase))
  19320. {
  19321. Directory.CreateDirectory(filePathBase);
  19322. }
  19323. #region 上传文件
  19324. var filePaths = new List<string>();
  19325. foreach (var item in dto)
  19326. {
  19327. var file = item.File;
  19328. // 将文件保存到指定位置
  19329. var filePath = Path.Combine(filePathBase, file.FileName);
  19330. using (var stream = new FileStream(filePath, FileMode.Create))
  19331. {
  19332. await file.CopyToAsync(stream);
  19333. }
  19334. //验证文件是否上传成功
  19335. if (!System.IO.File.Exists(filePath))
  19336. {
  19337. foreach (var filePathStr in filePaths)
  19338. {
  19339. System.IO.File.Delete(filePathStr);
  19340. }
  19341. return Ok(JsonView(false, "文件上传失败!"));
  19342. }
  19343. item.ESFileName = file.FileName;
  19344. }
  19345. #endregion
  19346. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19347. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19348. .UpdateColumns(x => new
  19349. {
  19350. x.Catering,
  19351. x.CateringReason,
  19352. x.Stay,
  19353. x.StayReason,
  19354. x.Route,
  19355. x.RouteReason,
  19356. x.OfficialActivity,
  19357. x.OfficialActivityReason,
  19358. x.TourGuide,
  19359. x.TourGuideReason,
  19360. x.Translate,
  19361. x.TranslateReason,
  19362. x.Trip,
  19363. x.TripReason,
  19364. x.ESFileName,
  19365. x.SignatureDate,
  19366. x.Remark
  19367. })
  19368. .WhereColumns(x => new { x.Id })
  19369. .ExecuteCommandAsync();
  19370. if (upd < 1)
  19371. {
  19372. foreach (var filePathStr in filePaths)
  19373. {
  19374. System.IO.File.Delete(filePathStr);
  19375. }
  19376. return Ok(JsonView(false));
  19377. }
  19378. return Ok(JsonView(true));
  19379. }
  19380. #endregion
  19381. #region 团组餐厅相关信息
  19382. /// <summary>
  19383. /// 团组相关餐厅信息
  19384. /// 基础数据(团组)
  19385. /// </summary>
  19386. /// <returns></returns>
  19387. [HttpGet]
  19388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19389. public async Task<IActionResult> RestaurantInit()
  19390. {
  19391. return Ok(await _restaurantRep.InitAsync());
  19392. }
  19393. /// <summary>
  19394. /// 团组相关餐厅信息
  19395. /// Item
  19396. /// </summary>
  19397. /// <param name="dto"></param>
  19398. /// <returns></returns>
  19399. [HttpPost]
  19400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19401. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19402. {
  19403. int portType = dto.PortType,
  19404. groupId = dto.GroupId;
  19405. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19406. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19407. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19408. }
  19409. /// <summary>
  19410. /// 团组相关餐厅信息
  19411. /// List
  19412. /// </summary>
  19413. /// <param name="dto"></param>
  19414. /// <returns></returns>
  19415. [HttpPost]
  19416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19417. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19418. {
  19419. int portType = dto.PortType,
  19420. groupId = dto.GroupId;
  19421. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19422. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19423. var sql = string.Format(@" SELECT
  19424. ri.Id,
  19425. ri.GroupId,
  19426. ri.Date,
  19427. ri.StartTime,
  19428. ri.EndTime,
  19429. CASE WHEN ri.Type = 1 THEN '早餐'
  19430. WHEN ri.Type = 2 THEN '午餐'
  19431. WHEN ri.Type = 3 THEN '晚餐'
  19432. ELSE '其他'
  19433. END AS 'Type',
  19434. ri.Name,
  19435. ri.Address,
  19436. ri.Tel,
  19437. ri.Remark,
  19438. ri.CreateTime,
  19439. u.CnName AS CreateUserName
  19440. FROM
  19441. Grp_RestaurantInfo ri
  19442. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19443. WHERE
  19444. ri.IsDel = 0
  19445. AND ri.GroupId = {0}
  19446. ORDER BY
  19447. ri.Date ASC
  19448. ", groupId);
  19449. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19450. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19451. return Ok(JsonView(infos));
  19452. }
  19453. /// <summary>
  19454. /// 团组相关餐厅信息
  19455. /// Info
  19456. /// </summary>
  19457. /// <param name="dto"></param>
  19458. /// <returns></returns>
  19459. [HttpPost]
  19460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19461. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19462. {
  19463. int portType = dto.PortType,
  19464. id = dto.Id;
  19465. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19466. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19467. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19468. }
  19469. /// <summary>
  19470. /// 团组相关餐厅信息
  19471. /// Op
  19472. /// </summary>
  19473. /// <param name="dto"></param>
  19474. /// <returns></returns>
  19475. [HttpPost]
  19476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19477. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19478. {
  19479. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19480. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19481. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19482. return Ok(await _restaurantRep.OpAsync(dto));
  19483. }
  19484. /// <summary>
  19485. /// 团组相关餐厅信息
  19486. /// Del
  19487. /// </summary>
  19488. /// <param name="dto"></param>
  19489. /// <returns></returns>
  19490. [HttpPost]
  19491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19492. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19493. {
  19494. int userId = dto.DeleteUserId;
  19495. var id = dto.Id;
  19496. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19497. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19498. return Ok(await _restaurantRep.DelAsync(dto));
  19499. }
  19500. #endregion
  19501. // /// <summary>
  19502. // ///
  19503. // /// </summary>
  19504. // /// <param name="_dto"></param>
  19505. // /// <returns></returns>
  19506. // [HttpPost]
  19507. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19508. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19509. // {
  19510. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19511. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19512. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19513. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19514. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19515. // dic_psg.Add("客人", 974);
  19516. // dic_psg.Add("司机", 975);
  19517. // dic_psg.Add("导游", 976);
  19518. // dic_psg.Add("公司内部人员", 977);
  19519. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19520. // foreach (var item in list_visa)
  19521. // {
  19522. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19523. // temp.Id = item.Id;
  19524. // temp.DIId = item.DIId;
  19525. // temp.VisaClient = item.VisaClient;
  19526. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19527. // temp.VisaCurrency = item.VisaCurrency;
  19528. // temp.IsThird = item.IsThird;
  19529. // if (dic_psg.ContainsKey(item.PassengerType))
  19530. // {
  19531. // temp.PassengerType = dic_psg[item.PassengerType];
  19532. // }
  19533. // else {
  19534. // temp.PassengerType = -1;
  19535. // }
  19536. // temp.VisaNumber = item.VisaNumber;
  19537. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19538. // temp.CreateUserId = item.Operators;
  19539. // DateTime dt_ct;
  19540. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19541. // if (b_ct)
  19542. // {
  19543. // temp.CreateTime = dt_ct;
  19544. // }
  19545. // else
  19546. // {
  19547. // temp.CreateTime = DateTime.Now;
  19548. // }
  19549. // temp.DeleteTime = "";
  19550. // temp.DeleteUserId = 0;
  19551. // temp.Remark = item.Remark;
  19552. // if (string.IsNullOrEmpty(temp.Remark)) {
  19553. // temp.Remark = "";
  19554. // }
  19555. // temp.IsDel = item.IsDel;
  19556. // temp.VisaDescription = item.VisaAttachment;
  19557. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19558. //([Id]
  19559. // ,[DIId]
  19560. // ,[VisaClient]
  19561. // ,[VisaPrice]
  19562. // ,[VisaCurrency]
  19563. // ,[IsThird]
  19564. // ,[PassengerType]
  19565. // ,[VisaNumber]
  19566. // ,[VisaFreeNumber]
  19567. // ,[CreateUserId]
  19568. // ,[CreateTime]
  19569. // ,[DeleteTime]
  19570. // ,[DeleteUserId]
  19571. // ,[Remark]
  19572. // ,[IsDel]
  19573. // ,[visaDescription])
  19574. // VALUES
  19575. // ({0},{1},'{2}',{3},{4}
  19576. //,{5},{6},{7},{8},{9}
  19577. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19578. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19579. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19580. //);
  19581. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19582. // }
  19583. // return Ok(JsonView(true, "操作成功!"));
  19584. // }
  19585. /// <summary>
  19586. /// 123132123
  19587. /// </summary>
  19588. /// <param name="_dto"></param>
  19589. /// <returns></returns>
  19590. [HttpPost]
  19591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19592. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19593. {
  19594. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19595. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19596. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19597. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19598. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19599. dicDetail.Add(789, 1034);
  19600. dicDetail.Add(790, 1035);
  19601. dicDetail.Add(791, 1036);
  19602. dicDetail.Add(792, 1037);
  19603. dicDetail.Add(793, 1038);
  19604. dicDetail.Add(794, 1039);
  19605. dicDetail.Add(795, 1040);
  19606. dicDetail.Add(796, 1041);
  19607. dicDetail.Add(797, 1042);
  19608. dicDetail.Add(798, 1043);
  19609. dicDetail.Add(801, 1044);
  19610. dicDetail.Add(802, 1045);
  19611. dicDetail.Add(803, 1046);
  19612. Dictionary<int, int> dic = new Dictionary<int, int>();
  19613. dic.Add(806, 1027);
  19614. dic.Add(807, 1028);
  19615. dic.Add(808, 1029);
  19616. dic.Add(809, 1030);
  19617. dic.Add(810, 1031);
  19618. dic.Add(811, 1032);
  19619. dic.Add(812, 1033);
  19620. foreach (var item in list_visa)
  19621. {
  19622. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19623. temp.Coefficient = item.coefficient;
  19624. DateTime dtCrt;
  19625. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19626. if (b1)
  19627. {
  19628. temp.CreateTime = dtCrt;
  19629. }
  19630. else
  19631. {
  19632. temp.CreateTime = DateTime.Now;
  19633. }
  19634. temp.CreateUserId = item.Operators;
  19635. temp.DeleteTime = "";
  19636. temp.DeleteUserId = 0;
  19637. temp.DiId = int.Parse(item.DIID);
  19638. temp.FilePath = item.FilePath;
  19639. temp.IsDel = item.IsDel;
  19640. temp.Price = item.Price;
  19641. temp.PriceCount = 1;
  19642. temp.PriceCurrency = item.Currency;
  19643. int detailId = 0;
  19644. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19645. {
  19646. detailId = dicDetail[item.PriceTypeDetail];
  19647. }
  19648. temp.PriceDetailType = detailId;
  19649. temp.PriceDt = DateTime.Now;
  19650. temp.PriceName = item.PriceName;
  19651. temp.PriceSum = item.Price;
  19652. int tid = 0;
  19653. if (dic.ContainsKey(item.PriceType))
  19654. {
  19655. tid = dic[item.PriceType];
  19656. }
  19657. temp.PriceType = tid;
  19658. temp.Remark = item.Remark;
  19659. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19660. }
  19661. return Ok(JsonView(true, "操作成功!"));
  19662. }
  19663. [HttpPost]
  19664. public IActionResult TimeTest()
  19665. {
  19666. var jw = JsonView(false, "error");
  19667. _sqlSugar.BeginTran();
  19668. try
  19669. {
  19670. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19671. .Select(x => new Crm_NewClientData
  19672. {
  19673. Id = x.Id,
  19674. Client = x.Client,
  19675. Contact = x.Contact,
  19676. Location = x.Location,
  19677. })
  19678. .ToList();
  19679. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19680. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19681. Stopwatch stopwatch = new Stopwatch();
  19682. // 开始计时
  19683. stopwatch.Start();
  19684. foreach (var item in clientList)
  19685. {
  19686. EncryptionProcessor.DecryptProperties(item);
  19687. }
  19688. stopwatch.Stop();
  19689. jw.Code = 200;
  19690. jw.Data = stopwatch.ElapsedMilliseconds;
  19691. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19692. }
  19693. catch (Exception ex)
  19694. {
  19695. jw.Code = 400;
  19696. jw.Msg = ex.Message;
  19697. }
  19698. return Ok(jw);
  19699. }
  19700. }
  19701. }