GroupsController.cs 1.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Runtime.InteropServices;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.Mvc.RazorPages;
  10. using Microsoft.AspNetCore.SignalR;
  11. using Microsoft.IdentityModel.Tokens;
  12. using Microsoft.VisualBasic;
  13. using MySqlX.XDevAPI.Relational;
  14. using NetTaste;
  15. using NPOI.HSSF.UserModel;
  16. using NPOI.SS.Formula.Functions;
  17. using NPOI.SS.UserModel;
  18. using NPOI.SS.Util;
  19. using NPOI.XSSF.UserModel;
  20. using OASystem.API.Middlewares;
  21. using OASystem.API.OAMethodLib;
  22. using OASystem.API.OAMethodLib.APNs;
  23. using OASystem.API.OAMethodLib.File;
  24. using OASystem.API.OAMethodLib.Hub.HubClients;
  25. using OASystem.API.OAMethodLib.Hub.Hubs;
  26. using OASystem.API.OAMethodLib.JuHeAPI;
  27. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  28. using OASystem.Domain.AesEncryption;
  29. using OASystem.Domain.Attributes;
  30. using OASystem.Domain.Dtos.CRM;
  31. using OASystem.Domain.Dtos.FileDto;
  32. using OASystem.Domain.Dtos.Financial;
  33. using OASystem.Domain.Dtos.Groups;
  34. using OASystem.Domain.Entities.Customer;
  35. using OASystem.Domain.Entities.Financial;
  36. using OASystem.Domain.Entities.Groups;
  37. using OASystem.Domain.ViewModels.Financial;
  38. using OASystem.Domain.ViewModels.Groups;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.ViewModels.Statistics;
  41. using OASystem.Infrastructure.Repositories.CRM;
  42. using OASystem.Infrastructure.Repositories.Financial;
  43. using OASystem.Infrastructure.Repositories.Groups;
  44. using OASystem.Infrastructure.Tools;
  45. using OASystem.RedisRepository;
  46. using Org.BouncyCastle.Crypto;
  47. using Org.BouncyCastle.Utilities;
  48. using Quartz.Util;
  49. using SqlSugar.Extensions;
  50. using System.Collections;
  51. using System.Data;
  52. using System.Diagnostics;
  53. using System.Drawing.Printing;
  54. using System.Globalization;
  55. using System.IO;
  56. using System.IO.Compression;
  57. using System.Text.Json;
  58. using System.Web;
  59. using System.Xml.Linq;
  60. using TencentCloud.Ocr.V20181119.Models;
  61. using static OASystem.API.OAMethodLib.JWTHelper;
  62. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  63. using Bookmark = Aspose.Words.Bookmark;
  64. using Cell = Aspose.Words.Tables.Cell;
  65. using Table = Aspose.Words.Tables.Table;
  66. namespace OASystem.API.Controllers
  67. {
  68. /// <summary>
  69. /// 团组相关
  70. /// </summary>
  71. //[Authorize]
  72. [Route("api/[controller]/[action]")]
  73. public class GroupsController : ControllerBase
  74. {
  75. private readonly ILogger<GroupsController> _logger;
  76. private readonly GrpScheduleRepository _grpScheduleRep;
  77. private readonly IMapper _mapper;
  78. private readonly DelegationInfoRepository _groupRepository;
  79. private readonly TaskAssignmentRepository _taskAssignmentRep;
  80. private readonly AirTicketResRepository _airTicketResRep;
  81. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  82. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  83. private readonly DelegationEnDataRepository _delegationEnDataRep;
  84. private readonly DelegationVisaRepository _delegationVisaRep;
  85. private readonly VisaPriceRepository _visaPriceRep;
  86. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  87. private readonly HotelPriceRepository _hotelPriceRep;
  88. private readonly CustomersRepository _customersRep;
  89. private readonly MessageRepository _message;
  90. private readonly SqlSugarClient _sqlSugar;
  91. private readonly TourClientListRepository _tourClientListRep;
  92. private readonly TeamRateRepository _teamRateRep;
  93. #region 成本相关
  94. private readonly CheckBoxsRepository _checkBoxs;
  95. private readonly GroupCostRepository _GroupCostRepository;
  96. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  97. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  98. #endregion
  99. private readonly SetDataRepository _setDataRep;
  100. private string url;
  101. private string path;
  102. private readonly EnterExitCostRepository _enterExitCostRep;
  103. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  104. private readonly UsersRepository _usersRep;
  105. private readonly IJuHeApiService _juHeApi;
  106. private readonly InvertedListRepository _invertedListRep;
  107. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  108. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  109. private readonly ThreeCodeRepository _threeCodeRepository;
  110. private readonly HotelInquiryRepository _hotelInquiryRep;
  111. private readonly FeeAuditRepository _feeAuditRep;
  112. private readonly VisaCommissionRepository _visaCommissionRep;
  113. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  114. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  115. private readonly List<CurrencyInfo> _currencyInit;
  116. private readonly List<int> _portTypeData;
  117. private readonly TableOperationRecordRepository _tableorRep;
  118. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  119. private readonly RestaurantRepository _restaurantRep;
  120. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  121. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  122. /// <summary>
  123. /// 构造函数
  124. /// </summary>
  125. /// <param name="logger"></param>
  126. /// <param name="mapper"></param>
  127. /// <param name="hubContext"></param>
  128. /// <param name="sqlSugar"></param>
  129. /// <param name="grpScheduleRep"></param>
  130. /// <param name="groupRepository"></param>
  131. /// <param name="taskAssignmentRep"></param>
  132. /// <param name="airTicketResRep"></param>
  133. /// <param name="decreasePaymentsRep"></param>
  134. /// <param name="InvitationOfficialActivitiesRep"></param>
  135. /// <param name="delegationEnDataRep"></param>
  136. /// <param name="enterExitCostRep"></param>
  137. /// <param name="delegationVisaRep"></param>
  138. /// <param name="message"></param>
  139. /// <param name="visaPriceRep"></param>
  140. /// <param name="carTouristGuideGroundRep"></param>
  141. /// <param name="checkBoxs"></param>
  142. /// <param name="GroupCostRepository"></param>
  143. /// <param name="CostTypeHotelNumberRepository"></param>
  144. /// <param name="GroupCostParameterRepository"></param>
  145. /// <param name="hotelPriceRep"></param>
  146. /// <param name="customersRep"></param>
  147. /// <param name="setDataRep"></param>
  148. /// <param name="tourClientListRep"></param>
  149. /// <param name="teamRateRep"></param>
  150. /// <param name="usersRep"></param>
  151. /// <param name="juHeApi"></param>
  152. /// <param name="invertedListRep"></param>
  153. /// <param name="visaFeeInfoRep"></param>
  154. /// <param name="ticketBlackCodeRep"></param>
  155. /// <param name="hotelInquiryRep"></param>
  156. /// <param name="threeCodeRepository"></param>
  157. /// <param name="feeAuditRep"></param>
  158. /// <param name="visaCommissionRep"></param>
  159. /// <param name="ffrRep"></param>
  160. /// <param name="opinionaireRep"></param>
  161. /// <param name="tableorRep"></param>
  162. /// <param name="enterExitCostDraftRep"></param>
  163. /// <param name="restaurantRep"></param>
  164. /// <param name="enterExitCostQuoteRep"></param>
  165. /// <param name="grpOrderPreInfoRep"></param>
  166. public GroupsController(
  167. ILogger<GroupsController> logger,
  168. IMapper mapper,
  169. IHubContext<ChatHub, IChatClient> hubContext,
  170. SqlSugarClient sqlSugar,
  171. GrpScheduleRepository grpScheduleRep,
  172. DelegationInfoRepository groupRepository,
  173. TaskAssignmentRepository taskAssignmentRep,
  174. AirTicketResRepository airTicketResRep,
  175. DecreasePaymentsRepository decreasePaymentsRep,
  176. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  177. DelegationEnDataRepository delegationEnDataRep,
  178. EnterExitCostRepository enterExitCostRep,
  179. DelegationVisaRepository delegationVisaRep,
  180. MessageRepository message,
  181. VisaPriceRepository visaPriceRep,
  182. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  183. CheckBoxsRepository checkBoxs,
  184. GroupCostRepository GroupCostRepository,
  185. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  186. GroupCostParameterRepository GroupCostParameterRepository,
  187. HotelPriceRepository hotelPriceRep,
  188. CustomersRepository customersRep,
  189. SetDataRepository setDataRep,
  190. TourClientListRepository tourClientListRep,
  191. TeamRateRepository teamRateRep,
  192. UsersRepository usersRep,
  193. IJuHeApiService juHeApi,
  194. InvertedListRepository invertedListRep,
  195. VisaFeeInfoRepository visaFeeInfoRep,
  196. TicketBlackCodeRepository ticketBlackCodeRep,
  197. HotelInquiryRepository hotelInquiryRep,
  198. ThreeCodeRepository threeCodeRepository,
  199. FeeAuditRepository feeAuditRep,
  200. VisaCommissionRepository visaCommissionRep,
  201. ForeignReceivablesRepository ffrRep,
  202. OpinionaireRepository opinionaireRep,
  203. TableOperationRecordRepository tableorRep,
  204. EnterExitCostDraftRepository enterExitCostDraftRep,
  205. RestaurantRepository restaurantRep,
  206. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  207. GroupOrderPreInfoRepository grpOrderPreInfoRep
  208. )
  209. {
  210. _logger = logger;
  211. _mapper = mapper;
  212. _grpScheduleRep = grpScheduleRep;
  213. _groupRepository = groupRepository;
  214. _taskAssignmentRep = taskAssignmentRep;
  215. _airTicketResRep = airTicketResRep;
  216. _sqlSugar = sqlSugar;
  217. url = AppSettingsHelper.Get("ExcelBaseUrl");
  218. path = AppSettingsHelper.Get("ExcelBasePath");
  219. if (!System.IO.Directory.Exists(path))
  220. {
  221. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  222. }
  223. _decreasePaymentsRep = decreasePaymentsRep;
  224. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  225. _delegationEnDataRep = delegationEnDataRep;
  226. _enterExitCostRep = enterExitCostRep;
  227. _delegationVisaRep = delegationVisaRep;
  228. _message = message;
  229. _visaPriceRep = visaPriceRep;
  230. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  231. _checkBoxs = checkBoxs;
  232. _GroupCostRepository = GroupCostRepository;
  233. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  234. _GroupCostParameterRepository = GroupCostParameterRepository;
  235. _hotelPriceRep = hotelPriceRep;
  236. _customersRep = customersRep;
  237. _setDataRep = setDataRep;
  238. _tourClientListRep = tourClientListRep;
  239. _teamRateRep = teamRateRep;
  240. _hubContext = hubContext;
  241. _usersRep = usersRep;
  242. _juHeApi = juHeApi;
  243. _invertedListRep = invertedListRep;
  244. _visaFeeInfoRep = visaFeeInfoRep;
  245. _ticketBlackCodeRep = ticketBlackCodeRep;
  246. _hotelInquiryRep = hotelInquiryRep;
  247. _threeCodeRepository = threeCodeRepository;
  248. _feeAuditRep = feeAuditRep;
  249. _visaCommissionRep = visaCommissionRep;
  250. _ffrRep = ffrRep;
  251. _opinionaireRep = opinionaireRep;
  252. _currencyInit = new List<CurrencyInfo>()
  253. {
  254. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  255. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  256. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  257. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  258. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  259. };
  260. _portTypeData = new List<int>() { 2, 3 };
  261. _tableorRep = tableorRep;
  262. _enterExitCostDraftRep = enterExitCostDraftRep;
  263. _restaurantRep = restaurantRep;
  264. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  265. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  266. }
  267. #region 流程管控
  268. /// <summary>
  269. /// 获取团组流程管控信息
  270. /// </summary>
  271. /// <param name="_jsonDto">查询参数</param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  276. {
  277. if (string.IsNullOrEmpty(_jsonDto.Paras))
  278. {
  279. return Ok(JsonView(false, "参数为空"));
  280. }
  281. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  282. if (_ScheduleDto != null)
  283. {
  284. if (_ScheduleDto.SearchType == 2)//获取列表
  285. {
  286. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  287. return Ok(JsonView(_grpScheduleViewList));
  288. }
  289. else//获取对象
  290. {
  291. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  292. if (_grpScheduleView != null)
  293. {
  294. return Ok(JsonView(_grpScheduleView));
  295. }
  296. }
  297. }
  298. else
  299. {
  300. return Ok(JsonView(false, "参数反序列化失败"));
  301. }
  302. return Ok(JsonView(false, "暂无数据!"));
  303. }
  304. /// <summary>
  305. /// 修改团组流程管控详细表数据
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  312. {
  313. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  314. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  315. .SetColumns(it => it.Duty == _detail.Duty)
  316. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  317. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  318. .SetColumns(it => it.JobContent == _detail.JobContent)
  319. .SetColumns(it => it.Remark == _detail.Remark)
  320. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  321. .Where(s => s.Id == dto.Id)
  322. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "保存成功!"));
  327. }
  328. return Ok(JsonView(false, "保存失败!"));
  329. }
  330. /// <summary>
  331. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. _detail.IsDel = 1;
  341. _detail.DeleteUserId = dto.Duty;
  342. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  343. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  344. .SetColumns(it => it.IsDel == _detail.IsDel)
  345. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  346. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  347. .Where(it => it.Id == dto.Id)
  348. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  349. //.WhereColumns(s => s.Id == dto.Id)
  350. .ExecuteCommandAsync();
  351. if (result > 0)
  352. {
  353. return Ok(JsonView(true, "删除成功!"));
  354. }
  355. return Ok(JsonView(false, "删除失败!"));
  356. }
  357. /// <summary>
  358. /// 增加团组流程管控详细表数据
  359. /// </summary>
  360. /// <param name="dto"></param>
  361. /// <returns></returns>
  362. [HttpPost]
  363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  364. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  365. {
  366. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  367. if (DateTime.Now < _detail.ExpectBeginDt)
  368. {
  369. _detail.StepStatus = 0;
  370. }
  371. else
  372. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  373. _detail.StepStatus = 1;
  374. }
  375. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  376. if (result > 0)
  377. {
  378. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  379. return Ok(JsonView(true, "添加成功!", _result));
  380. }
  381. return Ok(JsonView(false, "添加失败!"));
  382. }
  383. #endregion
  384. #region 团组前期信息
  385. /// <summary>
  386. /// 团组前期信息 List
  387. /// </summary>
  388. /// <returns></returns>
  389. [HttpPost]
  390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  391. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  392. {
  393. var search = dto.Search;
  394. int[] nameTempIds = new int[] { 1, 12, 28 },
  395. countryTempIds = new int[] { 2, 13, 29 },
  396. daysTempIds = new int[] { 4, 15, 31 },
  397. ppNumTempIds = new int[] { 6 };
  398. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  399. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  400. .Where((opi, u) => opi.IsDel == 0)
  401. .OrderByDescending((opi, u) => opi.CreateTime)
  402. .Select((opi, u) => new GroupOrderPreInfoListView()
  403. {
  404. Id = opi.Id,
  405. Name = opi.Name,
  406. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  407. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  408. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  409. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  410. Operator = u.CnName,
  411. OperationTime = opi.CreateTime
  412. })
  413. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  414. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  415. .ToListAsync();
  416. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  417. int total = list.Count;
  418. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  419. var listPageData1 = listPageData
  420. .Skip((dto.PageIndex - 1) * dto.PageSize)
  421. .Take(dto.PageSize)
  422. .ToList();
  423. var infoIds = listPageData1.Select(x => x.Id).ToList();
  424. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  425. .Where(x => x.IsDel == 0 && x.STid == 109)
  426. .ToArrayAsync();
  427. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  428. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  429. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  430. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  431. .ToListAsync();
  432. foreach (var item in listPageData1)
  433. {
  434. var typeDatas1 = typeDatas.Select(x => new
  435. {
  436. Id = x.Id,
  437. Name = x.Name,
  438. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  439. }).ToArray();
  440. item.VersionDetails = typeDatas1;
  441. }
  442. return Ok(JsonView(listPageData1, listPageData1.Count));
  443. }
  444. /// <summary>
  445. /// 团组前期信息 Init
  446. /// </summary>
  447. /// <returns></returns>
  448. [HttpGet("{userId}")]
  449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  450. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  451. {
  452. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  453. }
  454. /// <summary>
  455. /// 国家数据源
  456. /// </summary>
  457. /// <returns></returns>
  458. [HttpGet]
  459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  460. public async Task<IActionResult> CountryInit()
  461. {
  462. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  463. return Ok(JsonView(countrys));
  464. }
  465. /// <summary>
  466. /// 城市数据源
  467. /// </summary>
  468. /// <returns></returns>
  469. [HttpGet("{countryLabel}")]
  470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  471. public async Task<IActionResult> CityByCountry(string countryLabel)
  472. {
  473. countryLabel = HttpUtility.UrlDecode(countryLabel);
  474. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  475. var citys = Array.Empty<string?>();
  476. if (countryList.Any())
  477. {
  478. var cityDatas = await _sqlSugar
  479. .Queryable<Grp_NationalTravelFee>()
  480. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  481. .ToArrayAsync();
  482. foreach (var item in cityDatas)
  483. {
  484. if (item.City.Contains("城市"))
  485. {
  486. item.City = item.Country + "-所有城市";
  487. }
  488. }
  489. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  490. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  491. }
  492. return Ok(JsonView(citys));
  493. }
  494. /// <summary>
  495. /// 团组前期信息 Info
  496. /// </summary>
  497. /// <param name="dto">Id</param>
  498. /// <returns></returns>
  499. [HttpGet("{Id}/{TempId}")]
  500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  501. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  502. {
  503. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  504. }
  505. /// <summary>
  506. /// 团组前期信息 Save
  507. /// </summary>
  508. /// <param name="dto">Id</param>
  509. /// <returns></returns>
  510. [HttpPost]
  511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  512. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  513. {
  514. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  515. }
  516. /// <summary>
  517. /// 团组前期信息 Del
  518. /// </summary>
  519. /// <param name="dto">Id</param>
  520. /// <returns></returns>
  521. [HttpPost]
  522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  523. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  524. {
  525. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  526. }
  527. /// <summary>
  528. /// 团组前期信息 文件下载
  529. /// </summary>
  530. /// <param name="dto">Id</param>
  531. /// <returns></returns>
  532. [HttpGet("{Id}/{TempId}")]
  533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  534. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  535. {
  536. int id = dto.Id, tempId = dto.TempId;
  537. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  538. var data = view.Data as GrpOrderPreInfoView;
  539. #region Excel
  540. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  541. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  542. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  543. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  544. var fileNamePrefix = string.Empty;
  545. if (tempId == 1405)
  546. {
  547. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  548. fileNamePrefix = $"{data.Name}_无商邀版";
  549. }
  550. else if (tempId == 1406)
  551. {
  552. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  553. fileNamePrefix = $"{data.Name}_有商邀版";
  554. }
  555. else
  556. {
  557. //tempId == 1404 默认下载
  558. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  559. fileNamePrefix = $"{data.Name}_单接送机";
  560. }
  561. foreach (var item in data.Items)
  562. {
  563. var obj = item.NewValue;
  564. if (obj == null) item.OriginVal = "";
  565. else if (obj.Equals("有") || obj.Equals("无"))
  566. {
  567. item.OriginVal = obj.ToString();
  568. }
  569. else if (obj is object[] objArray)
  570. {
  571. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  572. item.OriginVal = string.Join("、", stringArray);
  573. }
  574. else if (obj is string[] stringArray)
  575. {
  576. item.OriginVal = string.Join("、", stringArray);
  577. }
  578. else if (obj.Equals("-"))
  579. {
  580. item.OriginVal = "";
  581. }
  582. }
  583. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  584. fileName = CommonFun.ValidFileName(fileName);
  585. //载入模板
  586. WorkbookDesigner designer = new WorkbookDesigner();
  587. designer.Workbook = new Workbook(tempPath);
  588. if (tempId == 1406)
  589. {
  590. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  591. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  592. for (int i = 1; i <= view2.Length; i++)
  593. {
  594. view2[i - 1].Index = i;
  595. }
  596. designer.SetDataSource("View1", view1);
  597. designer.SetDataSource("View2", view2);
  598. }
  599. else
  600. {
  601. designer.SetDataSource("View", data.Items);
  602. }
  603. designer.Process();
  604. if (!Directory.Exists(savePath))
  605. {
  606. Directory.CreateDirectory(savePath);
  607. }
  608. string serverPath = $"{savePath}{fileName}";
  609. designer.Workbook.Save(serverPath);
  610. string rst = $"{servicePath}{ftpPath}{fileName}";
  611. #endregion
  612. return Ok(JsonView(new { url = rst }));
  613. }
  614. #endregion
  615. #region 团组基本信息
  616. /// <summary>
  617. /// 接团信息列表
  618. /// </summary>
  619. /// <param name="dto">团组列表请求dto</param>
  620. /// <returns></returns>
  621. [HttpPost]
  622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  623. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  624. {
  625. var groupData = await _groupRepository.GetGroupList(dto);
  626. if (groupData.Code != 0)
  627. {
  628. return Ok(JsonView(false, groupData.Msg));
  629. }
  630. return Ok(JsonView(groupData.Data));
  631. }
  632. /// <summary>
  633. /// 分页查询团组列表
  634. /// </summary>
  635. /// <param name="dto"></param>
  636. /// <returns></returns>
  637. [HttpPost]
  638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  639. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  640. {
  641. var watch = new Stopwatch();
  642. watch.Start();
  643. RefAsync<int> total = 0;
  644. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  645. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  646. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  647. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  648. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  649. .Distinct()
  650. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  651. watch.Stop();
  652. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  653. }
  654. /// <summary>
  655. /// 接团信息列表 Page Init
  656. /// </summary>
  657. /// <returns></returns>
  658. [HttpPost]
  659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  660. public async Task<IActionResult> PostGroupPageListInit()
  661. {
  662. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  663. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  664. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  665. var _view = new
  666. {
  667. depData = depDatas,
  668. rankData = rankDatas
  669. };
  670. return Ok(JsonView(true, "查询成功!", _view));
  671. }
  672. /// <summary>
  673. /// 接团信息列表 Page
  674. /// </summary>
  675. /// <param name="dto">团组列表请求dto</param>
  676. /// <returns></returns>
  677. [HttpPost]
  678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  679. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  680. {
  681. #region 参数验证
  682. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  683. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  684. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  685. #region 页面操作权限验证
  686. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  687. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  688. #endregion
  689. #endregion
  690. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  691. {
  692. string sqlWhere = string.Empty;
  693. if (dto.IsSure == 0) //未完成
  694. {
  695. sqlWhere += string.Format(@" And IsSure = 0");
  696. }
  697. else if (dto.IsSure == 1) //已完成
  698. {
  699. sqlWhere += string.Format(@" And IsSure = 1");
  700. }
  701. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  702. {
  703. string tj = dto.SearchCriteria;
  704. 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}%')",
  705. tj, tj, tj, tj, tj);
  706. }
  707. if (int.TryParse(dto.Rank, out int rankId))
  708. {
  709. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  710. }
  711. string sqlWhere1 = string.Empty;
  712. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  713. {
  714. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  715. }
  716. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  717. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  718. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  719. JietuanOperator,IsSure,CreateTime,IsBid
  720. From (
  721. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  722. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  723. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  724. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  725. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  726. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  727. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  728. From Grp_DelegationInfo gdi
  729. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  730. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  731. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  732. Where gdi.IsDel = 0 {0}
  733. ) temp {1}", sqlWhere, sqlWhere1);
  734. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  735. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  736. var _view = new
  737. {
  738. PageFuncAuth = pageFunAuthView,
  739. Data = _DelegationList
  740. };
  741. return Ok(JsonView(true, "查询成功!", _view, total));
  742. }
  743. else
  744. {
  745. return Ok(JsonView(false, "查询失败"));
  746. }
  747. }
  748. /// <summary>
  749. /// 团组列表
  750. /// </summary>
  751. /// <returns></returns>
  752. [HttpPost]
  753. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  754. {
  755. #region 参数验证
  756. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  757. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  758. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  759. #region 页面操作权限验证
  760. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  761. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  762. #endregion
  763. #endregion
  764. if (dto.PortType != 1 && dto.PortType != 2)
  765. {
  766. return Ok(JsonView(false, "查询失败!"));
  767. }
  768. string orderbyStr = "order by gdi.CreateTime Desc";
  769. string sqlWhere = string.Empty;
  770. if (dto.IsSure == 0) //未完成
  771. {
  772. sqlWhere += string.Format(@" And IsSure = 0");
  773. }
  774. else if (dto.IsSure == 1) //已完成
  775. {
  776. sqlWhere += string.Format(@" And IsSure = 1");
  777. }
  778. //团组类型
  779. if (dto.TeamDid > 0)
  780. {
  781. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  782. }
  783. //团组名称
  784. if (!string.IsNullOrEmpty(dto.TeamName))
  785. {
  786. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  787. }
  788. //客户名称
  789. if (!string.IsNullOrEmpty(dto.ClientName))
  790. {
  791. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  792. }
  793. //客户单位
  794. if (!string.IsNullOrEmpty(dto.ClientUnit))
  795. {
  796. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  797. }
  798. //出访时间
  799. if (!string.IsNullOrEmpty(dto.visitDataTime))
  800. {
  801. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  802. orderbyStr = "order by gdi.VisitDate";
  803. }
  804. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  805. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  806. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  807. JietuanOperator,IsSure,CreateTime
  808. From (
  809. Select row_number() over({0}) as Row_Number,
  810. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  811. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  812. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  813. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  814. From Grp_DelegationInfo gdi
  815. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  816. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  817. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  818. Where gdi.IsDel = 0 {1}
  819. ) temp ", orderbyStr, sqlWhere);
  820. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  821. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  822. #region 处理所属部门
  823. /*
  824. * 1.sq 和 gyy 等显示 市场部
  825. * 2.王鸽和主管及张总还有管理员号统一国交部
  826. * 2-1. 4 管理员 ,21 张海麟
  827. */
  828. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  829. List<int> userIds1 = new List<int>() { 4, 21 };
  830. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  831. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  832. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  833. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  834. .ToList();
  835. foreach (var item in _DelegationList)
  836. {
  837. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  838. }
  839. #endregion
  840. var _view = new
  841. {
  842. PageFuncAuth = pageFunAuthView,
  843. Data = _DelegationList
  844. };
  845. return Ok(JsonView(true, "查询成功!", _view, total));
  846. }
  847. /// <summary>
  848. /// 接团信息详情
  849. /// </summary>
  850. /// <param name="dto">团组info请求dto</param>
  851. /// <returns></returns>
  852. [HttpPost]
  853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  854. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  855. {
  856. var groupData = await _groupRepository.GetGroupInfo(dto);
  857. if (groupData.Code != 0)
  858. {
  859. return Ok(JsonView(false, groupData.Msg));
  860. }
  861. return Ok(JsonView(groupData.Data));
  862. }
  863. /// <summary>
  864. /// 接团信息 编辑添加
  865. /// 基础信息数据源
  866. /// </summary>
  867. /// <param name="dto"></param>
  868. /// <returns></returns>
  869. [HttpPost]
  870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  871. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  872. {
  873. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  874. if (groupData.Code != 0)
  875. {
  876. return Ok(JsonView(false, groupData.Msg));
  877. }
  878. return Ok(JsonView(groupData.Data));
  879. }
  880. /// <summary>
  881. /// 接团信息 编辑添加
  882. /// 省份-城市 基础信息数据源
  883. /// </summary>
  884. /// <param name="dto"></param>
  885. /// <returns></returns>
  886. [HttpPost]
  887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  888. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  889. {
  890. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  891. string search = dto.Search;
  892. var data = await _groupRepository.CityBasicSource();
  893. int total = data.Length;
  894. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  895. .Skip((pageIndex - 1) * pageSize)
  896. .Take(pageSize)
  897. .ToArray();
  898. return Ok(JsonView(data, total));
  899. }
  900. /// <summary>
  901. /// 接团信息 操作(增改)
  902. /// </summary>
  903. /// <param name="dto"></param>
  904. /// <returns></returns>
  905. [HttpPost]
  906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  907. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  908. {
  909. // 创建 Stopwatch 实例
  910. Stopwatch stopwatch = Stopwatch.StartNew();
  911. decimal ffrPrice = 0.00M;
  912. DateTime? visitDt = null;
  913. if (dto.Status == 2)
  914. {
  915. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  916. if (groupInfo != null)
  917. {
  918. ffrPrice = groupInfo.PaymentMoney;
  919. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  920. }
  921. }
  922. var groupData = await _groupRepository.GroupOperation(dto);
  923. if (groupData.Code != 0)
  924. {
  925. return Ok(JsonView(false, groupData.Msg));
  926. }
  927. int diId = 0;
  928. try
  929. {
  930. //添加时 默认加入团组汇率
  931. if (dto.Status == 1) //添加
  932. {
  933. diId = groupData.Data;
  934. //添加默认币种
  935. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  936. //默认分配权限
  937. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  938. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  939. var _managerIds = new List<int>() { 22, 32, 21 };
  940. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  941. if (userIds.Count > 0)
  942. {
  943. userIds.Add(208);
  944. //创建团组管控
  945. GroupStepForDelegation.CreateWorkStep(diId);
  946. //发送消息
  947. string groupName = dto.TeamName;
  948. string createGroupUser = string.Empty;
  949. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  950. if (userInfo != null) createGroupUser = userInfo.CnName;
  951. string title = $"系统通知";
  952. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  953. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  954. }
  955. //默认创建倒推表
  956. await _invertedListRep._Create(dto.UserId, diId);
  957. }
  958. else if (dto.Status == 2)
  959. {
  960. diId = dto.Id;
  961. }
  962. #region 签证人员团组时间通知
  963. #region 计算出访起止时间
  964. var startTime = new DateTime();
  965. var endTime = new DateTime();
  966. if (DateTime.TryParse(dto.VisitDate, out startTime))
  967. {
  968. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  969. }
  970. #endregion
  971. #endregion
  972. #region 团组操作默认添加/修改收款账单
  973. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  974. {
  975. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  976. .Where(x => x.IsDel == 0 &&
  977. x.Diid == diId &&
  978. x.Remark.Equals("预付款")
  979. )
  980. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  981. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  982. .FirstAsync();
  983. ffrInfo = new Fin_ForeignReceivables()
  984. {
  985. Diid = diId,
  986. PriceName = dto.ClientUnit,
  987. Price = dto.PaymentMoney,
  988. Count = 1,
  989. Unit = $"元",
  990. ItemSumPrice = dto.PaymentMoney,
  991. Rate = 1.0000M,
  992. Currency = 836,
  993. AddingWay = 0,
  994. CreateUserId = dto.UserId,
  995. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  996. Remark = $"预付款"
  997. };
  998. if (ffrInfo == null) //Add
  999. {
  1000. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1001. }
  1002. else //修改
  1003. {
  1004. await _sqlSugar.Updateable(ffrInfo)
  1005. .UpdateColumns(x => new
  1006. {
  1007. x.PriceName,
  1008. x.Price,
  1009. x.ItemSumPrice,
  1010. x.CreateTime,
  1011. x.CreateUserId
  1012. })
  1013. .WhereColumns(x => x.Id)
  1014. .ExecuteCommandAsync();
  1015. }
  1016. }
  1017. #endregion
  1018. if (diId > 0)
  1019. {
  1020. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1021. }
  1022. // 停止计时
  1023. stopwatch.Stop();
  1024. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1025. }
  1026. catch (Exception ex)
  1027. {
  1028. // 停止计时
  1029. stopwatch.Stop();
  1030. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1031. Logs(ex.Message);
  1032. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1033. }
  1034. // 停止计时
  1035. stopwatch.Stop();
  1036. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1037. }
  1038. /// <summary>
  1039. /// 接团流程操作(增改)
  1040. /// 安卓端使用 建团时添加客户名单
  1041. /// </summary>
  1042. /// <param name="dto"></param>
  1043. /// <returns></returns>
  1044. [HttpPost]
  1045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1046. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1047. {
  1048. #region 参数验证
  1049. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1050. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1051. #region 页面操作权限验证
  1052. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1053. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1054. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1055. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1056. #endregion
  1057. #endregion
  1058. try
  1059. {
  1060. //_sqlSugar.BeginTran();
  1061. decimal ffrPrice = 0.00M;
  1062. DateTime? visitDt = null;
  1063. if (dto.Status == 2)
  1064. {
  1065. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1066. if (groupInfo != null)
  1067. {
  1068. ffrPrice = groupInfo.PaymentMoney;
  1069. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1070. }
  1071. }
  1072. var _dto = new GroupOperationDto();
  1073. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1074. var groupData = await _groupRepository.GroupOperation(_dto);
  1075. if (groupData.Code != 0)
  1076. {
  1077. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1078. }
  1079. int diId = 0;
  1080. //添加时 默认加入团组汇率
  1081. if (dto.Status == 1) //添加
  1082. {
  1083. diId = groupData.Data;
  1084. //添加默认币种
  1085. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1086. //默认分配权限
  1087. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1088. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1089. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1090. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1091. if (userIds.Count > 0)
  1092. {
  1093. userIds.Add(208);
  1094. //创建团组管控
  1095. GroupStepForDelegation.CreateWorkStep(diId);
  1096. //发送消息
  1097. string groupName = dto.TeamName;
  1098. string createGroupUser = string.Empty;
  1099. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1100. if (userInfo != null) createGroupUser = userInfo.CnName;
  1101. string title = $"系统通知";
  1102. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1103. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1104. }
  1105. #region 应用推送
  1106. try
  1107. {
  1108. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1109. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1110. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1111. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1112. {
  1113. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1114. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1115. }
  1116. }
  1117. catch (Exception ex)
  1118. {
  1119. }
  1120. #endregion
  1121. //默认创建倒推表
  1122. await _invertedListRep._Create(dto.UserId, diId);
  1123. }
  1124. if (dto.Status == 2)
  1125. {
  1126. diId = dto.Id;
  1127. if (diId == 0)
  1128. {
  1129. //_sqlSugar.RollbackTran();
  1130. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1131. }
  1132. }
  1133. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1134. if (viewData.Code != 0)
  1135. {
  1136. //_sqlSugar.RollbackTran();
  1137. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1138. }
  1139. #region 团组操作默认添加/修改收款账单
  1140. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1141. {
  1142. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1143. .Where(x => x.IsDel == 0 &&
  1144. x.Diid == diId &&
  1145. x.Remark.Equals("预付款")
  1146. )
  1147. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1148. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1149. .FirstAsync();
  1150. ffrInfo = new Fin_ForeignReceivables()
  1151. {
  1152. Diid = diId,
  1153. PriceName = dto.ClientUnit,
  1154. Price = dto.PaymentMoney,
  1155. Count = 1,
  1156. Unit = $"元",
  1157. ItemSumPrice = dto.PaymentMoney,
  1158. Rate = 1.0000M,
  1159. Currency = 836,
  1160. AddingWay = 0,
  1161. CreateUserId = dto.UserId,
  1162. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1163. Remark = $"预付款"
  1164. };
  1165. if (ffrInfo == null) //Add
  1166. {
  1167. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1168. }
  1169. else //修改
  1170. {
  1171. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1172. .UpdateColumns(x => new
  1173. {
  1174. x.PriceName,
  1175. x.Price,
  1176. x.ItemSumPrice,
  1177. x.CreateTime,
  1178. x.CreateUserId
  1179. })
  1180. .WhereColumns(x => x.Id)
  1181. .ExecuteCommandAsync();
  1182. }
  1183. }
  1184. #endregion
  1185. #region 签证人员团组时间通知
  1186. #region 计算出访起止时间
  1187. var startTime = new DateTime();
  1188. var endTime = new DateTime();
  1189. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1190. {
  1191. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1192. }
  1193. #endregion
  1194. if (diId > 0)
  1195. {
  1196. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1197. }
  1198. #endregion
  1199. //_sqlSugar.CommitTran();
  1200. return Ok(JsonView(true, "添加成功"));
  1201. }
  1202. catch (Exception ex)
  1203. {
  1204. _sqlSugar.RollbackTran();
  1205. return Ok(JsonView(false, ex.Message));
  1206. }
  1207. }
  1208. /// <summary>
  1209. /// 接团流程操作(增改)
  1210. /// 安卓端使用 建团时添加客户名单
  1211. /// </summary>
  1212. /// <param name="dto"></param>
  1213. /// <returns></returns>
  1214. [HttpPost]
  1215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1216. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1217. {
  1218. #region 参数验证
  1219. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1221. #region 页面操作权限验证
  1222. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1223. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1224. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1225. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1226. #endregion
  1227. #endregion
  1228. _sqlSugar.BeginTran();
  1229. decimal ffrPrice = 0.00M;
  1230. DateTime? visitDt = null;
  1231. if (dto.Status == 2)
  1232. {
  1233. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1234. if (groupInfo != null)
  1235. {
  1236. ffrPrice = groupInfo.PaymentMoney;
  1237. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1238. }
  1239. }
  1240. var _dto = new GroupOperationDto();
  1241. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1242. var groupData = await _groupRepository.GroupOperation(_dto);
  1243. if (groupData.Code != 0)
  1244. {
  1245. _sqlSugar.RollbackTran();
  1246. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1247. }
  1248. try
  1249. {
  1250. int diId = 0;
  1251. //添加时 默认加入团组汇率
  1252. if (dto.Status == 1) //添加
  1253. {
  1254. diId = groupData.Data;
  1255. //添加默认币种
  1256. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1257. //默认分配权限
  1258. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1259. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1260. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1261. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1262. if (userIds.Count > 0)
  1263. {
  1264. userIds.Add(208);
  1265. //创建团组管控
  1266. GroupStepForDelegation.CreateWorkStep(diId);
  1267. //发送消息
  1268. string groupName = dto.TeamName;
  1269. string createGroupUser = string.Empty;
  1270. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1271. if (userInfo != null) createGroupUser = userInfo.CnName;
  1272. string title = $"系统通知";
  1273. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1274. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1275. }
  1276. #region 应用推送
  1277. try
  1278. {
  1279. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1280. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1281. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1282. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1283. {
  1284. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1285. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1286. }
  1287. }
  1288. catch (Exception ex)
  1289. {
  1290. _sqlSugar.CommitTran();
  1291. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1292. }
  1293. #endregion
  1294. //默认创建倒推表
  1295. await _invertedListRep._Create(dto.UserId, diId);
  1296. }
  1297. else if (dto.Status == 2)
  1298. {
  1299. diId = dto.Id;
  1300. if (diId == 0)
  1301. {
  1302. _sqlSugar.RollbackTran();
  1303. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1304. }
  1305. }
  1306. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1307. if (viewData.Code != 0)
  1308. {
  1309. _sqlSugar.RollbackTran();
  1310. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1311. }
  1312. #region 团组操作默认添加/修改收款账单
  1313. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1314. {
  1315. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1316. .Where(x => x.IsDel == 0 &&
  1317. x.Diid == diId &&
  1318. x.Remark.Equals("预付款")
  1319. )
  1320. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1321. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1322. .FirstAsync();
  1323. ffrInfo = new Fin_ForeignReceivables()
  1324. {
  1325. Diid = diId,
  1326. PriceName = dto.ClientUnit,
  1327. Price = dto.PaymentMoney,
  1328. Count = 1,
  1329. Unit = $"元",
  1330. ItemSumPrice = dto.PaymentMoney,
  1331. Rate = 1.0000M,
  1332. Currency = 836,
  1333. AddingWay = 0,
  1334. CreateUserId = dto.UserId,
  1335. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1336. Remark = $"预付款"
  1337. };
  1338. if (ffrInfo == null) //Add
  1339. {
  1340. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1341. }
  1342. else //修改
  1343. {
  1344. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1345. .UpdateColumns(x => new
  1346. {
  1347. x.PriceName,
  1348. x.Price,
  1349. x.ItemSumPrice,
  1350. x.CreateTime,
  1351. x.CreateUserId
  1352. })
  1353. .WhereColumns(x => x.Id)
  1354. .ExecuteCommandAsync();
  1355. }
  1356. }
  1357. #endregion
  1358. #region 签证人员团组时间通知
  1359. #region 计算出访起止时间
  1360. var startTime = new DateTime();
  1361. var endTime = new DateTime();
  1362. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1363. {
  1364. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1365. }
  1366. #endregion
  1367. if (diId > 0)
  1368. {
  1369. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1370. }
  1371. #endregion
  1372. _sqlSugar.CommitTran();
  1373. return Ok(JsonView(true));
  1374. }
  1375. catch (Exception ex)
  1376. {
  1377. _sqlSugar.RollbackTran();
  1378. return Ok(JsonView(false, ex.Message));
  1379. }
  1380. }
  1381. /// <summary>
  1382. /// 接团信息 操作(删除)
  1383. /// </summary>
  1384. /// <param name="dto"></param>
  1385. /// <returns></returns>
  1386. [HttpPost]
  1387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1388. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1389. {
  1390. var diId = dto.Id;
  1391. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1392. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1393. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1394. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1395. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1396. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1397. #endregion
  1398. var groupData = await _groupRepository.GroupDel(dto);
  1399. if (groupData.Code != 0)
  1400. {
  1401. return Ok(JsonView(false, groupData.Msg));
  1402. }
  1403. return Ok(JsonView(true));
  1404. }
  1405. /// <summary>
  1406. /// 获取团组销售报价号
  1407. /// 团组添加时 使用
  1408. /// </summary>
  1409. /// <returns></returns>
  1410. [HttpPost]
  1411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1412. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1413. {
  1414. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1415. if (groupData.Code != 0)
  1416. {
  1417. return Ok(JsonView(false, groupData.Msg));
  1418. }
  1419. object salesQuoteNo = new
  1420. {
  1421. SalesQuoteNo = groupData.Data
  1422. };
  1423. return Ok(JsonView(salesQuoteNo));
  1424. }
  1425. /// <summary>
  1426. /// 设置确认出团
  1427. /// </summary>
  1428. /// <param name="dto"></param>
  1429. /// <returns></returns>
  1430. [HttpPost]
  1431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1432. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1433. {
  1434. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1435. if (groupData.Code != 0)
  1436. {
  1437. return Ok(JsonView(false, groupData.Msg));
  1438. }
  1439. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1440. #region OA消息推送
  1441. try
  1442. {
  1443. string groupName = groupInfo.TeamName;
  1444. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1445. string title = $"系统通知";
  1446. string content = $"团组[{groupName}]已确认出团!";
  1447. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1448. }
  1449. catch (Exception ex)
  1450. {
  1451. }
  1452. #endregion
  1453. #region 应用推送
  1454. try
  1455. {
  1456. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1457. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1458. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1459. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1460. {
  1461. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1462. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1463. }
  1464. }
  1465. catch (Exception ex)
  1466. {
  1467. }
  1468. #endregion
  1469. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1470. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1471. }
  1472. /// <summary>
  1473. /// 获取团组名称data And 签证国别Data
  1474. /// </summary>
  1475. /// <param name="dto"></param>
  1476. /// <returns></returns>
  1477. [HttpPost]
  1478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1479. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1480. {
  1481. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1482. if (groupData.Code != 0)
  1483. {
  1484. return Ok(JsonView(false, groupData.Msg));
  1485. }
  1486. return Ok(JsonView(groupData.Data));
  1487. }
  1488. /// <summary>
  1489. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1490. /// </summary>
  1491. /// <returns></returns>
  1492. [HttpPost]
  1493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1494. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1495. {
  1496. try
  1497. {
  1498. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1499. if (groupData.Code != 0)
  1500. {
  1501. return Ok(JsonView(false, groupData.Msg));
  1502. }
  1503. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1504. }
  1505. catch (Exception ex)
  1506. {
  1507. return Ok(JsonView(false, "程序错误!"));
  1508. throw;
  1509. }
  1510. }
  1511. /// <summary>
  1512. /// 团组清单 Excel
  1513. /// </summary>
  1514. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1515. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1516. /// <returns></returns>
  1517. [HttpGet]
  1518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1519. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1520. {
  1521. DateTime _beginDt, _endDt;
  1522. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1523. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1524. if (!beginBool && !endBool)
  1525. {
  1526. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1527. }
  1528. string sql = string.Format(@"
  1529. SELECT
  1530. ROW_NUMBER,
  1531. Id,
  1532. SalesQuoteNo,
  1533. TourCode,
  1534. TeamTypeId,
  1535. TeamType,
  1536. TeamLevId,
  1537. TeamLev,
  1538. TeamName,
  1539. ClientName,
  1540. ClientUnit,
  1541. VisitDate,
  1542. VisitDays,
  1543. VisitPNumber,
  1544. JietuanOperatorId,
  1545. JietuanOperator,
  1546. IsSure,
  1547. CreateUserName,
  1548. IsBid
  1549. FROM
  1550. (
  1551. SELECT
  1552. ROW_NUMBER() OVER(
  1553. ORDER BY
  1554. gdi.CreateTime Desc
  1555. ) AS ROW_NUMBER,
  1556. gdi.Id,
  1557. SalesQuoteNo,
  1558. TourCode,
  1559. ssd.Id TeamTypeId,
  1560. ssd.Name TeamType,
  1561. ssd1.Id TeamLevId,
  1562. ssd1.Name TeamLev,
  1563. TeamName,
  1564. ClientName,
  1565. ClientUnit,
  1566. VisitDate,
  1567. VisitDays,
  1568. VisitPNumber,
  1569. JietuanOperator JietuanOperatorId,
  1570. su.CnName JietuanOperator,
  1571. IsSure,
  1572. gdi.CreateTime,
  1573. su1.CnName As CreateUserName,
  1574. gdi.IsBid
  1575. FROM
  1576. Grp_DelegationInfo gdi
  1577. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1578. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1579. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1580. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1581. WHERE
  1582. gdi.IsDel = 0
  1583. AND gdi.IsBid = 0
  1584. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1585. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1586. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1587. #region 处理所属部门
  1588. /*
  1589. * 1.sq 和 gyy 等显示 市场部
  1590. * 2.王鸽和主管及张总还有管理员号统一国交部
  1591. * 2-1. 4 管理员 ,21 张海麟
  1592. */
  1593. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1594. List<int> userIds1 = new List<int>() { 4, 21 };
  1595. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1596. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1597. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1598. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1599. .ToListAsync();
  1600. var droupIds = groupList.Select(it => it.Id).ToList();
  1601. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1602. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1603. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1604. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1605. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1606. {
  1607. DiId = tcl.DiId,
  1608. LastName = dc.LastName,
  1609. FirstName = dc.FirstName,
  1610. Sex = dc.Sex,
  1611. Birthday = dc.BirthDay,
  1612. Company = cc.CompanyFullName,
  1613. Job = dc.Job,
  1614. CreateTime = tcl.CreateTime,
  1615. })
  1616. .ToList();
  1617. foreach (var item in groupList)
  1618. {
  1619. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1620. string groupFirstName = "";
  1621. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1622. if (currDatas.Any())
  1623. {
  1624. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1625. }
  1626. item.GroupFirst = groupFirstName;
  1627. }
  1628. #endregion
  1629. #region Excel
  1630. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1631. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1632. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1633. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1634. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1635. //载入模板
  1636. WorkbookDesigner designer = new WorkbookDesigner();
  1637. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1638. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1639. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1640. dt.TableName = "GroupList";
  1641. designer.SetDataSource(dt);
  1642. designer.Process();
  1643. if (!Directory.Exists(savePath))
  1644. {
  1645. Directory.CreateDirectory(savePath);
  1646. }
  1647. string serverPath = $"{savePath}{fileName}";
  1648. designer.Workbook.Save(serverPath);
  1649. string rst = $"{servicePath}{ftpPath}{fileName}";
  1650. #endregion
  1651. return Ok(JsonView(true, "操作成功!", rst));
  1652. }
  1653. /// <summary>
  1654. /// 团组合同下载(1.付款80% 2.付全款)
  1655. /// </summary>
  1656. /// <param name="dto"></param>
  1657. /// <returns></returns>
  1658. /// <exception cref="Exception"></exception>
  1659. [HttpPost]
  1660. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1661. {
  1662. var jw = JsonView(false);
  1663. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1664. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1665. if (di == null)
  1666. {
  1667. jw.Msg = "团组Id有误!";
  1668. return Ok(jw);
  1669. }
  1670. #region 权限校验
  1671. var allDownFile = new List<int>() { 21 };
  1672. try
  1673. {
  1674. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1675. .First(x => x.Id == 1418 && x.IsDel == 0);
  1676. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1677. }
  1678. catch (Exception)
  1679. { }
  1680. var guojiaoDownFile = new List<int>() { 330 };
  1681. var shichangDownFile = new List<int>() { 95 };
  1682. if (allDownFile.Contains(dto.UserId))
  1683. {
  1684. }
  1685. else if (guojiaoDownFile.Contains(dto.UserId))
  1686. {
  1687. var guojiaobuDi = new List<int>() { 4, 21 };
  1688. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1689. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1690. .Where((d, u) => u.Id == di.JietuanOperator)
  1691. .Select((d, u) => d.DepName)
  1692. .First();
  1693. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1694. {
  1695. jw.Msg = "暂无下载权限!";
  1696. return Ok(jw);
  1697. }
  1698. }
  1699. else if (shichangDownFile.Contains(dto.UserId))
  1700. {
  1701. var dic = new Dictionary<int, int[]>()
  1702. {
  1703. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1704. };
  1705. try
  1706. {
  1707. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1708. if (sqSetting != null)
  1709. {
  1710. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1711. foreach (var item in result.Keys)
  1712. {
  1713. if (dic.Keys.Contains(item))
  1714. {
  1715. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1716. Array.Copy(dic[item], dilatation, dic[item].Length);
  1717. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1718. dic[item] = dilatation;
  1719. }
  1720. else
  1721. {
  1722. dic.Add(item, result[item]);
  1723. }
  1724. }
  1725. }
  1726. if (!dic[95].Contains(di.CreateUserId))
  1727. {
  1728. jw.Msg = "暂无下载权限!";
  1729. return Ok(jw);
  1730. }
  1731. }
  1732. catch (Exception)
  1733. { }
  1734. }
  1735. else if (dto.UserId == di.CreateUserId)
  1736. {
  1737. }
  1738. else
  1739. {
  1740. jw.Msg = "暂无下载权限!";
  1741. return Ok(jw);
  1742. }
  1743. #endregion
  1744. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1745. .Where(x=>x.DiId == dto.GroupId && x.IsDel == 0)
  1746. .ToListAsync();
  1747. if (!blackCodeList.Any())
  1748. {
  1749. jw.Msg = "该团无机票行程代码!";
  1750. return Ok(jw);
  1751. }
  1752. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1753. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1754. if (groupEnterExitCost == null)
  1755. {
  1756. jw.Msg = "暂无三公费用信息!";
  1757. return Ok(jw);
  1758. }
  1759. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1760. rateList ??= new List<CurrencyInfo>();
  1761. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1762. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1763. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1764. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1765. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1766. .Select((x, a, b) => new
  1767. {
  1768. x.Index,
  1769. itemName = a.Name,
  1770. CurrencyStr = b.Name,
  1771. x.Cost,
  1772. x.SubTotal,
  1773. x.Remark
  1774. })
  1775. .OrderBy((x) => x.Index)
  1776. .ToList();
  1777. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1778. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1779. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1780. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1781. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1782. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1783. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1784. decimal subJJC = 0.00M,
  1785. subGWC = 0.00M,
  1786. subTDC = 0.00M;
  1787. //经济舱
  1788. if (groupEnterExitCost.SumJJC == 1)
  1789. {
  1790. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1791. }
  1792. //公务舱
  1793. if (groupEnterExitCost.SumGWC == 1)
  1794. {
  1795. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1796. }
  1797. //头等舱
  1798. if (groupEnterExitCost.SumTDC == 1)
  1799. {
  1800. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1801. }
  1802. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1803. .LeftJoin<Sys_SetData>((x,s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0 )
  1804. .Where((x, s) => x.DiId == dto.GroupId && x.IsDel == 0)
  1805. .Select((x, s) => new
  1806. {
  1807. x.Id,
  1808. s.Name,
  1809. })
  1810. .ToListAsync();
  1811. //获取舱位人数
  1812. var cabinCount = groupClints.GroupBy(x => x.Name)
  1813. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1814. .ToList();
  1815. string cityPath = string.Empty;
  1816. string startCity = string.Empty;
  1817. string endCity = string.Empty;
  1818. foreach (var item in blackCodeList)
  1819. {
  1820. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1821. cityPath += city + "\r\n";
  1822. if (item.Equals(blackCodeList.First()))
  1823. {
  1824. var sp = city.Split('-');
  1825. startCity = sp[0];
  1826. endCity = sp[sp.Length - 1];
  1827. }
  1828. }
  1829. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1830. bookMarkDic.Add("ClientUnit",di.ClientUnit);
  1831. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1832. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1833. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1834. bookMarkDic.Add("CityPath", cityPath);
  1835. bookMarkDic.Add("StartCity", startCity);
  1836. bookMarkDic.Add("EndCity", endCity);
  1837. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays -1}晚");
  1838. Document doc = null;
  1839. var percentage = 0.8M;
  1840. var fileNameadd = "预付";
  1841. if (dto.FileType == 1)
  1842. {
  1843. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1844. }
  1845. else if (dto.FileType == 2)
  1846. {
  1847. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1848. percentage = 1;
  1849. fileNameadd = "全款";
  1850. }
  1851. else
  1852. {
  1853. throw new Exception("FileType有误!");
  1854. }
  1855. DocumentBuilder builder = new DocumentBuilder(doc);
  1856. decimal totalPrice = 0.00M;
  1857. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1858. if (firstTable != null)
  1859. {
  1860. // 遍历表格的行和单元格
  1861. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1862. {
  1863. for (int i = 0; i < row.Cells.Count; i++)
  1864. {
  1865. var cell = row.Cells[i];
  1866. // 读取单元格内容
  1867. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  1868. if (cellTextFirst.Contains("舱位"))
  1869. {
  1870. break;
  1871. }
  1872. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  1873. {
  1874. if (i == 2)
  1875. {
  1876. if (cellTextFirst == "经济舱")
  1877. {
  1878. // 设置单元格内容
  1879. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1880. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  1881. }
  1882. else
  1883. {
  1884. // 设置单元格内容
  1885. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1886. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  1887. }
  1888. }
  1889. if (i == 3)
  1890. {
  1891. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1892. if (count != null)
  1893. {
  1894. // 设置单元格内容
  1895. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1896. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  1897. }
  1898. }
  1899. if (i == 4)
  1900. {
  1901. var rowPrice = 0.00M;
  1902. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  1903. count ??= 0;
  1904. if (cellTextFirst == "经济舱")
  1905. {
  1906. rowPrice = subJJC * (int)count;
  1907. }
  1908. else
  1909. {
  1910. rowPrice = subGWC * (int)count;
  1911. }
  1912. totalPrice += rowPrice;
  1913. // 设置单元格内容
  1914. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1915. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  1916. }
  1917. }
  1918. }
  1919. }
  1920. }
  1921. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  1922. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  1923. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  1924. //--合同表格部分
  1925. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  1926. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  1927. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  1928. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  1929. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日")+"-"+di.VisitEndDate.ToString("yyyy年MM月dd日"));
  1930. bookMarkDic.Add("CityPath1", cityPath);
  1931. bookMarkDic.Add("CityPath2", cityPath);
  1932. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  1933. if (contractTable != null)
  1934. {
  1935. //数据源
  1936. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  1937. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  1938. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  1939. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  1940. .Select((it, y, s) => new
  1941. {
  1942. it.Cost,
  1943. it.SubTotal,
  1944. it.Type,
  1945. y.Id,
  1946. y.City,
  1947. s.Name,
  1948. CurrencyCodeCn = s.Remark
  1949. })
  1950. .ToList()
  1951. .Select(x => new
  1952. {
  1953. CurrencyCode = x.Name,
  1954. CityId = x.Id,
  1955. x.City,
  1956. VisitPNumber = di.VisitPNumber,
  1957. x.Type,
  1958. x.Cost,
  1959. x.SubTotal,
  1960. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  1961. x.CurrencyCodeCn,
  1962. });
  1963. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  1964. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  1965. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  1966. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  1967. List<tableSetting> tableSettings = new List<tableSetting>()
  1968. {
  1969. new tableSetting{ Index = 1 , Property = "City"},
  1970. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  1971. new tableSetting{ Index = 3 , Property = "Cost"},
  1972. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  1973. //new tableSetting{ Index = 5 , Property = ""},
  1974. //new tableSetting{ Index = 6 , Property = ""},
  1975. new tableSetting{ Index = 7 , Property = "Rate"},
  1976. //new tableSetting{ Index = 8 , Property = ""},
  1977. };
  1978. //1.住宿费
  1979. int cloneRow = 8;
  1980. int startDayPrice = 8; //写入index
  1981. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  1982. foreach (var dac in dac1)
  1983. {
  1984. var first = dac.First();
  1985. var dayCount = dac.Count();
  1986. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  1987. for (int i = 1; i < row.Cells.Count; i++)
  1988. {
  1989. var cell = row.Cells[i];
  1990. var findProperty = tableSettings.Find(x => x.Index == i);
  1991. if (findProperty != null)
  1992. {
  1993. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  1994. // 设置单元格内容
  1995. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  1996. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  1997. }
  1998. else
  1999. {
  2000. switch (i)
  2001. {
  2002. case 5:
  2003. cell.FirstParagraph.Runs.Clear();
  2004. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2005. break;
  2006. case 6:
  2007. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2008. cell.FirstParagraph.Runs.Clear();
  2009. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2010. break;
  2011. case 8:
  2012. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2013. cell.FirstParagraph.Runs.Clear();
  2014. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2015. ZSPriceSum += xiaojiRMB;
  2016. break;
  2017. default:
  2018. break;
  2019. }
  2020. }
  2021. }
  2022. startDayPrice++;
  2023. if (!dac1.Last().Equals(dac))
  2024. {
  2025. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2026. // 将克隆的行追加到原行后面
  2027. contractTable.Rows.Insert(startDayPrice, newRow);
  2028. }
  2029. else
  2030. {
  2031. cloneRow += dac1.Count() + 1;
  2032. startDayPrice = cloneRow;
  2033. }
  2034. }
  2035. //2.伙食费
  2036. foreach (var dac in dac2)
  2037. {
  2038. var first = dac.First();
  2039. var dayCount = dac.Count();
  2040. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2041. for (int i = 1; i < row.Cells.Count; i++)
  2042. {
  2043. var cell = row.Cells[i];
  2044. var findProperty = tableSettings.Find(x => x.Index == i);
  2045. if (findProperty != null)
  2046. {
  2047. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2048. // 设置单元格内容
  2049. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2050. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2051. }
  2052. else
  2053. {
  2054. switch (i)
  2055. {
  2056. case 5:
  2057. cell.FirstParagraph.Runs.Clear();
  2058. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2059. break;
  2060. case 6:
  2061. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2062. cell.FirstParagraph.Runs.Clear();
  2063. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2064. break;
  2065. case 8:
  2066. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2067. cell.FirstParagraph.Runs.Clear();
  2068. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2069. HSPriceSum += xiaojiRMB;
  2070. break;
  2071. default:
  2072. break;
  2073. }
  2074. }
  2075. }
  2076. startDayPrice++;
  2077. if (!dac2.Last().Equals(dac))
  2078. {
  2079. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2080. // 将克隆的行追加到原行后面
  2081. contractTable.Rows.Insert(startDayPrice, newRow);
  2082. }
  2083. else
  2084. {
  2085. cloneRow += dac2.Count() + 1;
  2086. startDayPrice = cloneRow;
  2087. }
  2088. }
  2089. //3.公杂费
  2090. foreach (var dac in dac3)
  2091. {
  2092. var first = dac.First();
  2093. var dayCount = dac.Count();
  2094. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2095. for (int i = 1; i < row.Cells.Count; i++)
  2096. {
  2097. var cell = row.Cells[i];
  2098. var findProperty = tableSettings.Find(x => x.Index == i);
  2099. if (findProperty != null)
  2100. {
  2101. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2102. // 设置单元格内容
  2103. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2104. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2105. }
  2106. else
  2107. {
  2108. switch (i)
  2109. {
  2110. case 5:
  2111. cell.FirstParagraph.Runs.Clear();
  2112. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2113. break;
  2114. case 6:
  2115. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2116. cell.FirstParagraph.Runs.Clear();
  2117. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2118. break;
  2119. case 8:
  2120. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2121. cell.FirstParagraph.Runs.Clear();
  2122. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2123. GZPriceSum += xiaojiRMB;
  2124. break;
  2125. default:
  2126. break;
  2127. }
  2128. }
  2129. }
  2130. startDayPrice++;
  2131. if (!dac3.Last().Equals(dac))
  2132. {
  2133. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2134. // 将克隆的行追加到原行后面
  2135. contractTable.Rows.Insert(startDayPrice, newRow);
  2136. }
  2137. else
  2138. {
  2139. cloneRow += dac3.Count() + 1;
  2140. startDayPrice = cloneRow;
  2141. }
  2142. }
  2143. //合并单元格
  2144. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2145. {
  2146. var currentRow = contractTable.Rows[i];
  2147. var nextRow = contractTable.Rows[i + 1];
  2148. // 获取当前行和下一行的第一个单元格
  2149. Cell currentCell = currentRow.Cells[0];
  2150. Cell nextCell = nextRow.Cells[0];
  2151. // 检查单元格内容是否一致(去除尾部的换行符)
  2152. string currentText = currentCell.GetText().Trim();
  2153. string nextText = nextCell.GetText().Trim();
  2154. if (currentText == nextText)
  2155. {
  2156. // 如果当前单元格已经被合并,找到合并的起始单元格
  2157. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2158. {
  2159. // 找到合并的起始单元格
  2160. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2161. // 将下一行的单元格设置为合并的后续单元格
  2162. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2163. }
  2164. else
  2165. {
  2166. // 如果当前单元格是合并的起始单元格
  2167. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2168. // 将下一行的单元格设置为合并的后续单元格
  2169. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2170. }
  2171. }
  2172. else
  2173. {
  2174. // 如果内容不一致,重置当前单元格的合并属性
  2175. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2176. {
  2177. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2178. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2179. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2180. }
  2181. else
  2182. {
  2183. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2184. }
  2185. }
  2186. }
  2187. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2188. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2189. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2190. }
  2191. foreach (var bookmarkName in bookMarkDic.Keys)
  2192. {
  2193. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2194. if (bookmark != null)
  2195. {
  2196. if (bookmarkName == "ClientUnit")
  2197. {
  2198. // 移动到书签位置
  2199. builder.MoveTo(bookmark.BookmarkStart);
  2200. // 设置字体样式为下划线
  2201. builder.Font.Underline = Aspose.Words.Underline.Single;
  2202. // 插入书签值
  2203. builder.Write(bookMarkDic[bookmarkName]);
  2204. // 清除字体格式,避免影响后续文本
  2205. builder.Font.ClearFormatting();
  2206. }
  2207. else
  2208. {
  2209. builder.MoveToBookmark(bookmarkName);
  2210. builder.Write(bookMarkDic[bookmarkName]);
  2211. }
  2212. }
  2213. }
  2214. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2215. doc.Save(savePaht);
  2216. jw.Msg = "生成成功!";
  2217. jw.Code = 200;
  2218. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath"))};
  2219. return Ok(jw);
  2220. }
  2221. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2222. {
  2223. int index = rowIndex;
  2224. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2225. {
  2226. index--;
  2227. }
  2228. return index;
  2229. }
  2230. #endregion
  2231. #region 团组&签证
  2232. /// <summary>
  2233. /// 根据团组Id获取签证客户信息List
  2234. /// </summary>
  2235. /// <param name="dto">请求dto</param>
  2236. /// <returns></returns>
  2237. [HttpPost]
  2238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2239. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2240. {
  2241. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2242. if (groupData.Code != 0)
  2243. {
  2244. return Ok(JsonView(false, groupData.Msg));
  2245. }
  2246. return Ok(JsonView(groupData.Data));
  2247. }
  2248. /// <summary>
  2249. /// IOS获取团组签证拍照上传进度01(团组列表)
  2250. /// </summary>
  2251. /// <param name="dto">请求dto</param>
  2252. /// <returns></returns>
  2253. [HttpPost]
  2254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2255. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2256. {
  2257. if (dto == null)
  2258. {
  2259. return Ok(JsonView(false, "参数为空"));
  2260. }
  2261. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2262. return Ok(JsonView(visaList));
  2263. }
  2264. /// <summary>
  2265. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2266. /// </summary>
  2267. /// <returns></returns>
  2268. [HttpPost]
  2269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2270. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2271. {
  2272. if (dto == null)
  2273. {
  2274. return Ok(JsonView(false, "请求错误:"));
  2275. }
  2276. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2277. return Ok(JsonView(list));
  2278. }
  2279. /// <summary>
  2280. /// IOS获取团组签证拍照上传进度03(相册)
  2281. /// </summary>
  2282. /// <returns></returns>
  2283. [HttpPost]
  2284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2285. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2286. {
  2287. if (dto == null)
  2288. {
  2289. return Ok(JsonView(false, "请求错误:"));
  2290. }
  2291. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2292. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2293. list.ForEach(s => s.url = url);
  2294. return Ok(JsonView(list));
  2295. }
  2296. /// <summary>
  2297. /// IOS获取团组签证拍照上传进度04(图片上传)
  2298. /// </summary>
  2299. /// <param name="dto"></param>
  2300. /// <returns></returns>
  2301. [HttpPost]
  2302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2303. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2304. {
  2305. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2306. //if (!string.IsNullOrEmpty(result))
  2307. //{
  2308. //}
  2309. //else {
  2310. // return Ok(JsonView(false, "上传失败"));
  2311. //}
  2312. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2313. int sucNum = 0;
  2314. try
  2315. {
  2316. foreach (var item in dto.base64DataList)
  2317. {
  2318. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2319. string result = DecodeBase64ToImage(item, imageName);
  2320. if (!string.IsNullOrEmpty(result))
  2321. {
  2322. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2323. pic.CreateUserId = dto.CreateUserId;
  2324. pic.PicName = imageName;
  2325. pic.PicPath = result;
  2326. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2327. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2328. if (insertResult > 0)
  2329. {
  2330. sucNum++;
  2331. }
  2332. }
  2333. }
  2334. }
  2335. catch (Exception ex)
  2336. {
  2337. return Ok(JsonView(false, ex.Message));
  2338. }
  2339. string msg = string.Format(@"成功上传{0}张", sucNum);
  2340. return Ok(JsonView(true, msg));
  2341. }
  2342. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2343. {
  2344. string filename = "";//声明一个string类型的相对路径
  2345. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2346. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2347. try//会有异常抛出,try,catch一下
  2348. {
  2349. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2350. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2351. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2352. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2353. //文件名称
  2354. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2355. //上传的文件的路径
  2356. string filePath = "";
  2357. if (!Directory.Exists(fileDir))
  2358. {
  2359. Directory.CreateDirectory(fileDir);
  2360. }
  2361. //上传的文件的路径
  2362. filePath = fileDir + filename;
  2363. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2364. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2365. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2366. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2367. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2368. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2369. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2370. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2371. bitmap.Dispose();
  2372. }
  2373. catch (Exception e)
  2374. {
  2375. string massage = e.Message;
  2376. Logs("IOS图片上传Error:" + massage);
  2377. //filename = e.Message;
  2378. }
  2379. return filename;//返回相对路径
  2380. }
  2381. /// <summary>
  2382. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2383. /// </summary>
  2384. /// <param name="dto"></param>
  2385. /// <returns></returns>
  2386. [HttpPost]
  2387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2388. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2389. {
  2390. if (dto == null)
  2391. {
  2392. return Ok(JsonView(false, "请求错误:"));
  2393. }
  2394. string msg = "参数错误";
  2395. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2396. {
  2397. try
  2398. {
  2399. //_delegationVisaRep.BeginTran();
  2400. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2401. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2402. .Where(s => s.Id == dto.visaProgressCustomerId)
  2403. .ExecuteCommandAsync();
  2404. if (updCount > 0 && dto.publishCode == 1)
  2405. {
  2406. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2407. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2408. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2409. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2410. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2411. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2412. if (groupData == null)
  2413. {
  2414. _delegationVisaRep.RollbackTran();
  2415. }
  2416. string title = string.Format(@"[签证进度更新]");
  2417. string content = string.Format(@"测试文本");
  2418. bool rst = await _message.AddMsg(new MessageDto()
  2419. {
  2420. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2421. IssuerId = dto.publisher,
  2422. Title = title,
  2423. Content = content,
  2424. ReleaseTime = DateTime.Now,
  2425. UIdList = new List<int> {
  2426. 234
  2427. }
  2428. });
  2429. if (rst)
  2430. {
  2431. return Ok(JsonView(true, "发送通知成功"));
  2432. }
  2433. }
  2434. //_delegationVisaRep.CommitTran();
  2435. }
  2436. catch (Exception)
  2437. {
  2438. //_delegationVisaRep.RollbackTran();
  2439. }
  2440. }
  2441. return Ok(JsonView(true, msg));
  2442. }
  2443. #endregion
  2444. #region 团组任务分配
  2445. /// <summary>
  2446. /// 团组任务分配初始化
  2447. /// </summary>
  2448. /// <returns></returns>
  2449. [HttpPost]
  2450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2451. public async Task<IActionResult> GetTaskAssignmen()
  2452. {
  2453. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2454. if (groupData.Code != 0)
  2455. {
  2456. return Ok(JsonView(false, groupData.Msg));
  2457. }
  2458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2459. }
  2460. /// <summary>
  2461. /// 团组任务分配查询
  2462. /// </summary>
  2463. /// <param name="dto"></param>
  2464. /// <returns></returns>
  2465. [HttpPost]
  2466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2467. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2468. {
  2469. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2470. if (groupData.Code != 0)
  2471. {
  2472. return Ok(JsonView(false, groupData.Msg));
  2473. }
  2474. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2475. }
  2476. /// <summary>
  2477. /// 团组任务分配操作
  2478. /// </summary>
  2479. /// <param name="dto"></param>
  2480. /// <returns></returns>
  2481. [HttpPost]
  2482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2483. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2484. {
  2485. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2486. if (groupData.Code != 0)
  2487. {
  2488. return Ok(JsonView(false, groupData.Msg));
  2489. }
  2490. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2491. }
  2492. /// <summary>
  2493. /// 团组任务分配
  2494. /// 批量分配
  2495. /// 查询团组
  2496. /// </summary>
  2497. /// <param name="dto"></param>
  2498. /// <returns></returns>
  2499. [HttpPost]
  2500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2501. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2502. {
  2503. //参数验证
  2504. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2505. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2506. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2507. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2508. }
  2509. /// <summary>
  2510. /// 团组任务分配
  2511. /// 批量分配
  2512. /// </summary>
  2513. /// <param name="dto"></param>
  2514. /// <returns></returns>
  2515. [HttpPost]
  2516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2517. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2518. {
  2519. //参数验证
  2520. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2521. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2522. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2523. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2524. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2525. }
  2526. #endregion
  2527. #region 团组费用审核
  2528. /// <summary>
  2529. /// 费用审核
  2530. /// 团组列表 Page
  2531. /// </summary>
  2532. /// <param name="_dto">团组列表请求dto</param>
  2533. /// <returns></returns>
  2534. [HttpPost]
  2535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2536. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2537. {
  2538. #region 参数验证
  2539. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2540. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2541. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2542. #region 页面操作权限验证
  2543. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2544. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2545. #endregion
  2546. #endregion
  2547. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2548. {
  2549. string sqlWhere = string.Empty;
  2550. if (_dto.IsSure == 0) //未完成
  2551. {
  2552. sqlWhere += string.Format(@" And IsSure = 0");
  2553. }
  2554. else if (_dto.IsSure == 1) //已完成
  2555. {
  2556. sqlWhere += string.Format(@" And IsSure = 1");
  2557. }
  2558. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2559. {
  2560. string tj = _dto.SearchCriteria;
  2561. 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}%')",
  2562. tj, tj, tj, tj, tj);
  2563. }
  2564. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2565. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2566. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2567. From (
  2568. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2569. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2570. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2571. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2572. From Grp_DelegationInfo gdi
  2573. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2574. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2575. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2576. Where gdi.IsDel = 0 {0}
  2577. ) temp ", sqlWhere);
  2578. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2579. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2580. var _view = new
  2581. {
  2582. PageFuncAuth = pageFunAuthView,
  2583. Data = _DelegationList
  2584. };
  2585. return Ok(JsonView(true, "查询成功!", _view, total));
  2586. }
  2587. else
  2588. {
  2589. return Ok(JsonView(false, "查询失败"));
  2590. }
  2591. }
  2592. /// <summary>
  2593. /// 获取团组费用审核
  2594. /// </summary>
  2595. /// <param name="_dto"></param>
  2596. /// <returns></returns>
  2597. [HttpPost]
  2598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2599. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2600. {
  2601. try
  2602. {
  2603. #region 参数验证
  2604. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2605. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2606. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2607. #region 页面操作权限验证
  2608. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2609. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2610. #endregion
  2611. #endregion
  2612. var _view = new Grp_CreditCardPaymentView();
  2613. var clientNameList = getSimplClientList(_dto.DiId);
  2614. #region 费用清单
  2615. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2616. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2617. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2618. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2619. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2620. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2621. /*
  2622. * 76://酒店预订
  2623. */
  2624. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2625. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2626. /*
  2627. * 79://车/导游地接
  2628. */
  2629. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2630. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2631. /*
  2632. * 80: //签证
  2633. */
  2634. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2635. /*
  2636. *81: //邀请/公务活动
  2637. */
  2638. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2639. /*
  2640. * 82: //团组客户保险
  2641. */
  2642. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2643. /*
  2644. * Lable = 85 机票预订
  2645. */
  2646. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2647. /*
  2648. * 85 机票预定
  2649. */
  2650. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2651. /*
  2652. * 98 其他款项
  2653. */
  2654. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2655. /*
  2656. * 285:收款退还
  2657. */
  2658. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2659. /*
  2660. * 1015: //超支费用
  2661. */
  2662. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2663. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2664. /*
  2665. * 币种信息
  2666. */
  2667. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2668. /*
  2669. * 车/导游地接 费用类型
  2670. */
  2671. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2672. /*
  2673. * 车/导游地接 费用类型
  2674. */
  2675. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2676. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2677. /*
  2678. * 用户信息
  2679. */
  2680. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2681. /*
  2682. * 费用模块
  2683. */
  2684. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2685. string priceModule = string.Empty;
  2686. if (sdPriceName != null)
  2687. {
  2688. priceModule = sdPriceName.Name;
  2689. }
  2690. /*
  2691. * 成本信息
  2692. */
  2693. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2694. decimal _groupRate = 0.0000M;
  2695. string _groupCurrencyCode = "-";
  2696. if (groupCost != null)
  2697. {
  2698. _groupRate = groupCost.Rate;
  2699. if (int.TryParse(groupCost.Currency, out int _currency))
  2700. {
  2701. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2702. }
  2703. else _groupCurrencyCode = groupCost.Currency;
  2704. }
  2705. string costContentSql = $"Select * From Grp_GroupCost";
  2706. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2707. //处理日期为空的天数
  2708. for (int i = 0; i < groupCostDetails.Count; i++)
  2709. if (i != 0)
  2710. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2711. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2712. /*
  2713. * 处理详情数据
  2714. */
  2715. foreach (var entity in entityList)
  2716. {
  2717. var _detail = new Grp_CreditCardPaymentDetailView();
  2718. _detail.Id = entity.Id;
  2719. _detail.PriceName = priceModule;
  2720. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2721. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2722. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2723. //处理金额
  2724. if (entity.CTable == 1015)
  2725. {
  2726. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2727. if (czInfo != null)
  2728. {
  2729. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2730. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2731. }
  2732. }
  2733. /*
  2734. * 应付款金额
  2735. */
  2736. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2737. string PaymentCurrency_WaitPay = "Unknown";
  2738. string hotelCurrncyCode = "Unknown";
  2739. string hotelCurrncyName = "Unknown";
  2740. if (sdPaymentCurrency_WaitPay != null)
  2741. {
  2742. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2743. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2744. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2745. if (hotelCurrncyCode.Equals("CNY"))
  2746. {
  2747. entity.DayRate = 1.0000M;
  2748. }
  2749. }
  2750. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2751. /*
  2752. * 此次付款金额
  2753. */
  2754. decimal CurrPayStr = 0.00M,
  2755. OriginalCurrPay = 0.00M;
  2756. if (entity.PayPercentage == 0)
  2757. {
  2758. if (entity.PayThenMoney != 0)
  2759. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2760. }
  2761. else
  2762. {
  2763. if (entity.PayMoney != 0)
  2764. {
  2765. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2766. }
  2767. }
  2768. //if (_dto.Label == 79)
  2769. //{
  2770. // string original = string.Empty;
  2771. // if (hotelCurrncyCode.Equals("CNY"))
  2772. // {
  2773. // OriginalCurrPay = CurrPayStr;
  2774. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2775. // }
  2776. // else
  2777. // {
  2778. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2779. // //760 EUR(7600.00 CNY)
  2780. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2781. // }
  2782. //}
  2783. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2784. string original = string.Empty;
  2785. if (hotelCurrncyCode.Equals("CNY"))
  2786. {
  2787. OriginalCurrPay = CurrPayStr;
  2788. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2789. }
  2790. else
  2791. {
  2792. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2793. //760 EUR(7600.00 CNY)
  2794. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2795. }
  2796. /*
  2797. * 剩余尾款
  2798. */
  2799. decimal BalanceStr = 0;
  2800. if (CurrPayStr != 0)
  2801. {
  2802. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2803. BalanceStr = 0;
  2804. else
  2805. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2806. }
  2807. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2808. /*
  2809. * Bus名称
  2810. */
  2811. _detail.BusName = "待增加";
  2812. /*
  2813. *费用所属
  2814. */
  2815. switch (entity.CTable)
  2816. {
  2817. case 76://酒店预订
  2818. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2819. if (hotelReservations != null)
  2820. {
  2821. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2822. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2823. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2824. string roomFeeStr = "", roomFeestr1 = "";
  2825. //是否比较房型价格
  2826. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2827. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2828. roomFeeStr += $"<br/>";
  2829. var roomTotal = 0.00M;
  2830. if (hotelReservations.SingleRoomPrice > 0)
  2831. {
  2832. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2833. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2834. //__isSingle = true;
  2835. roomTotal += fee;
  2836. }
  2837. if (hotelReservations.DoubleRoomPrice > 0)
  2838. {
  2839. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2840. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2841. // __isDouble = true;
  2842. roomTotal += fee;
  2843. }
  2844. if (hotelReservations.SuiteRoomPrice > 0)
  2845. {
  2846. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2847. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2848. //__isSuite = true;
  2849. roomTotal += fee;
  2850. }
  2851. if (hotelReservations.OtherRoomPrice > 0)
  2852. {
  2853. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2854. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2855. //__isOther = true;
  2856. roomTotal += fee;
  2857. }
  2858. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2859. else roomFeeStr += " 0.00 * 0";
  2860. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2861. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2862. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2863. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2864. /*
  2865. * 费用类型
  2866. * 1:房费
  2867. * 2:早餐
  2868. * 3:地税
  2869. * 4:城市税
  2870. * </summary>
  2871. */
  2872. //地税
  2873. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2874. if (governmentRentData != null)
  2875. {
  2876. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2877. governmentRentFee = governmentRentData.Price;
  2878. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2879. if (governmentRentCurrData != null)
  2880. {
  2881. governmentRentCode = governmentRentCurrData.Name;
  2882. governmentRentName = $"({governmentRentCurrData.Remark})";
  2883. }
  2884. }
  2885. //城市税
  2886. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2887. if (cityTaxData != null)
  2888. {
  2889. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2890. cityTaxFee = cityTaxData.Price;
  2891. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2892. if (cityTaxCurrData != null)
  2893. {
  2894. cityTaxCode = cityTaxCurrData.Name;
  2895. cityTaxName = $"({cityTaxCurrData.Remark})";
  2896. }
  2897. }
  2898. //酒店早餐
  2899. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2900. if (breakfastData != null)
  2901. {
  2902. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2903. breakfastFee = breakfastData.Price;
  2904. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2905. if (breakfastCurrData != null)
  2906. {
  2907. breakfastCode = breakfastCurrData.Name;
  2908. breakfastName = $"({breakfastCurrData.Remark})";
  2909. }
  2910. }
  2911. //房间费用
  2912. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2913. if (roomData != null)
  2914. {
  2915. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2916. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2917. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2918. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2919. roomFee = roomData.Price;
  2920. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2921. if (roomCurrData != null)
  2922. {
  2923. roomCode = roomCurrData.Name;
  2924. roomName = $"({roomCurrData.Remark})";
  2925. }
  2926. }
  2927. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2928. string hotelCostStr = "";
  2929. decimal hotelCsotTotal = 0.00M;
  2930. if (groupCost != null)
  2931. {
  2932. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2933. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2934. }
  2935. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2936. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2937. string hotelCost_day = "";
  2938. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2939. foreach (var item in hotelCostDetails1)
  2940. {
  2941. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2942. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2943. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2944. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2945. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2946. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2947. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2948. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2949. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2950. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2951. hotelCost_day += @$"<br/>";
  2952. }
  2953. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2954. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2955. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2956. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2957. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2958. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2959. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2960. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2961. $"房间说明: {hotelReservations.Remark} <br/>" +
  2962. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2963. $"{hotelBreakfastStr}" +
  2964. $"{hotelGovernmentRentStr}" +
  2965. $"{hotelCityTaxStr}";
  2966. _detail.PriceNameContent = hotelReservations.HotelName;
  2967. }
  2968. break;
  2969. case 79://车/导游地接
  2970. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2971. if (touristGuideGroundReservations != null)
  2972. {
  2973. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2974. {
  2975. _detail.BusName = touristGuideGroundReservations.BusName;
  2976. }
  2977. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2978. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2979. //if (isInt)
  2980. //{
  2981. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2982. // if (cityInfo != null)
  2983. // {
  2984. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2985. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2986. // if (carFeeItem != null)
  2987. // {
  2988. // nameContent += $@"({carFeeItem.Name})";
  2989. // }
  2990. // _detail.PriceNameContent = nameContent;
  2991. // }
  2992. //}
  2993. //else
  2994. //{
  2995. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2996. //}
  2997. var touristGuideGroundReservationsContents =
  2998. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2999. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3000. foreach (var item in touristGuideGroundReservationsContents)
  3001. {
  3002. string typeName = "Unknown";
  3003. string carCurrencyCode = "Unknown";
  3004. string carCurrencyName = "Unknown";
  3005. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3006. if (carTypeData != null) typeName = carTypeData.Name;
  3007. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3008. if (currencyData != null)
  3009. {
  3010. carCurrencyCode = currencyData.Name;
  3011. carCurrencyName = currencyData.Remark;
  3012. }
  3013. //op、成本 币种是否一致
  3014. bool IsCurrencyAgreement = false;
  3015. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3016. string opCostStr = string.Empty;
  3017. decimal opCostTypePrice = 0.00M;
  3018. #region 处理成本各项费用
  3019. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3020. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3021. if (opCost.Count > 0)
  3022. {
  3023. switch (item.SId)
  3024. {
  3025. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3026. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3027. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3028. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3029. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3030. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3031. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3032. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3033. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3034. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3035. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3036. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3037. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3038. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3039. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3040. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3041. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3042. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3043. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3044. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3045. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3046. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3047. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3048. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3049. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3050. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3051. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3052. }
  3053. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  3054. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  3055. }
  3056. #endregion
  3057. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  3058. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  3059. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3060. $"{opTypeStr} {opCostStr}<br/>" +
  3061. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3062. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3063. }
  3064. _detail.PriceMsgContent = priceMsg;
  3065. }
  3066. break;
  3067. case 80: //签证
  3068. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3069. if (visaInfo != null)
  3070. {
  3071. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3072. _detail.PriceNameContent = visaInfo.VisaDescription;
  3073. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3074. }
  3075. break;
  3076. case 81: //邀请/公务活动
  3077. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3078. if (_ioa != null)
  3079. {
  3080. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3081. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3082. sendCurrName = "Unknown", //快递费用币种 Name
  3083. sendCurrCode = "Unknown", //快递费用币种 Code
  3084. eventsCurrName = "Unknown", //公务活动费币种 Name
  3085. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3086. translateCurrName = "Unknown", //公务翻译费 Name
  3087. translateCurrCode = "Unknown"; //公务翻译费 Code
  3088. #region 处理费用币种
  3089. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3090. if (inviteCurrData != null)
  3091. {
  3092. inviteCurrName = inviteCurrData.Remark;
  3093. inviteCurrCode = inviteCurrData.Name;
  3094. }
  3095. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3096. if (sendCurrData != null)
  3097. {
  3098. sendCurrName = sendCurrData.Remark;
  3099. sendCurrCode = sendCurrData.Name;
  3100. }
  3101. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3102. if (eventsCurrData != null)
  3103. {
  3104. eventsCurrName = eventsCurrData.Remark;
  3105. eventsCurrCode = eventsCurrData.Name;
  3106. }
  3107. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3108. if (translateCurrData != null)
  3109. {
  3110. translateCurrName = translateCurrData.Remark;
  3111. translateCurrCode = translateCurrData.Name;
  3112. }
  3113. #endregion
  3114. _detail.PriceNameContent = _ioa.InviterArea;
  3115. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3116. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3117. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3118. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3119. $@"备注:" + _ioa.Remark + "<br/>";
  3120. }
  3121. break;
  3122. case 82: //团组客户保险
  3123. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3124. if (customers != null)
  3125. {
  3126. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3127. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3128. }
  3129. break;
  3130. case 85: //机票预订
  3131. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3132. if (jpRes != null)
  3133. {
  3134. string FlightsDescription = jpRes.FlightsDescription;
  3135. string PriceDescription = jpRes.PriceDescription;
  3136. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3137. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3138. }
  3139. break;
  3140. case 98://其他款项
  3141. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3142. if (gdpRes != null)
  3143. {
  3144. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3145. _detail.PriceNameContent = gdpRes.PriceName;
  3146. }
  3147. break;
  3148. case 285://收款退还
  3149. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3150. if (refundAndOtherMoney != null)
  3151. {
  3152. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3153. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3154. }
  3155. break;
  3156. case 751://酒店早餐
  3157. break;
  3158. case 1015://超支费用
  3159. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3160. if (groupExtraCost != null)
  3161. {
  3162. _detail.PriceNameContent = groupExtraCost.PriceName;
  3163. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3164. }
  3165. break;
  3166. default:
  3167. break;
  3168. }
  3169. /*
  3170. * 申请人
  3171. */
  3172. string operatorName = " - ";
  3173. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3174. if (_opUser != null)
  3175. {
  3176. operatorName = _opUser.CnName;
  3177. }
  3178. _detail.OperatorName = operatorName;
  3179. /*
  3180. * 审核人
  3181. */
  3182. string auditOperatorName = "Unknown";
  3183. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3184. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3185. else
  3186. {
  3187. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3188. if (_adUser != null)
  3189. {
  3190. auditOperatorName = _adUser.CnName;
  3191. }
  3192. }
  3193. _detail.AuditOperatorName = auditOperatorName;
  3194. /*
  3195. * 超预算比例
  3196. */
  3197. string overBudgetStr = "";
  3198. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3199. else if (entity.ExceedBudget == 0)
  3200. {
  3201. if (entity.CTable == 76 || entity.CTable == 79)
  3202. {
  3203. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3204. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3205. }
  3206. else
  3207. {
  3208. overBudgetStr = "未超预算";
  3209. }
  3210. }
  3211. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3212. _detail.OverBudget = overBudgetStr;
  3213. decimal auditFee = 0.00M; //已审核金额 人名币
  3214. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3215. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3216. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3217. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3218. {
  3219. auditedFeeOriginal = entity.PayMoney;
  3220. auditFee = CurrPayStr;
  3221. }
  3222. else if (entity.IsAuditGM == 0)
  3223. {
  3224. unAuditFeeCNY = CurrPayStr;
  3225. unAuditFeeOriginal = OriginalCurrPay;
  3226. OriginalCurrPay = 0.00M;
  3227. }
  3228. /*
  3229. * 费用总计
  3230. */
  3231. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3232. {
  3233. CurrencyId = entity.PaymentCurrency,
  3234. CurrencyName = PaymentCurrency_WaitPay,
  3235. AmountPayable = entity.PayMoney,
  3236. ThisPayment = OriginalCurrPay,
  3237. BalancePayment = BalanceStr,
  3238. AuditedFunds = auditFee,
  3239. AuditedFundsOriginal = auditedFeeOriginal,
  3240. UnAuditFundsCNY = unAuditFeeCNY,
  3241. UnAuditFundsOriginal = unAuditFeeOriginal
  3242. });
  3243. _detail.IsAuditGM = entity.IsAuditGM;
  3244. detailList.Add(_detail);
  3245. }
  3246. #endregion
  3247. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3248. /*
  3249. * 下方描述处理
  3250. */
  3251. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3252. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3253. if (ccpCurrencyPrice != null)
  3254. {
  3255. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3256. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3257. }
  3258. else
  3259. {
  3260. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3261. }
  3262. string amountPayableStr = string.Format(@"应付款总金额: ");
  3263. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3264. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3265. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3266. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3267. foreach (var item in nonDuplicat)
  3268. {
  3269. var currencyName = item.CurrencyName;
  3270. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3271. if (strs.Count > 0)
  3272. {
  3273. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3274. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3275. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3276. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3277. //单独处理此次付款金额
  3278. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3279. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3280. //单独处理已审核费用
  3281. //if (item.CurrencyId == 836) //人民币
  3282. //{
  3283. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3284. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3285. //}
  3286. //else
  3287. //{
  3288. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3289. //}
  3290. if (currencyName.Equals("CNY"))
  3291. {
  3292. //已审核费用
  3293. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3294. //未审核费用
  3295. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3296. }
  3297. else
  3298. {
  3299. //已审核费用
  3300. 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"));
  3301. //未审核费用
  3302. 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"));
  3303. }
  3304. }
  3305. }
  3306. _view.TotalStr1 = amountPayableStr[..^1];
  3307. _view.TotalStr2 = thisPaymentStr[..^1];
  3308. _view.TotalStr3 = balancePaymentStr[..^1];
  3309. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3310. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3311. var _view1 = new
  3312. {
  3313. PageFuncAuth = pageFunAuthView,
  3314. Data = _view
  3315. };
  3316. return Ok(JsonView(_view1));
  3317. }
  3318. catch (Exception ex)
  3319. {
  3320. return Ok(JsonView(false, ex.Message));
  3321. }
  3322. }
  3323. /// <summary>
  3324. /// 费用审核
  3325. /// 修改团组费用审核状态
  3326. /// </summary>
  3327. /// <param name="_dto">参数Json字符串</param>
  3328. /// <returns></returns>
  3329. [HttpPost]
  3330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3331. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3332. {
  3333. #region 参数验证
  3334. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3335. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3336. #endregion
  3337. #region 页面操作权限验证
  3338. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3339. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3340. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3341. #endregion
  3342. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3343. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3344. DateTime dtNow = DateTime.Now;
  3345. _groupRepository.BeginTran();
  3346. int rst = 0;
  3347. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3348. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3349. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3350. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3351. List<dynamic> msgDatas = new List<dynamic>();
  3352. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3353. foreach (var item in idList)
  3354. {
  3355. int CreditId = int.Parse(item);
  3356. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3357. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3358. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3359. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3360. .Where(s => s.Id == CreditId)
  3361. .ExecuteCommandAsync();
  3362. if (result < 1)
  3363. {
  3364. rst = -1;
  3365. _groupRepository.RollbackTran();
  3366. return Ok(JsonView(false, "操作失败并回滚!"));
  3367. }
  3368. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3369. if (creditData != null)
  3370. {
  3371. #region 应用通知配置
  3372. try
  3373. {
  3374. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3375. }
  3376. catch (Exception ex)
  3377. {
  3378. }
  3379. #endregion
  3380. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3381. string groupNameStr = string.Empty;
  3382. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3383. if (groupData != null) groupNameStr = groupData.TeamName;
  3384. string creditTypeStr = string.Empty;
  3385. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3386. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3387. string creditCurrency = string.Empty;
  3388. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3389. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3390. if (creditCurrency.Equals("CNY"))
  3391. {
  3392. creditData.DayRate = 1.0000M;
  3393. }
  3394. if (creditData.PayPercentage == 0.00M)
  3395. {
  3396. creditData.PayPercentage = 100M;
  3397. }
  3398. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3399. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3400. string msgContent = "";
  3401. if (creditCurrency.Equals("CNY"))
  3402. {
  3403. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3404. }
  3405. else
  3406. {
  3407. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3408. }
  3409. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3410. }
  3411. }
  3412. if (rst == 0)
  3413. {
  3414. _groupRepository.CommitTran();
  3415. foreach (var item in msgDatas)
  3416. {
  3417. //发送消息
  3418. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3419. }
  3420. #region 应用推送
  3421. try
  3422. {
  3423. foreach (var ccpId in dic_ccp_user.Keys)
  3424. {
  3425. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3426. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3427. }
  3428. }
  3429. catch (Exception)
  3430. {
  3431. }
  3432. #endregion
  3433. return Ok(JsonView(true, "操作成功!"));
  3434. }
  3435. return Ok(JsonView(false, "操作失败!"));
  3436. }
  3437. #endregion
  3438. #region 机票费用录入
  3439. /// <summary>
  3440. /// 机票录入当前登录人可操作团组
  3441. /// </summary>
  3442. /// <param name="dto"></param>
  3443. /// <returns></returns>
  3444. [HttpPost]
  3445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3446. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3447. {
  3448. try
  3449. {
  3450. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3451. if (groupData.Code != 0)
  3452. {
  3453. return Ok(JsonView(false, groupData.Msg));
  3454. }
  3455. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3456. }
  3457. catch (Exception ex)
  3458. {
  3459. return Ok(JsonView(false, "程序错误!"));
  3460. throw;
  3461. }
  3462. }
  3463. /// <summary>
  3464. /// 机票费用录入列表
  3465. /// </summary>
  3466. /// <param name="dto"></param>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3471. {
  3472. try
  3473. {
  3474. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3475. if (groupData.Code != 0)
  3476. {
  3477. return Ok(JsonView(false, groupData.Msg));
  3478. }
  3479. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3480. }
  3481. catch (Exception ex)
  3482. {
  3483. return Ok(JsonView(false, ex.Message));
  3484. throw;
  3485. }
  3486. }
  3487. /// <summary>
  3488. /// 根据id查询费用录入信息
  3489. /// </summary>
  3490. /// <param name="dto"></param>
  3491. /// <returns></returns>
  3492. [HttpPost]
  3493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3494. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3495. {
  3496. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3497. if (groupData.Code != 0)
  3498. {
  3499. return Ok(JsonView(false, groupData.Msg));
  3500. }
  3501. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3502. }
  3503. /// <summary>
  3504. /// 机票费用录入操作(Status:1.新增,2.修改)
  3505. /// </summary>
  3506. /// <param name="dto"></param>
  3507. /// <returns></returns>
  3508. [HttpPost]
  3509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3510. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3511. {
  3512. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3513. if (groupData.Code != 0)
  3514. {
  3515. return Ok(JsonView(false, groupData.Msg));
  3516. }
  3517. #region 应用推送
  3518. try
  3519. {
  3520. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3521. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3522. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3523. //2024-10-21 新增LZ UID
  3524. var userIds = new List<int>() { 21 };
  3525. string title = $"系统通知";
  3526. string content = "";
  3527. var diId = dto.AirTicketResOpData.DiId;
  3528. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3529. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3530. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3531. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3532. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3533. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3534. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3535. }
  3536. catch (Exception ex)
  3537. {
  3538. }
  3539. #endregion
  3540. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3541. }
  3542. /// <summary>
  3543. /// 根据舱位类型查询接团客户名单信息
  3544. /// </summary>
  3545. /// <param name="dto"></param>
  3546. /// <returns></returns>
  3547. [HttpPost]
  3548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3549. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3550. {
  3551. try
  3552. {
  3553. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3554. if (crm_Groups.Count != 0)
  3555. {
  3556. List<dynamic> Customer = new List<dynamic>();
  3557. foreach (var item in crm_Groups)
  3558. {
  3559. var data = new
  3560. {
  3561. Id = item.Id,
  3562. Pinyin = item.Pinyin,
  3563. Name = item.LastName + item.FirstName
  3564. };
  3565. Customer.Add(data);
  3566. }
  3567. return Ok(JsonView(true, "查询成功!", Customer));
  3568. }
  3569. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3570. }
  3571. catch (Exception ex)
  3572. {
  3573. return Ok(JsonView(false, "程序错误!"));
  3574. throw;
  3575. }
  3576. }
  3577. /// <summary>
  3578. /// 根据团号获取客户信息
  3579. /// </summary>
  3580. /// <param name="dto"></param>
  3581. /// <returns></returns>
  3582. [HttpPost]
  3583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3584. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3585. {
  3586. var jw = JsonView(false);
  3587. if (dto.DIID < 1)
  3588. {
  3589. jw.Msg += "请输入正确的diid";
  3590. return Ok(jw);
  3591. }
  3592. var arr = getSimplClientList(dto.DIID);
  3593. jw = JsonView(true, "获取成功!", arr);
  3594. return Ok(jw);
  3595. }
  3596. private List<SimplClientInfo> getSimplClientList(int diId)
  3597. {
  3598. 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);
  3599. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3600. foreach (var item in arr)
  3601. {
  3602. EncryptionProcessor.DecryptProperties(item);
  3603. }
  3604. return arr;
  3605. }
  3606. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3607. {
  3608. string result = origin;
  3609. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3610. {
  3611. string[] temparr = origin.Split(',');
  3612. string fistrStr = temparr[0];
  3613. int count = temparr.Count();
  3614. int tempId;
  3615. bool success = int.TryParse(fistrStr, out tempId);
  3616. if (success)
  3617. {
  3618. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3619. if (tempInfo != null)
  3620. {
  3621. if (count > 1)
  3622. {
  3623. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3624. }
  3625. else
  3626. {
  3627. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3628. }
  3629. }
  3630. }
  3631. }
  3632. return result;
  3633. }
  3634. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3635. {
  3636. string result = origin;
  3637. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3638. {
  3639. string[] temparr = origin.Split(',');
  3640. result = "";
  3641. foreach (var item in temparr)
  3642. {
  3643. int tempId;
  3644. bool success = int.TryParse(item, out tempId);
  3645. if (success)
  3646. {
  3647. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3648. if (tempInfo != null)
  3649. {
  3650. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3651. }
  3652. }
  3653. }
  3654. }
  3655. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3656. return result;
  3657. }
  3658. /// <summary>
  3659. /// 机票费用录入,删除
  3660. /// </summary>
  3661. /// <param name="dto"></param>
  3662. /// <returns></returns>
  3663. [HttpPost]
  3664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3665. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3666. {
  3667. try
  3668. {
  3669. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3670. if (res)
  3671. {
  3672. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3673. {
  3674. IsDel = 1,
  3675. DeleteUserId = dto.DeleteUserId,
  3676. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3677. }).ExecuteCommandAsync();
  3678. return Ok(JsonView(true, "删除成功!"));
  3679. }
  3680. return Ok(JsonView(false, "删除失败!"));
  3681. }
  3682. catch (Exception ex)
  3683. {
  3684. return Ok(JsonView(false, "程序错误!"));
  3685. throw;
  3686. }
  3687. }
  3688. /// <summary>
  3689. /// 导出机票录入报表
  3690. /// </summary>
  3691. /// <param name="dto"></param>
  3692. /// <returns></returns>
  3693. [HttpPost]
  3694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3695. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3696. {
  3697. try
  3698. {
  3699. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3700. if (groupData.Code != 0)
  3701. {
  3702. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3703. }
  3704. else
  3705. {
  3706. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3707. if (AirTicketReservations.Count != 0)
  3708. {
  3709. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3710. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3711. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3712. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3713. WorkbookDesigner designer = new WorkbookDesigner();
  3714. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3715. decimal countCost = 0;
  3716. foreach (var item in AirTicketReservations)
  3717. {
  3718. #region 处理客人姓名
  3719. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3720. item.ClientName = clientNames;
  3721. #endregion
  3722. if (item.BankType == "其他")
  3723. {
  3724. item.BankNo = "--";
  3725. }
  3726. else
  3727. {
  3728. if (!string.IsNullOrEmpty(item.BankType))
  3729. {
  3730. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3731. }
  3732. }
  3733. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3734. item.Price = System.Decimal.Round(item.Price, 2);
  3735. countCost += Convert.ToDecimal(item.Price);
  3736. }
  3737. designer.SetDataSource("Export", AirTicketReservations);
  3738. designer.SetDataSource("ExportDiCode", diCode);
  3739. designer.SetDataSource("ExportDiName", diName);
  3740. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3741. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3742. designer.Process();
  3743. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3744. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3745. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3746. return Ok(JsonView(true, "成功", url = rst));
  3747. }
  3748. else
  3749. {
  3750. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3751. }
  3752. }
  3753. }
  3754. catch (Exception ex)
  3755. {
  3756. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3757. throw;
  3758. }
  3759. }
  3760. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3761. /// <summary>
  3762. /// 行程单导出
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3769. {
  3770. try
  3771. {
  3772. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3773. if (groupData.Code != 0)
  3774. {
  3775. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3776. }
  3777. else
  3778. {
  3779. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3780. if (dto.Language == "CN")
  3781. {
  3782. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3783. DocumentBuilder builder = new DocumentBuilder(doc);
  3784. int tableIndex = 0;//表格索引
  3785. //得到文档中的第一个表格
  3786. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3787. foreach (var item in _AirTicketReservations)
  3788. {
  3789. #region 处理固定数据
  3790. string[] FlightsCode = item.FlightsCode.Split('/');
  3791. if (FlightsCode.Length != 0)
  3792. {
  3793. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3794. if (_AirCompany != null)
  3795. {
  3796. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3797. }
  3798. else
  3799. {
  3800. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3801. }
  3802. }
  3803. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3804. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3805. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3806. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3807. string name = "";
  3808. foreach (string clientName in nameArray)
  3809. {
  3810. if (!name.Contains(clientName))
  3811. {
  3812. name += clientName + ",";
  3813. }
  3814. }
  3815. if (!string.IsNullOrWhiteSpace(name))
  3816. {
  3817. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3818. }
  3819. else
  3820. {
  3821. table.Range.Bookmarks["ClientName"].Text = "--";
  3822. }
  3823. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3824. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3825. table.Range.Bookmarks["JointTicket"].Text = "--";
  3826. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3827. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3828. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3829. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3830. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3831. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3832. #endregion
  3833. #region 循环数据处理
  3834. List<AirInfo> airs = new List<AirInfo>();
  3835. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3836. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3837. for (int i = 0; i < FlightsCode.Length; i++)
  3838. {
  3839. AirInfo air = new AirInfo();
  3840. string[] tempstr = DayArray[i]
  3841. .Replace("\r\n", string.Empty)
  3842. .Replace("\\r\\n", string.Empty)
  3843. .TrimStart().TrimEnd()
  3844. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3845. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3846. string starCity = "";
  3847. if (star_Three != null)
  3848. {
  3849. starCity = star_Three.AirPort;
  3850. }
  3851. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3852. string EndCity = "";
  3853. if (End_Three != null)
  3854. {
  3855. EndCity = End_Three.AirPort;
  3856. }
  3857. air.Destination = starCity + "/" + EndCity;
  3858. air.Flight = FlightsCode[i];
  3859. air.SeatingClass = item.CTypeName;
  3860. string dateTime = tempstr[2];
  3861. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3862. air.FlightDate = DateTemp;
  3863. air.DepartureTime = tempstr[5];
  3864. air.LandingTime = tempstr[6];
  3865. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3866. air.TicketStatus = "--";
  3867. air.Luggage = "--";
  3868. air.DepartureTerminal = "--";
  3869. air.LandingTerminal = "--";
  3870. airs.Add(air);
  3871. }
  3872. int row = 13;
  3873. for (int i = 0; i < airs.Count; i++)
  3874. {
  3875. if (airs.Count > 2)
  3876. {
  3877. for (int j = 0; j < airs.Count - 2; j++)
  3878. {
  3879. var CopyRow = table.Rows[12].Clone(true);
  3880. table.Rows.Add(CopyRow);
  3881. }
  3882. }
  3883. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3884. int index = 0;
  3885. foreach (PropertyInfo property in properties)
  3886. {
  3887. string value = property.GetValue(airs[i]).ToString();
  3888. Cell ishcel0 = table.Rows[row].Cells[index];
  3889. Paragraph p = new Paragraph(doc);
  3890. string s = value;
  3891. p.AppendChild(new Run(doc, s));
  3892. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3893. ishcel0.AppendChild(p);
  3894. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3895. index++;
  3896. }
  3897. row++;
  3898. }
  3899. #endregion
  3900. Paragraph lastParagraph = new Paragraph(doc);
  3901. //第一个表格末尾加段落
  3902. table.ParentNode.InsertAfter(lastParagraph, table);
  3903. //复制第一个表格
  3904. Table cloneTable = (Table)table.Clone(true);
  3905. //在文档末尾段落后面加入复制的表格
  3906. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3907. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3908. {
  3909. int rownewsIndex = 13;
  3910. for (int i = 0; i < 2; i++)
  3911. {
  3912. var CopyRow = table.Rows[12].Clone(true);
  3913. table.Rows.RemoveAt(13);
  3914. table.Rows.Add(CopyRow);
  3915. rownewsIndex++;
  3916. }
  3917. }
  3918. else
  3919. {
  3920. table.Rows.RemoveAt(12);
  3921. }
  3922. cloneTable.Rows.RemoveAt(12);
  3923. }
  3924. if (_AirTicketReservations.Count != 0)
  3925. {
  3926. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3927. if (FlightsCode.Length != 0)
  3928. {
  3929. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3930. if (_AirCompany != null)
  3931. {
  3932. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3933. }
  3934. else
  3935. {
  3936. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3937. }
  3938. }
  3939. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3940. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3941. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3942. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3943. string name = "";
  3944. foreach (string clientName in nameArray)
  3945. {
  3946. if (!name.Contains(clientName))
  3947. {
  3948. name += clientName + ",";
  3949. }
  3950. }
  3951. if (!string.IsNullOrWhiteSpace(name))
  3952. {
  3953. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3954. }
  3955. else
  3956. {
  3957. table.Range.Bookmarks["ClientName"].Text = "--";
  3958. }
  3959. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3960. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3961. table.Range.Bookmarks["JointTicket"].Text = "--";
  3962. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3963. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3964. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3965. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3966. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3967. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3968. }
  3969. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3970. //保存合并后的文档
  3971. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3972. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3973. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3974. return Ok(JsonView(true, "成功!", rst));
  3975. }
  3976. else
  3977. {
  3978. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3979. DocumentBuilder builder = new DocumentBuilder(doc);
  3980. int tableIndex = 0;//表格索引
  3981. //得到文档中的第一个表格
  3982. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3983. List<string> texts = new List<string>();
  3984. foreach (var item in _AirTicketReservations)
  3985. {
  3986. string[] FlightsCode = item.FlightsCode.Split('/');
  3987. if (FlightsCode.Length != 0)
  3988. {
  3989. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3990. if (_AirCompany != null)
  3991. {
  3992. if (!transDic.ContainsKey(_AirCompany.CnName))
  3993. {
  3994. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3995. }
  3996. }
  3997. else
  3998. {
  3999. if (!transDic.ContainsKey("--"))
  4000. {
  4001. transDic.Add("--", "--");
  4002. }
  4003. }
  4004. }
  4005. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4006. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4007. string name = "";
  4008. foreach (string clientName in nameArray)
  4009. {
  4010. name += clientName + ",";
  4011. }
  4012. if (!texts.Contains(name))
  4013. {
  4014. texts.Add(name);
  4015. }
  4016. List<AirInfo> airs = new List<AirInfo>();
  4017. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4018. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4019. for (int i = 0; i < FlightsCode.Length; i++)
  4020. {
  4021. AirInfo air = new AirInfo();
  4022. string[] tempstr = DayArray[i]
  4023. .Replace("\r\n", string.Empty)
  4024. .Replace("\\r\\n", string.Empty)
  4025. .TrimStart().TrimEnd()
  4026. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4027. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4028. if (star_Three != null)
  4029. {
  4030. if (!transDic.ContainsKey(star_Three.AirPort))
  4031. {
  4032. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4033. }
  4034. }
  4035. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4036. if (End_Three != null)
  4037. {
  4038. if (!transDic.ContainsKey(End_Three.AirPort))
  4039. {
  4040. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4041. }
  4042. }
  4043. if (!texts.Contains(item.CTypeName))
  4044. {
  4045. texts.Add(item.CTypeName);
  4046. }
  4047. }
  4048. }
  4049. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4050. if (transData.Count > 0)
  4051. {
  4052. foreach (TranslateResult item in transData)
  4053. {
  4054. if (!transDic.ContainsKey(item.Query))
  4055. {
  4056. transDic.Add(item.Query, item.Translation);
  4057. }
  4058. }
  4059. }
  4060. foreach (var item in _AirTicketReservations)
  4061. {
  4062. #region 处理固定数据
  4063. string[] FlightsCode = item.FlightsCode.Split('/');
  4064. if (FlightsCode.Length != 0)
  4065. {
  4066. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4067. if (_AirCompany != null)
  4068. {
  4069. string str = "--";
  4070. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4071. if (!string.IsNullOrEmpty(translateResult))
  4072. {
  4073. str = translateResult;
  4074. str = _airTicketResRep.Processing(str);
  4075. }
  4076. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4077. }
  4078. else
  4079. {
  4080. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4081. }
  4082. }
  4083. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4084. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4085. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4086. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4087. string names = "";
  4088. foreach (string clientName in nameArray)
  4089. {
  4090. names += clientName + ",";
  4091. }
  4092. if (!string.IsNullOrWhiteSpace(names))
  4093. {
  4094. string str = "--";
  4095. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4096. if (!string.IsNullOrEmpty(translateResult))
  4097. {
  4098. str = translateResult;
  4099. str = _airTicketResRep.Processing(str);
  4100. }
  4101. table.Range.Bookmarks["ClientName"].Text = str;
  4102. }
  4103. else
  4104. {
  4105. table.Range.Bookmarks["ClientName"].Text = "--";
  4106. }
  4107. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4108. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4109. table.Range.Bookmarks["JointTicket"].Text = "--";
  4110. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4111. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4112. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4113. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4114. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4115. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4116. #endregion
  4117. #region 循环数据处理
  4118. List<AirInfo> airs = new List<AirInfo>();
  4119. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4120. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4121. for (int i = 0; i < FlightsCode.Length; i++)
  4122. {
  4123. AirInfo air = new AirInfo();
  4124. string[] tempstr = DayArray[i]
  4125. .Replace("\r\n", string.Empty)
  4126. .Replace("\\r\\n", string.Empty)
  4127. .TrimStart().TrimEnd()
  4128. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4129. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4130. string starCity = "";
  4131. if (star_Three != null)
  4132. {
  4133. string str2 = "--";
  4134. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4135. if (!string.IsNullOrEmpty(translateResult2))
  4136. {
  4137. str2 = translateResult2;
  4138. str2 = _airTicketResRep.Processing(str2);
  4139. }
  4140. starCity = str2;
  4141. }
  4142. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4143. string EndCity = "";
  4144. if (End_Three != null)
  4145. {
  4146. string str1 = "--";
  4147. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4148. if (!string.IsNullOrEmpty(translateResult1))
  4149. {
  4150. str1 = translateResult1;
  4151. str1 = _airTicketResRep.Processing(str1);
  4152. }
  4153. EndCity = str1;
  4154. }
  4155. air.Destination = starCity + "/" + EndCity;
  4156. air.Flight = FlightsCode[i];
  4157. string str = "--";
  4158. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4159. if (!string.IsNullOrEmpty(translateResult))
  4160. {
  4161. str = translateResult;
  4162. str = _airTicketResRep.Processing(str);
  4163. }
  4164. air.SeatingClass = str;
  4165. string dateTime = tempstr[2];
  4166. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4167. air.FlightDate = DateTemp;
  4168. air.DepartureTime = tempstr[5];
  4169. air.LandingTime = tempstr[6];
  4170. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4171. air.TicketStatus = "--";
  4172. air.Luggage = "--";
  4173. air.DepartureTerminal = "--";
  4174. air.LandingTerminal = "--";
  4175. airs.Add(air);
  4176. }
  4177. int row = 13;
  4178. for (int i = 0; i < airs.Count; i++)
  4179. {
  4180. if (airs.Count > 2)
  4181. {
  4182. for (int j = 0; j < airs.Count - 2; j++)
  4183. {
  4184. var CopyRow = table.Rows[12].Clone(true);
  4185. table.Rows.Add(CopyRow);
  4186. }
  4187. }
  4188. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4189. int index = 0;
  4190. foreach (PropertyInfo property in properties)
  4191. {
  4192. string value = property.GetValue(airs[i]).ToString();
  4193. Cell ishcel0 = table.Rows[row].Cells[index];
  4194. Paragraph p = new Paragraph(doc);
  4195. string s = value;
  4196. p.AppendChild(new Run(doc, s));
  4197. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4198. ishcel0.AppendChild(p);
  4199. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4200. //ishcel0.CellFormat.VerticalAlignment=
  4201. index++;
  4202. }
  4203. row++;
  4204. }
  4205. #endregion
  4206. Paragraph lastParagraph = new Paragraph(doc);
  4207. //第一个表格末尾加段落
  4208. table.ParentNode.InsertAfter(lastParagraph, table);
  4209. //复制第一个表格
  4210. Table cloneTable = (Table)table.Clone(true);
  4211. //在文档末尾段落后面加入复制的表格
  4212. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4213. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4214. {
  4215. int rownewsIndex = 13;
  4216. for (int i = 0; i < 2; i++)
  4217. {
  4218. var CopyRow = table.Rows[12].Clone(true);
  4219. table.Rows.RemoveAt(13);
  4220. table.Rows.Add(CopyRow);
  4221. rownewsIndex++;
  4222. }
  4223. }
  4224. else
  4225. {
  4226. table.Rows.RemoveAt(12);
  4227. }
  4228. cloneTable.Rows.RemoveAt(12);
  4229. }
  4230. if (_AirTicketReservations.Count != 0)
  4231. {
  4232. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4233. if (FlightsCode.Length != 0)
  4234. {
  4235. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4236. if (_AirCompany != null)
  4237. {
  4238. string str = "--";
  4239. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4240. if (!string.IsNullOrEmpty(translateResult))
  4241. {
  4242. str = translateResult;
  4243. str = _airTicketResRep.Processing(str);
  4244. }
  4245. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4246. }
  4247. else
  4248. {
  4249. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4250. }
  4251. }
  4252. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4253. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4254. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4255. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4256. string names = "";
  4257. foreach (string clientName in nameArray)
  4258. {
  4259. names += clientName + ",";
  4260. }
  4261. if (!string.IsNullOrWhiteSpace(names))
  4262. {
  4263. string str = "--";
  4264. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4265. if (!string.IsNullOrEmpty(translateResult))
  4266. {
  4267. str = translateResult;
  4268. str = _airTicketResRep.Processing(str);
  4269. }
  4270. table.Range.Bookmarks["ClientName"].Text = str;
  4271. }
  4272. else
  4273. {
  4274. table.Range.Bookmarks["ClientName"].Text = "--";
  4275. }
  4276. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4277. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4278. table.Range.Bookmarks["JointTicket"].Text = "--";
  4279. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4280. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4281. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4282. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4283. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4284. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4285. }
  4286. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4287. //保存合并后的文档
  4288. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4289. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4290. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4291. return Ok(JsonView(true, "成功!", rst));
  4292. }
  4293. }
  4294. }
  4295. catch (Exception ex)
  4296. {
  4297. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4298. throw;
  4299. }
  4300. }
  4301. #endregion
  4302. #region 团组增减款项 --> 其他款项
  4303. /// <summary>
  4304. /// 团组增减款项下拉框绑定
  4305. /// </summary>
  4306. /// <param name="dto"></param>
  4307. /// <returns></returns>
  4308. [HttpPost]
  4309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4310. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4311. {
  4312. #region 参数验证
  4313. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4314. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4315. #endregion
  4316. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4317. }
  4318. /// <summary>
  4319. /// 根据团组Id查询团组增减款项
  4320. /// </summary>
  4321. /// <param name="dto"></param>
  4322. /// <returns></returns>
  4323. [HttpPost]
  4324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4325. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4326. {
  4327. #region 参数验证
  4328. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4329. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4330. #endregion
  4331. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4332. }
  4333. /// <summary>
  4334. /// 团组增减款项操作(Status:1.新增,2.修改)
  4335. /// </summary>
  4336. /// <param name="dto"></param>
  4337. /// <returns></returns>
  4338. [HttpPost]
  4339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4340. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4341. {
  4342. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4343. if (groupData.Code != 200)
  4344. {
  4345. return Ok(JsonView(false, groupData.Msg));
  4346. }
  4347. #region 应用推送
  4348. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4349. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4350. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4351. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4352. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4353. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4354. //自动审核
  4355. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4356. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4357. //2024-10-21 新增LZ UID
  4358. var userIds = new List<int>() { 21 };
  4359. string title = $"系统通知";
  4360. string content = "";
  4361. var diId = dto.DiId;
  4362. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4363. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4364. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4365. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4366. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4367. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4368. #endregion
  4369. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4370. }
  4371. /// <summary>
  4372. /// 团组增减款项操作 删除
  4373. /// </summary>
  4374. /// <param name="dto"></param>
  4375. /// <returns></returns>
  4376. [HttpPost]
  4377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4378. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4379. {
  4380. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4381. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4382. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4383. if (res.Code == 0)
  4384. {
  4385. return Ok(JsonView(true, "删除成功!"));
  4386. }
  4387. return Ok(JsonView(false, "删除失败!"));
  4388. }
  4389. /// <summary>
  4390. /// 根据团组增减款项Id查询
  4391. /// </summary>
  4392. /// <param name="dto"></param>
  4393. /// <returns></returns>
  4394. [HttpPost]
  4395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4396. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4397. {
  4398. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4399. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4400. }
  4401. /// <summary>
  4402. /// 查询供应商名称
  4403. /// </summary>
  4404. /// <param name="dto"></param>
  4405. /// <returns></returns>
  4406. [HttpPost]
  4407. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4408. {
  4409. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4410. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4411. ?? new List<Grp_DecreasePayments>();
  4412. dbResult = dbResult.Distinct(new
  4413. ProductComparer()).ToList();
  4414. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4415. {
  4416. x.Id,
  4417. x.SupplierAddress,
  4418. x.SupplierArea,
  4419. x.SupplierContact,
  4420. x.SupplierContactNumber,
  4421. x.SupplierEmail,
  4422. x.SupplierName,
  4423. x.SupplierSocialAccount,
  4424. x.SupplierTypeId,
  4425. }).ToList());
  4426. return Ok(jw);
  4427. }
  4428. /// <summary>
  4429. /// 团组增减款项 OTA匹配
  4430. /// </summary>
  4431. /// <param name="file"></param>
  4432. /// <returns></returns>
  4433. [HttpPost]
  4434. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4435. {
  4436. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4437. string fileName = file.FileName;
  4438. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4439. {
  4440. return Ok(JsonView(false, "请上传Excel文件!"));
  4441. }
  4442. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4443. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4444. if (!Directory.Exists(path))
  4445. {
  4446. Directory.CreateDirectory(path);
  4447. }
  4448. var filePath = @$"{path}/{fileName}";
  4449. //保存文件
  4450. using (FileStream fs = System.IO.File.Create(filePath))
  4451. {
  4452. file.CopyTo(fs);
  4453. fs.Flush();
  4454. }
  4455. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4456. //读取ExcelFile
  4457. DataTable dt = ConvertExcelToDataTable(filePath);
  4458. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4459. dt.TableName = "TB";
  4460. //修改table列名
  4461. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4462. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4463. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4464. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4465. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4466. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4467. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4468. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4469. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4470. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4471. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4472. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4473. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4474. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4475. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4476. var otaOrderNos = new List<string>();
  4477. foreach (DataRow item in dt.Rows)
  4478. {
  4479. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4480. }
  4481. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4482. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4483. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4484. .Select((dp, di) => new
  4485. {
  4486. dp.PriceName,
  4487. dp.OTAOrderNo,
  4488. dp.FeeTotal,
  4489. di.TeamName,
  4490. })
  4491. .ToListAsync();
  4492. foreach (DataRow item in dt.Rows)
  4493. {
  4494. var otaOrderNo = item["OTAOrderNo"].ToString();
  4495. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4496. if (oaData == null) continue;
  4497. item["GroupName"] = oaData.TeamName;
  4498. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4499. }
  4500. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4501. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4502. List<DataTable> datas = new List<DataTable>();
  4503. datas.Add(dt);
  4504. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4505. return Ok(JsonView(true, "操作成功", new { url = url }));
  4506. }
  4507. #region
  4508. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4509. {
  4510. // 创建Workbook对象
  4511. Workbook workbook = new Workbook(excelFilePath);
  4512. // 获取第一个工作表
  4513. Worksheet worksheet = workbook.Worksheets[0];
  4514. // 将工作表转换为DataTable
  4515. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4516. return dataTable;
  4517. }
  4518. #endregion
  4519. #endregion
  4520. #region 文件上传、删除
  4521. /// <summary>
  4522. /// region 文件上传 可以带参数
  4523. /// </summary>
  4524. /// <param name="file"></param>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public async Task<IActionResult> UploadProject(IFormFile file)
  4529. {
  4530. //var TypeName = Request.Headers["TypeName"].ToString();
  4531. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4532. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4533. ////文件名称
  4534. //string projectFileName = file.FileName;
  4535. ////上传的文件的路径
  4536. //string filePath = $"{fileDir}/{projectFileName}";
  4537. //if (TypeName == "A")//A代表团组增减款项
  4538. //{
  4539. // filePath = fileDir + $@"\团组增减款项相关文件";
  4540. // if (!Directory.Exists(filePath))
  4541. // {
  4542. // Directory.CreateDirectory(filePath);
  4543. // }
  4544. // //上传的文件的路径
  4545. // filePath += $@"\{projectFileName}";
  4546. //}
  4547. //else if (TypeName == "B")//B代表商邀相关文件
  4548. //{
  4549. // //上传的文件的路径
  4550. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4551. // if (!Directory.Exists(filePath))
  4552. // {
  4553. // Directory.CreateDirectory(filePath);
  4554. // }
  4555. // //上传的文件的路径
  4556. // filePath = $@"\{projectFileName}";
  4557. //}
  4558. //try
  4559. //{
  4560. // using (FileStream fs = System.IO.File.Create(filePath))
  4561. // {
  4562. // file.CopyTo(fs);
  4563. // fs.Flush();
  4564. // }
  4565. //}
  4566. //catch (Exception ex)
  4567. //{
  4568. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4569. //}
  4570. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4571. try
  4572. {
  4573. var TypeName = Request.Headers["TypeName"].ToString();
  4574. if (file != null)
  4575. {
  4576. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4577. //文件名称
  4578. string projectFileName = file.FileName;
  4579. //上传的文件的路径
  4580. string filePath = $"{fileDir}/{projectFileName}";
  4581. if (TypeName == "A")//A代表团组增减款项
  4582. {
  4583. if (!Directory.Exists(fileDir))
  4584. {
  4585. Directory.CreateDirectory(fileDir);
  4586. }
  4587. //上传的文件的路径
  4588. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4589. }
  4590. else if (TypeName == "B")//B代表商邀相关文件
  4591. {
  4592. if (!Directory.Exists(fileDir))
  4593. {
  4594. Directory.CreateDirectory(fileDir);
  4595. }
  4596. //上传的文件的路径
  4597. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4598. }
  4599. using (FileStream fs = System.IO.File.Create(filePath))
  4600. {
  4601. file.CopyTo(fs);
  4602. fs.Flush();
  4603. }
  4604. return Ok(JsonView(true, "上传成功!", projectFileName));
  4605. }
  4606. else
  4607. {
  4608. return Ok(JsonView(false, "上传失败!"));
  4609. }
  4610. }
  4611. catch (Exception ex)
  4612. {
  4613. return Ok(JsonView(false, "程序错误!"));
  4614. }
  4615. }
  4616. /// <summary>
  4617. /// 删除指定文件
  4618. /// </summary>
  4619. /// <param name="dto"></param>
  4620. /// <returns></returns>
  4621. [HttpPost]
  4622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4623. public async Task<IActionResult> DelFile(DelFileDto dto)
  4624. {
  4625. try
  4626. {
  4627. var TypeName = Request.Headers["TypeName"].ToString();
  4628. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4629. string filePath = "";
  4630. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4631. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4632. int id = 0;
  4633. if (TypeName == "A")
  4634. {
  4635. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4636. // 删除该文件
  4637. System.IO.File.Delete(filePath);
  4638. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4639. .Where(a => a.Id == dto.Id)
  4640. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4641. .ExecuteCommandAsync();
  4642. }
  4643. else if (TypeName == "B")
  4644. {
  4645. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4646. // 删除该文件
  4647. System.IO.File.Delete(filePath);
  4648. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4649. if (info != null)
  4650. {
  4651. string[] files = new string[] { };
  4652. if (!string.IsNullOrEmpty(info.Attachment))
  4653. {
  4654. try
  4655. {
  4656. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4657. }
  4658. catch (Exception)
  4659. {
  4660. files = new List<string>() { info.Attachment }.ToArray();
  4661. }
  4662. }
  4663. if (files.Length > 0)
  4664. {
  4665. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4666. string filePath2 = string.Empty;
  4667. if (files1.Length > 0)
  4668. {
  4669. filePath2 = JsonConvert.SerializeObject(files1);
  4670. }
  4671. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4672. .Where(a => a.Id == dto.Id)
  4673. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4674. .ExecuteCommandAsync();
  4675. }
  4676. }
  4677. }
  4678. if (id != 0)
  4679. {
  4680. return Ok(JsonView(true, "成功!"));
  4681. }
  4682. else
  4683. {
  4684. return Ok(JsonView(false, "失败!"));
  4685. }
  4686. }
  4687. catch (Exception ex)
  4688. {
  4689. return Ok(JsonView(false, "程序错误!"));
  4690. throw;
  4691. }
  4692. }
  4693. /// <summary>
  4694. /// 文件上传多个文件 可以带参数
  4695. /// </summary>
  4696. /// <param name="files"></param>
  4697. /// <returns></returns>
  4698. [HttpPost]
  4699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4700. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4701. {
  4702. try
  4703. {
  4704. var TypeName = Request.Headers["TypeName"].ToString();
  4705. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4706. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4707. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4708. var filePahts = new List<string>();
  4709. foreach (var file in files)
  4710. {
  4711. //文件名称
  4712. string projectFileName = file.FileName;
  4713. //上传的文件的路径
  4714. string filePath = $"{fileDir}/{projectFileName}";
  4715. if (TypeName == "A")//A代表团组增减款项
  4716. {
  4717. if (!Directory.Exists(fileDir))
  4718. {
  4719. Directory.CreateDirectory(fileDir);
  4720. }
  4721. //上传的文件的路径
  4722. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4723. }
  4724. else if (TypeName == "B")//B代表商邀相关文件
  4725. {
  4726. if (!Directory.Exists(fileDir))
  4727. {
  4728. Directory.CreateDirectory(fileDir);
  4729. }
  4730. //上传的文件的路径
  4731. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4732. }
  4733. using (FileStream fs = System.IO.File.Create(filePath))
  4734. {
  4735. file.CopyTo(fs);
  4736. fs.Flush();
  4737. }
  4738. filePahts.Add(projectFileName);
  4739. }
  4740. return Ok(JsonView(true, "上传成功!", filePahts));
  4741. }
  4742. catch (Exception ex)
  4743. {
  4744. return Ok(JsonView(false, "程序错误!"));
  4745. }
  4746. }
  4747. #endregion
  4748. #region 商邀费用录入
  4749. /// <summary>
  4750. /// 根据团组Id查询商邀费用列表
  4751. /// </summary>
  4752. /// <param name="dto"></param>
  4753. /// <returns></returns>
  4754. [HttpPost]
  4755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4756. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4757. {
  4758. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4759. if (groupData.Code != 0)
  4760. {
  4761. return Ok(JsonView(false, groupData.Msg));
  4762. }
  4763. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4764. }
  4765. /// <summary>
  4766. /// 商邀费用列表
  4767. /// 下载文件
  4768. /// </summary>
  4769. /// <param name="id"></param>
  4770. /// <returns></returns>
  4771. [HttpGet("{id}")]
  4772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4773. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4774. {
  4775. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4776. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4777. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4778. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4779. var filePaths = new List<string>();
  4780. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4781. try
  4782. {
  4783. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4784. }
  4785. catch (Exception ex)
  4786. {
  4787. filePaths.Add(info.Attachment);
  4788. }
  4789. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4790. for (int i = 0; i < filePaths.Count; i++)
  4791. {
  4792. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4793. }
  4794. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4795. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4796. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4797. {
  4798. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4799. {
  4800. foreach (string filePath in filePaths)
  4801. {
  4802. if (System.IO.File.Exists(filePath))
  4803. {
  4804. // 获取文件名
  4805. string fileName = Path.GetFileName(filePath);
  4806. // 将文件添加到ZIP归档中
  4807. zipArchive.CreateEntryFromFile(filePath, fileName);
  4808. }
  4809. }
  4810. }
  4811. }
  4812. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4813. }
  4814. /// <summary>
  4815. /// 商邀费用 Info Page 基础数据源
  4816. /// </summary>
  4817. /// <returns></returns>
  4818. [HttpPost]
  4819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4820. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4821. {
  4822. try
  4823. {
  4824. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4825. if (groupData.Code != 0)
  4826. {
  4827. return Ok(JsonView(false, groupData.Msg));
  4828. }
  4829. return Ok(JsonView(true, "操作成功", groupData.Data));
  4830. }
  4831. catch (Exception ex)
  4832. {
  4833. return Ok(JsonView(false, ex.Message));
  4834. throw;
  4835. }
  4836. }
  4837. /// <summary>
  4838. /// 根据商邀费用ID查询C表和商邀费用数据
  4839. /// </summary>
  4840. /// <param name="dto"></param>
  4841. /// <returns></returns>
  4842. [HttpPost]
  4843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4844. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4845. {
  4846. try
  4847. {
  4848. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4849. if (groupData.Code != 0)
  4850. {
  4851. return Ok(JsonView(false, groupData.Msg));
  4852. }
  4853. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4854. }
  4855. catch (Exception ex)
  4856. {
  4857. return Ok(JsonView(false, ex.Message));
  4858. throw;
  4859. }
  4860. }
  4861. /// <summary>
  4862. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4863. /// </summary>
  4864. /// <param name="dto"></param>
  4865. /// <returns></returns>
  4866. [HttpPost]
  4867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4868. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4869. {
  4870. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4871. if (groupData.Code != 0)
  4872. {
  4873. return Ok(JsonView(false, groupData.Msg));
  4874. }
  4875. #region 应用推送
  4876. try
  4877. {
  4878. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4879. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4880. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4881. //2024-10-21 新增LZ UID
  4882. var userIds = new List<int>() { 21 };
  4883. string title = $"系统通知";
  4884. string content = "";
  4885. var diId = dto.DiId;
  4886. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4887. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4888. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4889. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4890. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4891. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4892. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4893. }
  4894. catch (Exception ex)
  4895. {
  4896. }
  4897. #endregion
  4898. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4899. }
  4900. /// <summary>
  4901. /// 商邀删除
  4902. /// </summary>
  4903. /// <param name="dto"></param>
  4904. /// <returns></returns>
  4905. [HttpPost]
  4906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4907. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4908. {
  4909. try
  4910. {
  4911. _sqlSugar.BeginTran();
  4912. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4913. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4914. {
  4915. IsDel = 1,
  4916. DeleteUserId = dto.DeleteUserId,
  4917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4918. })
  4919. .Where(it => it.Id == dto.Id)
  4920. .ExecuteCommand();
  4921. if (res1 > 0)
  4922. {
  4923. int _diId = 0;
  4924. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4925. if (_ioaInfo != null)
  4926. {
  4927. _diId = _ioaInfo.DiId;
  4928. }
  4929. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4930. .SetColumns(a => new Grp_CreditCardPayment()
  4931. {
  4932. IsDel = 1,
  4933. DeleteUserId = dto.DeleteUserId,
  4934. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4935. })
  4936. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4937. .ExecuteCommand();
  4938. if (res2 > 0)
  4939. {
  4940. _sqlSugar.CommitTran();
  4941. return Ok(JsonView(true, "删除成功!"));
  4942. }
  4943. }
  4944. _sqlSugar.RollbackTran();
  4945. return Ok(JsonView(false, "删除失败"));
  4946. }
  4947. catch (Exception ex)
  4948. {
  4949. _sqlSugar.RollbackTran();
  4950. return Ok(JsonView(false, ex.Message));
  4951. }
  4952. }
  4953. #endregion
  4954. #region 票据上传
  4955. /// <summary>
  4956. /// 团组模块文件上传
  4957. /// </summary>
  4958. /// <param name="dto"></param>
  4959. /// <returns></returns>
  4960. [HttpPost]
  4961. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4962. {
  4963. var jw = JsonView(false);
  4964. long M = 1024 * 1024;
  4965. if (dto.Files == null || dto.Files.Count == 0)
  4966. {
  4967. jw.Msg = "无文件信息!";
  4968. return Ok(jw);
  4969. }
  4970. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4971. {
  4972. jw.Msg = "文件大小超过20M!";
  4973. return Ok(jw);
  4974. }
  4975. //var nameSp = dto.File.FileName.Split(".");
  4976. //if (nameSp.Length < 2)
  4977. //{
  4978. // jw.Msg = "拓展名称有误!";
  4979. // return Ok(jw);
  4980. //}
  4981. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4982. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4983. //{
  4984. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4985. // return Ok(jw);
  4986. //}
  4987. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4988. if (Ctable == null)
  4989. {
  4990. jw.Msg = "Ctable指向有误!";
  4991. return Ok(jw);
  4992. }
  4993. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4994. if (groupInfo == null)
  4995. {
  4996. jw.Msg = "团组信息不存在!";
  4997. return Ok(jw);
  4998. }
  4999. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5000. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5001. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5002. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5003. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5004. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5005. try
  5006. {
  5007. if (!Directory.Exists(fileBase))
  5008. {
  5009. Directory.CreateDirectory(fileBase);
  5010. }
  5011. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5012. foreach (var fileStream in dto.Files)
  5013. {
  5014. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5015. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5016. {
  5017. Cid = dto.Cid,
  5018. CreateTime = DateTime.Now,
  5019. CreateUserId = dto.Userid,
  5020. Ctable = dto.Ctable,
  5021. Diid = dto.Diid,
  5022. IsDel = 0,
  5023. FilePath = saveFilePath,
  5024. FileName = fileStream.FileName
  5025. };
  5026. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5027. {
  5028. fileStream.CopyTo(fs);
  5029. fs.Flush();
  5030. }
  5031. saveArr.Add(file);
  5032. }
  5033. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5034. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5035. jw = JsonView(true, "保存成功!", new
  5036. {
  5037. count = addResult,
  5038. filesName = saveArr.Select(x => x.FileName)
  5039. });
  5040. }
  5041. catch (Exception ex)
  5042. {
  5043. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5044. {
  5045. count = 0,
  5046. filesName = new string[0],
  5047. });
  5048. }
  5049. return Ok(jw);
  5050. }
  5051. /// <summary>
  5052. /// 查询各模块已保存文件
  5053. /// </summary>
  5054. /// <param name="dto"></param>
  5055. /// <returns></returns>
  5056. [HttpPost]
  5057. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5058. {
  5059. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5060. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5061. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5062. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5063. {
  5064. expression = Expressionable.Create<Grp_GroupModelFile>()
  5065. .And(x => visaIds.Contains(x.CreateUserId));
  5066. }
  5067. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5068. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5069. .Where(expression.ToExpression())
  5070. .ToList();
  5071. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5072. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5073. {
  5074. x.FileName,
  5075. x.Id,
  5076. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5077. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5078. })));
  5079. }
  5080. /// <summary>
  5081. /// 下载该团组下的所有文件
  5082. /// </summary>
  5083. /// <param name="dto"></param>
  5084. /// <returns></returns>
  5085. [HttpPost]
  5086. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5087. {
  5088. var jw = JsonView(false);
  5089. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5090. if (groupInfo == null)
  5091. {
  5092. jw.Msg = "团组信息不存在!";
  5093. return Ok(jw);
  5094. }
  5095. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5096. var isModule = Convert.ToBoolean(dto.isModule);
  5097. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5098. IOOperatorHelper io = new IOOperatorHelper();
  5099. if (isModule)
  5100. {
  5101. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5102. foreach (var moduleArr in moduleGroup)
  5103. {
  5104. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5105. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5106. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5107. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5108. foreach (var item in moduleArr)
  5109. {
  5110. if (System.IO.File.Exists(item.FilePath))
  5111. {
  5112. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5113. {
  5114. byte[] bytes = new byte[fileStream.Length];
  5115. fileStream.Read(bytes, 0, bytes.Length);
  5116. fileStream.Close();
  5117. Stream stream = new MemoryStream(bytes);
  5118. chiZips.Add(item.FileName, stream);
  5119. }
  5120. }
  5121. }
  5122. if (chiZips.Count > 0)
  5123. {
  5124. var byts = io.ConvertZipStream(chiZips);
  5125. Stream stream = new MemoryStream(byts);
  5126. Zips.Add(key.Name + "_.zip", stream);
  5127. }
  5128. }
  5129. }
  5130. else
  5131. {
  5132. foreach (var item in dbQuery)
  5133. {
  5134. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5135. {
  5136. byte[] bytes = new byte[fileStream.Length];
  5137. fileStream.Read(bytes, 0, bytes.Length);
  5138. fileStream.Close();
  5139. Stream stream = new MemoryStream(bytes);
  5140. while (Zips.Keys.Contains(item.FileName))
  5141. {
  5142. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5143. }
  5144. Zips.Add(item.FileName, stream);
  5145. }
  5146. }
  5147. }
  5148. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5149. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5150. if (Zips.Count > 0)
  5151. {
  5152. var byts = io.ConvertZipStream(Zips);
  5153. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5154. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5155. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5156. }
  5157. else
  5158. {
  5159. jw.Msg = "暂无生成文件!";
  5160. }
  5161. return Ok(jw);
  5162. }
  5163. /// <summary>
  5164. /// 下载该团组下此模块的所有文件
  5165. /// </summary>
  5166. /// <param name="dto"></param>
  5167. /// <returns></returns>
  5168. [HttpPost]
  5169. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5170. {
  5171. var jw = JsonView(false);
  5172. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5173. if (groupInfo == null)
  5174. {
  5175. jw.Msg = "团组信息不存在!";
  5176. return Ok(jw);
  5177. }
  5178. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5179. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5180. && x.IsDel == 0);
  5181. if (key == null)
  5182. {
  5183. jw.Msg = "Ctable指向错误!";
  5184. return Ok(jw);
  5185. }
  5186. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5187. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5188. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5189. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5190. IOOperatorHelper io = new IOOperatorHelper();
  5191. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5192. foreach (var item in dbQuery)
  5193. {
  5194. if (System.IO.File.Exists(item.FilePath))
  5195. {
  5196. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5197. {
  5198. byte[] bytes = new byte[fileStream.Length];
  5199. fileStream.Read(bytes, 0, bytes.Length);
  5200. fileStream.Close();
  5201. Stream stream = new MemoryStream(bytes);
  5202. while (Zips.Keys.Contains(item.FileName))
  5203. {
  5204. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5205. }
  5206. Zips.Add(item.FileName, stream);
  5207. }
  5208. }
  5209. }
  5210. if (Zips.Count > 0)
  5211. {
  5212. var byts = io.ConvertZipStream(Zips);
  5213. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5214. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5215. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5216. }
  5217. else
  5218. {
  5219. jw.Msg = "暂无生成文件!";
  5220. }
  5221. return Ok(jw);
  5222. }
  5223. /// <summary>
  5224. /// 删除该团组下的指定文件
  5225. /// </summary>
  5226. /// <param name="dto"></param>
  5227. /// <returns></returns>
  5228. [HttpPost]
  5229. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5230. {
  5231. var jw = JsonView(false);
  5232. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5233. if (sing == null)
  5234. {
  5235. jw.Msg = "暂无";
  5236. return Ok(jw);
  5237. }
  5238. if (System.IO.File.Exists(sing.FilePath))
  5239. {
  5240. try
  5241. {
  5242. System.IO.File.Delete(sing.FilePath);
  5243. }
  5244. catch (Exception ex)
  5245. {
  5246. jw.Msg = "删除失败!" + ex.Message;
  5247. return Ok(jw);
  5248. }
  5249. }
  5250. sing.IsDel = 1;
  5251. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5252. sing.DeleteUserId = dto.UserId;
  5253. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5254. jw = JsonView(true, "删除成功!");
  5255. return Ok(jw);
  5256. }
  5257. #endregion
  5258. #region 共享文件上传
  5259. /// <summary>
  5260. /// 共享文件数据初始化
  5261. /// </summary>
  5262. /// <returns></returns>
  5263. [HttpGet]
  5264. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5265. {
  5266. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5267. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5268. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5269. .Select(x => x.Id)
  5270. .ToList()
  5271. .Contains(userid);
  5272. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5273. .Where(x => x.STid == 111 && x.IsDel == 0)
  5274. .Select(x => new
  5275. {
  5276. x.Name,
  5277. x.Id,
  5278. }).ToList();
  5279. if (isMarketingDepartment)
  5280. {
  5281. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5282. }
  5283. if (portType == 1)
  5284. {
  5285. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5286. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5287. .Where(x => x.IsDel == 0)
  5288. .OrderByDescending(x=> x.VisitDate )
  5289. .Select(x => new
  5290. {
  5291. x.TeamName,
  5292. x.Id,
  5293. x.CityId,
  5294. })
  5295. .ToList()
  5296. .Select(x=>
  5297. {
  5298. var provinceId = x.CityId;
  5299. var isDefualtVal = true;
  5300. if (provinceId > 0)
  5301. {
  5302. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5303. if (parentId != null)
  5304. {
  5305. isDefualtVal = false;
  5306. provinceId = (int)parentId;
  5307. }
  5308. }
  5309. if (isDefualtVal)
  5310. {
  5311. provinceId = 122; //默认四川
  5312. }
  5313. return new
  5314. {
  5315. x.TeamName,
  5316. x.Id,
  5317. provinceId,
  5318. };
  5319. })
  5320. .ToList();
  5321. return Ok(JsonView(true, "SUCCESS!", new
  5322. {
  5323. dropDownType,
  5324. dropDownGroupList,
  5325. isMarketingDepartment
  5326. }));
  5327. }
  5328. else if (portType == 2 || portType == 3)
  5329. {
  5330. return Ok(JsonView(true, "SUCCESS!", new
  5331. {
  5332. dropDownType,
  5333. isMarketingDepartment
  5334. }));
  5335. }
  5336. else
  5337. {
  5338. return Ok(JsonView(false, "portType有误!"));
  5339. }
  5340. }
  5341. /// <summary>
  5342. /// 共享文件上传
  5343. /// </summary>
  5344. /// <param name="dto"></param>
  5345. /// <returns></returns>
  5346. [HttpPost]
  5347. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5348. {
  5349. var isGroup = new List<int> { 1412 };
  5350. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5351. {
  5352. return Ok(JsonView(false, "该文件需要关联团组!"));
  5353. }
  5354. if (dto.Files == null || dto.Files.Count == 0)
  5355. {
  5356. return Ok(JsonView(false, "无文件信息!"));
  5357. }
  5358. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5359. {
  5360. return Ok(JsonView(false, "文件大小超过20M!"));
  5361. }
  5362. if (dto.Userid < 1)
  5363. {
  5364. return Ok(JsonView(false, "请传入有效的Userid!"));
  5365. }
  5366. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5367. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5368. .Select((u, j) => new
  5369. {
  5370. u.CnName,
  5371. UserId = u.Id,
  5372. j.JobName,
  5373. })
  5374. .First();
  5375. if (jobInfo == null)
  5376. {
  5377. return Ok(JsonView(false, "请传入有效的Userid!"));
  5378. }
  5379. List<string> commonFileExtensions = new List<string>
  5380. {
  5381. // 文本文件
  5382. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5383. // 图片文件
  5384. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5385. // 视频文件
  5386. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5387. // 音频文件
  5388. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5389. // 压缩文件
  5390. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5391. // 数据文件
  5392. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5393. };
  5394. try
  5395. {
  5396. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5397. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5398. commonFileExtensions.AddRange(settingExtend);
  5399. }
  5400. catch (Exception)
  5401. { }
  5402. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5403. if (setdata == null)
  5404. {
  5405. return Ok(JsonView(false, "请传入有效的FileType!"));
  5406. }
  5407. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5408. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5409. if (!Directory.Exists(winPath))
  5410. {
  5411. Directory.CreateDirectory(winPath);
  5412. }
  5413. foreach (var item in dto.Files)
  5414. {
  5415. var houzui = Path.GetExtension(item.FileName);
  5416. if (!commonFileExtensions.Contains(houzui))
  5417. {
  5418. return Ok(JsonView(false, "未知后缀名称!"));
  5419. }
  5420. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5421. var saveFilePath = winPath + fileName;
  5422. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5423. {
  5424. item.CopyTo(fs);
  5425. fs.Flush();
  5426. }
  5427. var fileDetail = new Grp_GroupShareFile()
  5428. {
  5429. CreateUserId = dto.Userid,
  5430. CreateTime = DateTime.Now,
  5431. UploadJob = jobInfo.JobName,
  5432. FileName = fileName,
  5433. FileType = dto.FileType,
  5434. Diid = dto.Diid,
  5435. FilePath = winPath + fileName,
  5436. };
  5437. insertList.Add(fileDetail);
  5438. }
  5439. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5440. return Ok(JsonView(true, "保存成功!"));
  5441. }
  5442. /// <summary>
  5443. /// 查询共享文件列表
  5444. /// </summary>
  5445. /// <param name="dto"></param>
  5446. /// <returns></returns>
  5447. [HttpPost]
  5448. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5449. {
  5450. var isGroup = new List<int> { 1412 };
  5451. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5452. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5453. .And(x => x.Diid == dto.Diid)
  5454. .And(x => x.FileType == dto.FileType)
  5455. .And(x => x.IsDel == 0)
  5456. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5457. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5458. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5459. int totalCount = 0;
  5460. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5461. .Where(queryExpression.ToExpression())
  5462. .OrderBy(x => x.UploadJob)
  5463. .Select(x => new
  5464. {
  5465. x.Id,
  5466. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5467. x.FileName,
  5468. x.FileType,
  5469. x.CreateTime,
  5470. })
  5471. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5472. return Ok(JsonView(true, "SUCCESS!", new
  5473. {
  5474. FileList = dbQuery,
  5475. dto.PageSize,
  5476. dto.PageIndex,
  5477. totalCount
  5478. }));
  5479. }
  5480. /// <summary>
  5481. /// 删除共享文件模块下的指定文件
  5482. /// </summary>
  5483. /// <param name="dto"></param>
  5484. /// <returns></returns>
  5485. [HttpPost]
  5486. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5487. {
  5488. var jw = JsonView(false);
  5489. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5490. if (sing == null)
  5491. {
  5492. jw.Msg = "暂无文件信息!";
  5493. return Ok(jw);
  5494. }
  5495. if (sing.CreateUserId != dto.UserId)
  5496. {
  5497. jw.Msg = "只能删除自己上传的文件!";
  5498. return Ok(jw);
  5499. }
  5500. if (System.IO.File.Exists(sing.FilePath))
  5501. {
  5502. try
  5503. {
  5504. System.IO.File.Delete(sing.FilePath);
  5505. }
  5506. catch (Exception ex)
  5507. {
  5508. jw.Msg = "删除失败!" + ex.Message;
  5509. return Ok(jw);
  5510. }
  5511. }
  5512. sing.IsDel = 1;
  5513. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5514. sing.DeleteUserId = dto.UserId;
  5515. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5516. jw = JsonView(true, "删除成功!");
  5517. return Ok(jw);
  5518. }
  5519. #endregion
  5520. #region 团组英文资料
  5521. /// <summary>
  5522. /// 查询团组英文所有资料
  5523. /// </summary>
  5524. /// <param name="dto"></param>
  5525. /// <returns></returns>
  5526. [HttpPost]
  5527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5528. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5529. {
  5530. try
  5531. {
  5532. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5533. if (groupData.Code != 0)
  5534. {
  5535. return Ok(JsonView(false, groupData.Msg));
  5536. }
  5537. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5538. }
  5539. catch (Exception ex)
  5540. {
  5541. return Ok(JsonView(false, "程序错误!"));
  5542. throw;
  5543. }
  5544. }
  5545. /// <summary>
  5546. /// 团组英文资料操作(Status:1.新增,2.修改)
  5547. /// </summary>
  5548. /// <param name="dto"></param>
  5549. /// <returns></returns>
  5550. [HttpPost]
  5551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5552. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5553. {
  5554. try
  5555. {
  5556. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5557. if (groupData.Code != 0)
  5558. {
  5559. return Ok(JsonView(false, groupData.Msg));
  5560. }
  5561. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5562. }
  5563. catch (Exception ex)
  5564. {
  5565. return Ok(JsonView(false, "程序错误!"));
  5566. throw;
  5567. }
  5568. }
  5569. /// <summary>
  5570. /// 团组英文资料Id查询数据
  5571. /// </summary>
  5572. /// <param name="dto"></param>
  5573. /// <returns></returns>
  5574. [HttpPost]
  5575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5576. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5577. {
  5578. try
  5579. {
  5580. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5581. if (_DelegationEnData != null)
  5582. {
  5583. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5584. }
  5585. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5586. }
  5587. catch (Exception ex)
  5588. {
  5589. return Ok(JsonView(false, "程序错误!"));
  5590. throw;
  5591. }
  5592. }
  5593. /// <summary>
  5594. /// 团组英文资料删除
  5595. /// </summary>
  5596. /// <param name="dto"></param>
  5597. /// <returns></returns>
  5598. [HttpPost]
  5599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5600. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5601. {
  5602. try
  5603. {
  5604. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5605. if (!res)
  5606. {
  5607. return Ok(JsonView(false, "删除失败"));
  5608. }
  5609. return Ok(JsonView(true, "删除成功!"));
  5610. }
  5611. catch (Exception ex)
  5612. {
  5613. return Ok(JsonView(false, "程序错误!"));
  5614. throw;
  5615. }
  5616. }
  5617. #endregion
  5618. #region 导出邀请函
  5619. /// <summary>
  5620. /// 导出邀请函页面初始化
  5621. /// </summary>
  5622. /// <param name="dto"></param>
  5623. /// <returns></returns>
  5624. [HttpPost]
  5625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5626. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5627. {
  5628. try
  5629. {
  5630. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5631. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5632. if (dto.DiId == 0)
  5633. {
  5634. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5635. }
  5636. else
  5637. {
  5638. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5639. }
  5640. return Ok(JsonView(true, "查询成功!", new
  5641. {
  5642. deleClient = crm_Deles,
  5643. delegations = grp_Delegations
  5644. }));
  5645. }
  5646. catch (Exception ex)
  5647. {
  5648. return Ok(JsonView(false, "程序错误!"));
  5649. throw;
  5650. }
  5651. }
  5652. /// <summary>
  5653. /// 导出邀请函
  5654. /// </summary>
  5655. /// <param name="dto"></param>
  5656. /// <returns></returns>
  5657. [HttpPost]
  5658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5659. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5660. {
  5661. #region 参数验证
  5662. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5663. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5664. #endregion
  5665. try
  5666. {
  5667. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5668. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5669. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5670. From Grp_TourClientList tcl
  5671. Left Join
  5672. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5673. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5674. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5675. From Crm_DeleClient dc
  5676. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5677. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5678. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5679. Where dc.IsDel = 0) temp
  5680. On temp.DcId =tcl.ClientId
  5681. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5682. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5683. List<string> texts = new List<string>();
  5684. if (datas.Count != 0)
  5685. {
  5686. foreach (TourClientListDetailsView item in datas)
  5687. {
  5688. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5689. {
  5690. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5691. }
  5692. else
  5693. {
  5694. string name = item.LastName + item.FirstName;
  5695. texts.Add(name);
  5696. }
  5697. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5698. {
  5699. if (!transDic.ContainsKey(item.Job))
  5700. {
  5701. texts.Add(item.Job);
  5702. }
  5703. }
  5704. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5705. {
  5706. texts.Add(item.CompanyFullName);
  5707. }
  5708. }
  5709. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5710. if (transData.Count > 0)
  5711. {
  5712. foreach (TranslateResult item in transData)
  5713. {
  5714. if (!transDic.ContainsKey(item.Query))
  5715. {
  5716. transDic.Add(item.Query, item.Translation);
  5717. }
  5718. }
  5719. }
  5720. List<GuestList> list = new List<GuestList>();
  5721. foreach (TourClientListDetailsView dele in datas)
  5722. {
  5723. GuestList guestList = new GuestList();
  5724. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5725. {
  5726. guestList.Name = dele.Pinyin;
  5727. }
  5728. else
  5729. {
  5730. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5731. guestList.Name = Name;
  5732. }
  5733. if (dele.Sex == 0)
  5734. {
  5735. guestList.Sex = "Male";
  5736. }
  5737. else if (dele.Sex == 1)
  5738. {
  5739. guestList.Sex = "Female";
  5740. }
  5741. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5742. if (!string.IsNullOrEmpty(dele.Job))
  5743. {
  5744. guestList.Job = dele.Job;
  5745. }
  5746. list.Add(guestList);
  5747. }
  5748. //载入模板
  5749. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5750. DocumentBuilder builder = new DocumentBuilder(doc);
  5751. //获取word里所有表格
  5752. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5753. //获取所填表格的序数
  5754. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5755. var rowStart = tableOne.Rows[0]; //获取第1行
  5756. //循环赋值
  5757. for (int i = 0; i < list.Count; i++)
  5758. {
  5759. builder.MoveToCell(0, i + 1, 0, 0);
  5760. builder.Write(list[i].Name.ToString());
  5761. builder.MoveToCell(0, i + 1, 1, 0);
  5762. builder.Write(list[i].Sex.ToString());
  5763. builder.MoveToCell(0, i + 1, 2, 0);
  5764. builder.Write(list[i].DOB.ToString());
  5765. builder.MoveToCell(0, i + 1, 3, 0);
  5766. builder.Write(list[i].Job.ToString());
  5767. }
  5768. //删除多余行
  5769. while (tableOne.Rows.Count > list.Count + 1)
  5770. {
  5771. tableOne.Rows.RemoveAt(list.Count + 1);
  5772. }
  5773. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5774. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5775. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5776. doc.Save(filePath);
  5777. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5778. return Ok(JsonView(true, "操作成功!", Url));
  5779. }
  5780. else
  5781. {
  5782. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5783. }
  5784. }
  5785. catch (Exception ex)
  5786. {
  5787. return Ok(JsonView(false, ex.Message));
  5788. throw;
  5789. }
  5790. }
  5791. #endregion
  5792. #region 团组经理模块 出入境费用
  5793. /// <summary>
  5794. /// 团组模块 - 出入境费用 - 省份基础数据源
  5795. /// </summary>
  5796. /// <returns></returns>
  5797. [HttpGet]
  5798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5799. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5800. {
  5801. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5802. }
  5803. /// <summary>
  5804. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5805. /// </summary>
  5806. /// <returns></returns>
  5807. [HttpPost]
  5808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5809. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5810. {
  5811. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5812. var groupNamFirst = groupNameData.FirstOrDefault();
  5813. //SetDataInfoView
  5814. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5815. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5816. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5817. //验证城市归属并给默认值
  5818. int provinceId = 122;
  5819. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5820. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5821. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5822. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5823. return Ok(JsonView(true, "查询成功!", new
  5824. {
  5825. GroupNameData = groupNameData,
  5826. CurrencyData = _CurrencyData,
  5827. WordTypeData = wordTypeData,
  5828. ExcelTypeData = excelTypeData,
  5829. CurrencyInit = _currencyInfos,
  5830. ViewPermissionData = viewPermissionData
  5831. }));
  5832. }
  5833. /// <summary>
  5834. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5835. /// </summary>
  5836. /// <returns></returns>
  5837. [HttpGet("{provinceId}")]
  5838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5839. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5840. {
  5841. //验证城市归属并给默认值
  5842. if (provinceId < 1) provinceId = 122;
  5843. /*
  5844. * 122 四川
  5845. * 108 贵州
  5846. * 103 重庆
  5847. * 132 云南
  5848. */
  5849. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5850. return Ok(JsonView(true, "查询成功!", new
  5851. {
  5852. WordTypeData = wordTypeData,
  5853. ExcelTypeData = excelTypeData,
  5854. }));
  5855. }
  5856. /// <summary>
  5857. /// 团组模块 - 出入境费用
  5858. /// 实时汇率 tips
  5859. /// 签证费用 tips
  5860. /// 机票费用 tips
  5861. /// </summary>
  5862. /// <returns></returns>
  5863. [HttpPost]
  5864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5865. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5866. {
  5867. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5868. //默认币种显示
  5869. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5870. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5871. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5872. return Ok(JsonView(true, "查询成功!", new
  5873. {
  5874. //GroupNameData = groupNameData.Data,
  5875. visaData = visaData.Data,
  5876. airData = airData.Data,
  5877. reteInfos = reteInfos
  5878. }));
  5879. }
  5880. /// <summary>
  5881. /// 团组模块 - 出入境费用 - Info
  5882. /// </summary>
  5883. /// <returns></returns>
  5884. [HttpPost]
  5885. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5887. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5888. {
  5889. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5890. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5891. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5892. }
  5893. /// <summary>
  5894. /// 团组模块 - 出入境费用 - 设置view权限
  5895. /// </summary>
  5896. /// <returns></returns>
  5897. [HttpPost]
  5898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5899. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5900. {
  5901. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5902. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5903. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5904. var permissions = new List<Grp_EnterExitCostPermission>();
  5905. foreach (var userId in dto.UserIds)
  5906. {
  5907. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5908. }
  5909. if (permissions.Any())
  5910. {
  5911. _sqlSugar.BeginTran();
  5912. try
  5913. {
  5914. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5915. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5916. if (result < 1)
  5917. {
  5918. _sqlSugar.RollbackTran();
  5919. return Ok(JsonView(false));
  5920. }
  5921. }
  5922. catch (Exception ex)
  5923. {
  5924. _sqlSugar.RollbackTran();
  5925. return Ok(JsonView(false, ex.Message));
  5926. }
  5927. _sqlSugar.CommitTran();
  5928. return Ok(JsonView(true));
  5929. }
  5930. return Ok(JsonView(false));
  5931. }
  5932. /// <summary>
  5933. /// 团组模块 - 出入境费用 - Add And Update
  5934. /// </summary>
  5935. /// <returns></returns>
  5936. [HttpPost]
  5937. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5939. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5940. {
  5941. try
  5942. {
  5943. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5944. if (dto.DayOtherPriceData.Any())
  5945. {
  5946. var inserList = dto.DayOtherPriceData
  5947. .Where(x => x.Id == 0)
  5948. .Select(x => new Grp_DayOtherPrice
  5949. {
  5950. Cost = x.Cost,
  5951. Id = x.Id,
  5952. CreateTime = DateTime.Now,
  5953. CreateUserId = dto.UserId,
  5954. Currency = x.Currency,
  5955. Diid = x.DiId,
  5956. Index = x.Index,
  5957. IsDel = 0,
  5958. SetDataId = x.SetDataId,
  5959. SubTotal = x.SubTotal,
  5960. Remark = x.Remark
  5961. })
  5962. .ToList();
  5963. var updateList = dto.DayOtherPriceData
  5964. .Where(x => x.Id != 0)
  5965. .Select(x => new Grp_DayOtherPrice
  5966. {
  5967. Cost = x.Cost,
  5968. Id = x.Id,
  5969. CreateTime = DateTime.Now,
  5970. CreateUserId = dto.UserId,
  5971. Currency = x.Currency,
  5972. Diid = x.DiId,
  5973. Index = x.Index,
  5974. IsDel = 0,
  5975. SetDataId = x.SetDataId,
  5976. SubTotal = x.SubTotal,
  5977. Remark = x.Remark
  5978. })
  5979. .ToList();
  5980. //添加
  5981. _sqlSugar.BeginTran();
  5982. if (inserList.Any())
  5983. {
  5984. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5985. }
  5986. if (updateList.Any())
  5987. {
  5988. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5989. }
  5990. _sqlSugar.CommitTran();
  5991. }
  5992. if (data.Code != 0)
  5993. {
  5994. return Ok(JsonView(false, data.Msg));
  5995. }
  5996. //生成默认文件pdf并且通知人员
  5997. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5998. {
  5999. DiId = dto.DiId,
  6000. ExportType = 1,
  6001. SubTypeId = 1005
  6002. }, "pdf");
  6003. //发送通知
  6004. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6005. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6006. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6007. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6008. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6009. //汇率信息记录
  6010. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6011. return Ok(JsonView(true, data.Msg, data.Data));
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. return Ok(JsonView(false, ex.Message));
  6016. }
  6017. }
  6018. /// <summary>
  6019. /// 团组模块 - 出入境费用 - Confirm 费用
  6020. /// </summary>
  6021. /// <returns></returns>
  6022. [HttpPost]
  6023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6024. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6025. {
  6026. //TODO:测试完毕需把对应的用户ID更改
  6027. //1、数据表添加字段
  6028. //2、更改字段接口()
  6029. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6030. //3、确认成功 给财务发送消息
  6031. if (_view.Code == 200)
  6032. {
  6033. if (dto.Type == 1)
  6034. {
  6035. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6036. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6037. }
  6038. }
  6039. return Ok(_view);
  6040. }
  6041. /// <summary>
  6042. /// 团组模块 - 出入境费用 - File download
  6043. /// </summary>
  6044. /// <param name="dto"></param>
  6045. /// <returns></returns>
  6046. [HttpPost]
  6047. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6049. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6050. {
  6051. try
  6052. {
  6053. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6054. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6055. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6056. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6057. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6058. 3 团组成员名单 1 团组成员名单", ""));
  6059. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6060. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6061. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6062. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6063. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6064. //数据源
  6065. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6066. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6067. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6068. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6069. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6070. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6071. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6072. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6073. .Select((x, a, b) => new
  6074. {
  6075. x.Index,
  6076. itemName = a.Name,
  6077. CurrencyStr = b.Name,
  6078. x.Cost,
  6079. x.SubTotal,
  6080. x.Remark
  6081. })
  6082. .OrderBy((x) => x.Index)
  6083. .ToList(); //其他款项费用
  6084. var peiceItemCurrencys = new List<string>();
  6085. if (_DayAndCosts.Any())
  6086. {
  6087. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6088. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6089. }
  6090. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6091. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6092. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6093. {
  6094. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6095. }
  6096. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6097. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6098. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6099. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6100. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6101. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6102. .Select((tcl, dc, cc) => new ClientInfo
  6103. {
  6104. LastName = dc.LastName,
  6105. FirstName = dc.FirstName,
  6106. Sex = dc.Sex,
  6107. Birthday = dc.BirthDay,
  6108. Company = cc.CompanyFullName,
  6109. Job = dc.Job
  6110. })
  6111. .ToList();
  6112. foreach (var item in DeleClientList)
  6113. {
  6114. EncryptionProcessor.DecryptProperties(item);
  6115. }
  6116. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6117. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6118. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6119. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6120. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6121. if (dto.ExportType == 1) //明细表
  6122. {
  6123. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6124. {
  6125. //获取模板
  6126. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6127. //载入模板
  6128. Document doc = new Document(tempPath);
  6129. DocumentBuilder builder = new DocumentBuilder(doc);
  6130. //利用键值对存放数据
  6131. Dictionary<string, string> dic = new Dictionary<string, string>();
  6132. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6133. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6134. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6135. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6136. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6137. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6138. //境内费用(其他费用)
  6139. if (_EnterExitCosts.ChoiceOne == 1)
  6140. {
  6141. string row1_1 = "";
  6142. if (_EnterExitCosts.Visa > 0)
  6143. {
  6144. //insidePayTotal += _EnterExitCosts.Visa;
  6145. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6146. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6147. //{
  6148. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6149. //}
  6150. }
  6151. string row1_2 = "";
  6152. if (_EnterExitCosts.YiMiao > 0)
  6153. {
  6154. //insidePayTotal += _EnterExitCosts.YiMiao;
  6155. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6156. }
  6157. if (_EnterExitCosts.HeSuan > 0)
  6158. {
  6159. //insidePayTotal += _EnterExitCosts.HeSuan;
  6160. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6161. }
  6162. if (_EnterExitCosts.Service > 0)
  6163. {
  6164. //insidePayTotal += _EnterExitCosts.Service;
  6165. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6166. }
  6167. string row1_3 = "";
  6168. if (_EnterExitCosts.Safe > 0)
  6169. {
  6170. //insidePayTotal += _EnterExitCosts.Safe;
  6171. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6172. }
  6173. if (_EnterExitCosts.Ticket > 0)
  6174. {
  6175. //insidePayTotal += _EnterExitCosts.Ticket;
  6176. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6177. }
  6178. string row1 = "";
  6179. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6180. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6181. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6182. row1 += $"备注:{_EnterExitCosts.Remark}";
  6183. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6184. dic.Add("Row1Str", row1);
  6185. }
  6186. string airTotalStr = string.Empty,
  6187. airPriceStr = string.Empty;
  6188. //经济舱
  6189. if (_EnterExitCosts.SumJJC == 1)
  6190. {
  6191. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6192. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6193. }
  6194. //公务舱
  6195. if (_EnterExitCosts.SumGWC == 1)
  6196. {
  6197. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6198. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6199. }
  6200. //头等舱
  6201. if (_EnterExitCosts.SumTDC == 1)
  6202. {
  6203. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6204. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6205. }
  6206. //汇率描述
  6207. string rateStr = "";
  6208. if (peiceItemCurrencyInfos.Any())
  6209. {
  6210. rateStr = "\r\n汇率描述:";
  6211. foreach (var item in peiceItemCurrencyInfos)
  6212. {
  6213. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6214. }
  6215. }
  6216. string twoItemRemark = "备注:";
  6217. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6218. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6219. dic.Add("AirTotalStr", airTotalStr);
  6220. dic.Add("AirPriceStr", airPriceStr);
  6221. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6222. dic.Add("TwoItemRemark", twoItemRemark);
  6223. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6224. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6225. int table1Row = 0,
  6226. table2Row = 0,
  6227. table3Row = 0,
  6228. table4Row = 0,
  6229. table5Row = 0;
  6230. //住宿费
  6231. if (_EnterExitCosts.ChoiceThree == 1)
  6232. {
  6233. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6234. table1Row = dac1.Count;
  6235. #region 填充word表格内容
  6236. for (int i = 0; i < dac1.Count; i++)
  6237. {
  6238. Grp_DayAndCost dac = dac1[i];
  6239. if (dac == null) continue;
  6240. builder.MoveToCell(0, i, 0, 0);
  6241. builder.Write("第" + dac.Days.ToString() + "晚:");
  6242. builder.MoveToCell(0, i, 1, 0);
  6243. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6244. //builder.Write(dac.Place == null ? "" : dac.Place);
  6245. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6246. builder.MoveToCell(0, i, 2, 0);
  6247. builder.Write("费用标准:");
  6248. string curr = "";
  6249. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6250. if (currData != null)
  6251. {
  6252. curr = currData.Name;
  6253. }
  6254. builder.MoveToCell(0, i, 3, 0);
  6255. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6256. builder.MoveToCell(0, i, 4, 0);
  6257. builder.Write("费用小计:");
  6258. builder.MoveToCell(0, i, 5, 0);
  6259. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6260. }
  6261. #endregion
  6262. }
  6263. else dic.Add("SubZS", "0.00");
  6264. //删除多余行
  6265. while (table1.Rows.Count > table1Row)
  6266. {
  6267. table1.Rows.RemoveAt(table1Row);
  6268. }
  6269. //伙食费
  6270. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6271. if (_EnterExitCosts.ChoiceFour == 1)
  6272. {
  6273. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6274. table2Row = dac2.Count;
  6275. #region 填充word表格内容
  6276. for (int i = 0; i < dac2.Count; i++)
  6277. {
  6278. Grp_DayAndCost dac = dac2[i];
  6279. if (dac == null) continue;
  6280. builder.MoveToCell(1, i, 0, 0);
  6281. builder.Write("第" + dac.Days.ToString() + "天:");
  6282. builder.MoveToCell(1, i, 1, 0);
  6283. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6284. builder.MoveToCell(1, i, 2, 0);
  6285. builder.Write("费用标准:");
  6286. string curr = "";
  6287. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6288. if (currData != null)
  6289. {
  6290. curr = currData.Name;
  6291. }
  6292. builder.MoveToCell(1, i, 3, 0);
  6293. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6294. builder.MoveToCell(1, i, 4, 0);
  6295. builder.Write("费用小计:");
  6296. builder.MoveToCell(1, i, 5, 0);
  6297. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6298. }
  6299. #endregion
  6300. }
  6301. else dic.Add("SubHS", "0.00");
  6302. //删除多余行
  6303. while (table2.Rows.Count > table2Row)
  6304. {
  6305. table2.Rows.RemoveAt(table2Row);
  6306. }
  6307. //公杂费
  6308. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6309. if (_EnterExitCosts.ChoiceFive == 1)
  6310. {
  6311. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6312. table3Row = dac3.Count;
  6313. #region 填充word表格内容
  6314. for (int i = 0; i < dac3.Count; i++)
  6315. {
  6316. Grp_DayAndCost dac = dac3[i];
  6317. if (dac == null) continue;
  6318. builder.MoveToCell(2, i, 0, 0);
  6319. builder.Write("第" + dac.Days.ToString() + "天:");
  6320. builder.MoveToCell(2, i, 1, 0);
  6321. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6322. builder.MoveToCell(2, i, 2, 0);
  6323. builder.Write("费用标准:");
  6324. string curr = "";
  6325. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6326. if (currData != null)
  6327. {
  6328. curr = currData.Name;
  6329. }
  6330. builder.MoveToCell(2, i, 3, 0);
  6331. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6332. builder.MoveToCell(2, i, 4, 0);
  6333. builder.Write("费用小计:");
  6334. builder.MoveToCell(2, i, 5, 0);
  6335. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6336. }
  6337. //删除多余行
  6338. while (table3.Rows.Count > table3Row)
  6339. {
  6340. table3.Rows.RemoveAt(table3Row);
  6341. }
  6342. #endregion
  6343. }
  6344. else dic.Add("SubGZF", "0.00");
  6345. //删除多余行
  6346. while (table3.Rows.Count > table3Row)
  6347. {
  6348. table3.Rows.RemoveAt(table3Row);
  6349. }
  6350. //培训费
  6351. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6352. if (_EnterExitCosts.ChoiceSix == 1)
  6353. {
  6354. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6355. dic.Add("SubPX", pxStr);
  6356. table4Row = dac4.Count;
  6357. #region 填充word表格内容
  6358. for (int i = 0; i < dac4.Count; i++)
  6359. {
  6360. Grp_DayAndCost dac = dac4[i];
  6361. if (dac == null) continue;
  6362. builder.MoveToCell(3, i, 0, 0);
  6363. builder.Write("第" + dac.Days.ToString() + "天:");
  6364. builder.MoveToCell(3, i, 1, 0);
  6365. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6366. builder.MoveToCell(3, i, 2, 0);
  6367. builder.Write("费用标准:");
  6368. string curr = "";
  6369. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6370. if (currData != null)
  6371. {
  6372. curr = currData.Name;
  6373. }
  6374. builder.MoveToCell(3, i, 3, 0);
  6375. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6376. builder.MoveToCell(3, i, 4, 0);
  6377. builder.Write("费用小计:");
  6378. builder.MoveToCell(3, i, 5, 0);
  6379. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6380. }
  6381. #endregion
  6382. }
  6383. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6384. //删除多余行
  6385. while (table4.Rows.Count > table4Row)
  6386. {
  6387. table4.Rows.RemoveAt(table4Row);
  6388. }
  6389. //其他费用
  6390. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6391. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6392. {
  6393. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6394. dic.Add("titleQi", qtStr);
  6395. table5Row = dac5.Count;
  6396. #region 填充word表格内容
  6397. for (int i = 0; i < dac5.Count; i++)
  6398. {
  6399. var dac = dac5[i];
  6400. if (dac == null) continue;
  6401. builder.MoveToCell(4, i, 0, 0);
  6402. builder.Write("第" + dac.Index.ToString() + "项:");
  6403. builder.MoveToCell(4, i, 1, 0);
  6404. builder.Write(dac.itemName);
  6405. builder.MoveToCell(4, i, 2, 0);
  6406. builder.Write("费用标准:");
  6407. builder.MoveToCell(4, i, 3, 0);
  6408. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6409. builder.MoveToCell(4, i, 4, 0);
  6410. builder.Write("费用小计:");
  6411. builder.MoveToCell(4, i, 5, 0);
  6412. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6413. builder.MoveToCell(4, i, 6, 0);
  6414. builder.Write("备注:");
  6415. builder.MoveToCell(4, i, 7, 0);
  6416. builder.Write(dac.Remark);
  6417. }
  6418. #endregion
  6419. }
  6420. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6421. //删除多余行
  6422. while (table5.Rows.Count > table5Row)
  6423. {
  6424. table5.Rows.RemoveAt(table5Row);
  6425. }
  6426. //加上其他费用
  6427. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6428. decimal subJJC = 0.00M,
  6429. subGWC = 0.00M,
  6430. subTDC = 0.00M;
  6431. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6432. string totalLabel = string.Format("全部费用总计:");
  6433. //经济舱
  6434. if (_EnterExitCosts.SumJJC == 1)
  6435. {
  6436. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6437. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6438. }
  6439. //公务舱
  6440. if (_EnterExitCosts.SumGWC == 1)
  6441. {
  6442. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6443. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6444. }
  6445. //头等舱
  6446. if (_EnterExitCosts.SumTDC == 1)
  6447. {
  6448. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6449. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6450. }
  6451. //TotalLabel
  6452. dic.Add("TotalLabel", totalLabel);
  6453. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6454. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6455. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6456. #region 填充word模板书签内容
  6457. foreach (var key in dic.Keys)
  6458. {
  6459. Bookmark bookmark = doc.Range.Bookmarks[key];
  6460. if (bookmark != null)
  6461. {
  6462. builder.MoveToBookmark(key);
  6463. builder.Write(dic[key]);
  6464. }
  6465. }
  6466. #endregion
  6467. #region 设置页眉
  6468. string userLabel = string.Empty;
  6469. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6470. if (currUserInfo != null)
  6471. {
  6472. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6473. if (userInfo != null)
  6474. {
  6475. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6476. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6477. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6478. }
  6479. }
  6480. //设置页脚
  6481. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6482. #endregion
  6483. //文件名
  6484. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6485. AsposeHelper.removewatermark_v2180();
  6486. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6487. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6488. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6489. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6490. }
  6491. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6492. {
  6493. //获取模板
  6494. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6495. //载入模板
  6496. Document doc = new Document(tempPath);
  6497. DocumentBuilder builder = new DocumentBuilder(doc);
  6498. Dictionary<string, string> dic = new Dictionary<string, string>();
  6499. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6500. {
  6501. List<string> list = new List<string>();
  6502. try
  6503. {
  6504. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6505. foreach (var item in spilitArr)
  6506. {
  6507. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6508. var depCode = spDotandEmpty[2].Substring(0, 3);
  6509. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6510. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6511. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6512. list.Add(depName);
  6513. list.Add(arrName);
  6514. }
  6515. list = list.Distinct().ToList();
  6516. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6517. }
  6518. catch (Exception)
  6519. {
  6520. dic.Add("ReturnCode", "行程录入不正确!");
  6521. }
  6522. }
  6523. else
  6524. {
  6525. dic.Add("ReturnCode", "未录入行程!");
  6526. }
  6527. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6528. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6529. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6530. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6531. {
  6532. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6533. dic.Add("Day", sp.Days.ToString());
  6534. }
  6535. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6536. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6537. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6538. //dic.Add("Names", Names);
  6539. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6540. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6541. decimal dac1totalPrice = 0.00M;
  6542. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6543. foreach (var dac in dac1)
  6544. {
  6545. if (dac.SubTotal == 0.00M)
  6546. {
  6547. continue;
  6548. }
  6549. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6550. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6551. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6552. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6553. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6554. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6555. builder.Write(currency);//币种
  6556. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6557. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6558. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6559. builder.Write("");//人数
  6560. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6561. builder.Write("");//天数
  6562. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6563. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6564. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6565. decimal rate = 0.00M;
  6566. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6567. builder.Write(rate.ToString("#0.0000"));//汇率
  6568. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6569. decimal rbmPrice = dac.SubTotal;
  6570. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6571. accommodationStartIndex++;
  6572. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6573. }
  6574. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6575. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6576. {
  6577. table1.Rows.RemoveAt(i - 1);
  6578. foodandotherStartIndex--;
  6579. }
  6580. if (dac2.Count == dac3.Count)//国家 币种 金额
  6581. {
  6582. for (int i = 0; i < dac2.Count; i++)
  6583. {
  6584. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6585. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6586. }
  6587. }
  6588. decimal dac2totalPrice = 0.00M;
  6589. foreach (var dac in dac2)
  6590. {
  6591. if (dac.SubTotal == 0)
  6592. {
  6593. continue;
  6594. }
  6595. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6596. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6597. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6598. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6599. builder.Write(currency);//币种
  6600. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6601. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6602. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6603. builder.Write("");//人数
  6604. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6605. builder.Write("");//天数
  6606. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6607. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6608. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6609. decimal rate = 0.00M;
  6610. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6611. builder.Write(rate.ToString("#0.0000"));//汇率
  6612. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6613. decimal rbmPrice = dac.SubTotal;
  6614. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6615. foodandotherStartIndex++;
  6616. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6617. }
  6618. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6619. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6620. {
  6621. table1.Rows.RemoveAt(i - 1);
  6622. }
  6623. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6624. string otherFeeStr = "";
  6625. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6626. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6627. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6628. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6629. foreach (var otherInfo in dac5)
  6630. {
  6631. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6632. }
  6633. #endregion
  6634. if (otherFeeStr.Length > 0)
  6635. {
  6636. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6637. otherFeeStr = $"({otherFeeStr})";
  6638. dic.Add("OtherFeeStr", otherFeeStr);
  6639. }
  6640. //总计
  6641. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6642. //国际旅费
  6643. string outsideAir = string.Empty;
  6644. string allPriceAir = string.Empty;
  6645. if (_EnterExitCosts.SumJJC == 1)
  6646. {
  6647. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6648. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6649. }
  6650. if (_EnterExitCosts.SumGWC == 1)
  6651. {
  6652. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6653. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6654. }
  6655. if (_EnterExitCosts.SumTDC == 1)
  6656. {
  6657. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6658. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6659. }
  6660. dic.Add("InTravelPrice", $"({outsideAir})");
  6661. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6662. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6663. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6664. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6665. foreach (var key in dic.Keys)
  6666. {
  6667. builder.MoveToBookmark(key);
  6668. builder.Write(dic[key]);
  6669. }
  6670. //模板文件名
  6671. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6672. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6673. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6674. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6675. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6676. }
  6677. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6678. {
  6679. //获取模板
  6680. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6681. //载入模板
  6682. WorkbookDesigner designer = new WorkbookDesigner();
  6683. designer.Workbook = new Workbook(tempPath);
  6684. Dictionary<string, string> dic = new Dictionary<string, string>();
  6685. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6686. {
  6687. List<string> list = new List<string>();
  6688. try
  6689. {
  6690. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6691. foreach (var item in spilitArr)
  6692. {
  6693. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6694. var depCode = spDotandEmpty[2].Substring(0, 3);
  6695. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6696. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6697. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6698. list.Add(depName);
  6699. list.Add(arrName);
  6700. }
  6701. list = list.Distinct().ToList();
  6702. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6703. }
  6704. catch (Exception)
  6705. {
  6706. dic.Add("ReturnCode", "行程录入不正确!");
  6707. }
  6708. }
  6709. else
  6710. {
  6711. dic.Add("ReturnCode", "未录入行程!");
  6712. }
  6713. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6714. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6715. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6716. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6717. {
  6718. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6719. dic.Add("Day", sp.Days.ToString());
  6720. }
  6721. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6722. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6723. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6724. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6725. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6726. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6727. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6728. designer.SetDataSource("Name", Names);
  6729. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6730. designer.SetDataSource("Day", dic["Day"] + "天");
  6731. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6732. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6733. int startIndex = 10;
  6734. const int startIndexcopy = 10;
  6735. if (dac2.Count == dac3.Count)//国家 币种 金额
  6736. {
  6737. for (int i = 0; i < dac2.Count; i++)
  6738. {
  6739. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6740. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6741. }
  6742. }
  6743. DataTable dtdac1 = new DataTable();
  6744. List<string> place = new List<string>();
  6745. dtdac1.Columns.AddRange(new DataColumn[] {
  6746. new DataColumn(){ ColumnName = "city"},
  6747. new DataColumn(){ ColumnName = "curr"},
  6748. new DataColumn(){ ColumnName = "criterion"},
  6749. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6750. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6751. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6752. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6753. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6754. });
  6755. DataTable dtdac2 = new DataTable();
  6756. dtdac2.Columns.AddRange(new DataColumn[] {
  6757. new DataColumn(){ ColumnName = "city"},
  6758. new DataColumn(){ ColumnName = "curr"},
  6759. new DataColumn(){ ColumnName = "criterion"},
  6760. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6761. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6762. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6763. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6764. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6765. });
  6766. dtdac1.TableName = "tb1";
  6767. dtdac2.TableName = "tb2";
  6768. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6769. foreach (var item in dac1)
  6770. {
  6771. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6772. if (place.Contains(item.Place))
  6773. {
  6774. continue;
  6775. }
  6776. DataRow row = dtdac1.NewRow();
  6777. row["city"] = item.Place;
  6778. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6779. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6780. row["curr"] = currency;
  6781. row["rate"] = rate.ToString("#0.0000");
  6782. row["criterion"] = item.Cost.ToString("#0.00");
  6783. row["number"] = 1;
  6784. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6785. //row["costRMB"] = rbmPrice;
  6786. dtdac1.Rows.Add(row);
  6787. place.Add(item.Place);
  6788. }
  6789. place = new List<string>();
  6790. foreach (var item in dac2)
  6791. {
  6792. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6793. if (place.Contains(item.Place))
  6794. {
  6795. continue;
  6796. }
  6797. DataRow row = dtdac2.NewRow();
  6798. row["city"] = item.Place;
  6799. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6800. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6801. row["curr"] = currency;
  6802. row["rate"] = rate.ToString("#0.0000");
  6803. row["criterion"] = item.Cost.ToString("#0.00");
  6804. row["number"] = 1;
  6805. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6806. //row["cost"] = item.SubTotal;
  6807. //row["costRMB"] = rbmPrice;
  6808. dtdac2.Rows.Add(row);
  6809. place.Add(item.Place);
  6810. //dac2totalPrice += rbmPrice;
  6811. }
  6812. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6813. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6814. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6815. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6816. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6817. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6818. string cell4Str1 = string.Empty;
  6819. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6820. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6821. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6822. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6823. string cellStr = $" 5.其他费用(";
  6824. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6825. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6826. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6827. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6828. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6829. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6830. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6831. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6832. foreach (var otherInfo in dac5)
  6833. {
  6834. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6835. }
  6836. #endregion
  6837. if (cellStr.Length > 8)
  6838. {
  6839. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6840. }
  6841. cellStr += ")";
  6842. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6843. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6844. decimal pxFee = dac4.Sum(it => it.Cost);
  6845. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6846. string celllastStr1 = "";
  6847. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6848. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6849. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6850. celllastStr1 += $",国际旅费 元";
  6851. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6852. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6853. designer.SetDataSource("cell4Str", cell4Str);
  6854. designer.SetDataSource("cellStr", cellStr);
  6855. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6856. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6857. designer.SetDataSource("celllastStr", celllastStr);
  6858. Workbook wb = designer.Workbook;
  6859. var sheet = wb.Worksheets[0];
  6860. //绑定datatable数据集
  6861. designer.SetDataSource(dtdac1);
  6862. designer.SetDataSource(dtdac2);
  6863. designer.Process();
  6864. var rowStart = dtdac1.Rows.Count;
  6865. while (rowStart > 0)
  6866. {
  6867. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6868. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6869. startIndex++;
  6870. rowStart--;
  6871. }
  6872. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6873. startIndex += 1; //总计行
  6874. rowStart = dtdac2.Rows.Count;
  6875. while (rowStart > 0)
  6876. {
  6877. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6878. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6879. startIndex++;
  6880. rowStart--;
  6881. }
  6882. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6883. wb.CalculateFormula(true);
  6884. //模板文件名
  6885. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6886. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6887. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6888. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6889. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6890. }
  6891. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6892. {
  6893. //获取模板
  6894. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6895. //载入模板
  6896. Document doc = new Document(tempPath);
  6897. DocumentBuilder builder = new DocumentBuilder(doc);
  6898. Dictionary<string, string> dic = new Dictionary<string, string>();
  6899. dic.Add("GroupName", _DelegationInfo.TeamName);
  6900. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6901. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6902. string missionLeaderJob = "";//负责人job
  6903. //int groupNumber = 0; //团人数
  6904. if (DeleClientList.Count > 0)
  6905. {
  6906. missionLeader = DeleClientList[0]?.Name ?? "";
  6907. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6908. }
  6909. dic.Add("MissionLeader", missionLeader); //团负责人
  6910. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6911. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6912. #region MyRegion
  6913. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6914. //{
  6915. // List<string> list = new List<string>();
  6916. // try
  6917. // {
  6918. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6919. // foreach (var item in spilitArr)
  6920. // {
  6921. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6922. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6923. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6924. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6925. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6926. // list.Add(depName);
  6927. // list.Add(arrName);
  6928. // }
  6929. // list = list.Distinct().ToList();
  6930. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6931. // }
  6932. // catch (Exception)
  6933. // {
  6934. // dic.Add("ReturnCode", "行程录入不正确!");
  6935. // }
  6936. //}
  6937. //else
  6938. //{
  6939. // dic.Add("ReturnCode", "未录入行程!");
  6940. //}
  6941. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6942. dic.Add("ReturnCode", string.Join("、", countrys));
  6943. #endregion
  6944. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6945. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6946. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6947. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6948. //{
  6949. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6950. // dic.Add("Day", sp.Days.ToString());
  6951. //}
  6952. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6953. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6954. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6955. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6956. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6957. //培训人员名单
  6958. int cultivateRowIndex = 7;
  6959. foreach (var item in DeleClientList)
  6960. {
  6961. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6962. builder.Write(item.Name);
  6963. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6964. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6965. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6966. string birthDay = "";
  6967. if (item.Birthday != null)
  6968. {
  6969. DateTime dt = Convert.ToDateTime(item.Birthday);
  6970. birthDay = $"{dt.Year}.{dt.Month}";
  6971. }
  6972. builder.Write(birthDay);
  6973. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6974. builder.Write(item.Company);
  6975. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6976. builder.Write(item.Job);
  6977. cultivateRowIndex++;
  6978. }
  6979. //删除多余行
  6980. //cultivateRowIndex -= 2;
  6981. int delRows = 10 + 7 - cultivateRowIndex;
  6982. if (delRows > 0)
  6983. {
  6984. for (int i = 0; i < delRows; i++)
  6985. {
  6986. table1.Rows.RemoveAt(cultivateRowIndex);
  6987. //cultivateRowIndex++;
  6988. }
  6989. }
  6990. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6991. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6992. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6993. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6994. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6995. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6996. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6997. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6998. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6999. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7000. //其他费用
  7001. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7002. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7003. //其他费用合计
  7004. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7005. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7006. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7007. //公务舱合计
  7008. //国际旅费
  7009. //string outsideJJ = "";
  7010. //string allPriceJJ = "";
  7011. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7012. {
  7013. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7014. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7015. }
  7016. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7017. {
  7018. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7019. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7020. }
  7021. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7022. {
  7023. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7024. dic.Add("AirFeeTotal", airFeeTotalStr);
  7025. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7026. dic.Add("FeeTotal", feeTotalStr);
  7027. }
  7028. foreach (var key in dic.Keys)
  7029. {
  7030. builder.MoveToBookmark(key);
  7031. builder.Write(dic[key]);
  7032. }
  7033. //模板文件名
  7034. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7035. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7036. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7037. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7038. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7039. }
  7040. }
  7041. else if (dto.ExportType == 2) //表格
  7042. {
  7043. //利用键值对存放数据
  7044. Dictionary<string, string> dic = new Dictionary<string, string>();
  7045. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7046. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7047. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7048. dic.Add("Day", sp.Days.ToString());
  7049. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7050. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7051. {
  7052. //获取模板
  7053. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7054. //载入模板
  7055. Document doc = new Document(tempPath);
  7056. DocumentBuilder builder = new DocumentBuilder(doc);
  7057. dic.Add("TeamName", _DelegationInfo.TeamName);
  7058. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7059. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7060. string missionLeaderName = "",
  7061. missionLeaderJob = "";
  7062. if (DeleClientList.Count > 0)
  7063. {
  7064. missionLeaderName = DeleClientList[0].Name;
  7065. missionLeaderJob = DeleClientList[0].Job;
  7066. }
  7067. dic.Add("MissionLeaderName", missionLeaderName);
  7068. dic.Add("MissionLeaderJob", missionLeaderJob);
  7069. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7070. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7071. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7072. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7073. int rowCount = 10;//总人数行
  7074. int startRowIndex = 7; //起始行
  7075. for (int i = 0; i < DeleClientList.Count; i++)
  7076. {
  7077. builder.MoveToCell(0, startRowIndex, 0, 0);
  7078. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7079. builder.MoveToCell(0, startRowIndex, 1, 0);
  7080. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7081. builder.Write(sex);//性别
  7082. builder.MoveToCell(0, startRowIndex, 2, 0);
  7083. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7084. builder.MoveToCell(0, startRowIndex, 3, 0);
  7085. builder.Write(DeleClientList[i].Company);//工作单位
  7086. builder.MoveToCell(0, startRowIndex, 4, 0);
  7087. builder.Write(DeleClientList[i].Job);//职务及级别
  7088. builder.MoveToCell(0, startRowIndex, 5, 0);
  7089. builder.Write("");//人员属性
  7090. builder.MoveToCell(0, startRowIndex, 6, 0);
  7091. builder.Write("");//上次出国时间
  7092. startRowIndex++;
  7093. }
  7094. int nullRow = rowCount - DeleClientList.Count;//空行
  7095. for (int i = 0; i < nullRow; i++)
  7096. {
  7097. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7098. }
  7099. foreach (var key in dic.Keys)
  7100. {
  7101. builder.MoveToBookmark(key);
  7102. builder.Write(dic[key]);
  7103. }
  7104. //模板文件名
  7105. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7106. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7107. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7108. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7109. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7110. }
  7111. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7112. {
  7113. //获取模板
  7114. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7115. //载入模板
  7116. Document doc = new Document(tempPath);
  7117. DocumentBuilder builder = new DocumentBuilder(doc);
  7118. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7119. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7120. dic.Add("Names", Names);
  7121. int accommodationRows = 12;
  7122. //int foodandotherRows = 12;
  7123. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7124. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7125. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7126. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7127. int accommodationStartIndex = 6;
  7128. decimal dac1totalPrice = 0.00M;
  7129. foreach (var dac in dac1)
  7130. {
  7131. if (dac.SubTotal == 0)
  7132. {
  7133. continue;
  7134. }
  7135. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7136. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7137. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7138. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7139. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7140. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7141. builder.Write(currency);//币种
  7142. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7143. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7144. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7145. builder.Write("");//人数
  7146. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7147. builder.Write("");//天数
  7148. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7149. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7150. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7151. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7152. builder.Write(rate.ToString("#0.0000"));//汇率
  7153. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7154. decimal rbmPrice = rate * dac.SubTotal;
  7155. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7156. accommodationStartIndex++;
  7157. dac1totalPrice += rbmPrice;
  7158. }
  7159. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7160. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7161. builder.Write("小计");
  7162. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7163. builder.Write(dac1totalPrice.ToString("#0.00"));
  7164. accommodationStartIndex++;
  7165. int nullRow = accommodationRows - dac1.Count;
  7166. //删除空行
  7167. //if (nullRow > 0)
  7168. //{
  7169. // int rowIndex = accommodationStartIndex;
  7170. // for (int i = 0; i < nullRow; i++)
  7171. // {
  7172. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7173. // row.Remove();
  7174. // rowIndex++;
  7175. // }
  7176. //}
  7177. if (dac2.Count == dac3.Count)//国家 币种 金额
  7178. {
  7179. for (int i = 0; i < dac2.Count; i++)
  7180. {
  7181. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7182. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7183. }
  7184. }
  7185. int foodandotherStartIndex = 19;//
  7186. decimal dac2totalPrice = 0.00M;
  7187. foreach (var dac in dac2)
  7188. {
  7189. if (dac.SubTotal == 0)
  7190. {
  7191. continue;
  7192. }
  7193. //foodandotherStartIndex = 12;
  7194. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7195. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7196. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7197. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7198. builder.Write(currency);//币种
  7199. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7200. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7201. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7202. builder.Write("");//人数
  7203. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7204. builder.Write("");//天数
  7205. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7206. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7207. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7208. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7209. builder.Write(rate.ToString("#0.0000"));//汇率
  7210. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7211. decimal rbmPrice = rate * dac.SubTotal;
  7212. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7213. foodandotherStartIndex++;
  7214. dac2totalPrice += rbmPrice;
  7215. }
  7216. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7217. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7218. //删除空行
  7219. //if (dac2.Count < foodandotherRows)
  7220. //{
  7221. // while (table2.Rows.Count > dac2.Count)
  7222. // {
  7223. // table2.Rows.RemoveAt(dac2.Count);
  7224. // }
  7225. //}
  7226. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7227. string otherFeeStr = "";
  7228. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7229. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7230. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7231. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7232. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7233. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7234. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7235. foreach (var otherInfo in dac5)
  7236. {
  7237. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7238. }
  7239. #endregion
  7240. if (otherFeeStr.Length > 0)
  7241. {
  7242. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7243. otherFeeStr = $"({otherFeeStr})";
  7244. dic.Add("OtherFeeStr", otherFeeStr);
  7245. }
  7246. foreach (var key in dic.Keys)
  7247. {
  7248. builder.MoveToBookmark(key);
  7249. builder.Write(dic[key]);
  7250. }
  7251. //模板文件名
  7252. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7253. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7254. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7255. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7256. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7257. }
  7258. }
  7259. else if (dto.ExportType == 3)
  7260. {
  7261. if (dto.SubTypeId == 1) //团组成员名单
  7262. {
  7263. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7264. //获取模板
  7265. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7266. //载入模板
  7267. Document doc = new Document(tempPath);
  7268. DocumentBuilder builder = new DocumentBuilder(doc);
  7269. //获取word里所有表格
  7270. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7271. //获取所填表格的序数
  7272. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7273. var rowStart = tableOne.Rows[0]; //获取第1行
  7274. //循环赋值
  7275. for (int i = 0; i < DeleClientList.Count; i++)
  7276. {
  7277. builder.MoveToCell(0, i + 1, 0, 0);
  7278. builder.Write(DeleClientList[i].Name);
  7279. builder.MoveToCell(0, i + 1, 1, 0);
  7280. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7281. builder.Write(sex);
  7282. builder.MoveToCell(0, i + 1, 2, 0);
  7283. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7284. builder.MoveToCell(0, i + 1, 3, 0);
  7285. builder.Write(DeleClientList[i].Company);
  7286. builder.MoveToCell(0, i + 1, 4, 0);
  7287. builder.Write(DeleClientList[i].Job);
  7288. }
  7289. //删除多余行
  7290. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7291. {
  7292. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7293. }
  7294. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7295. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7296. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7297. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7298. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7299. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7300. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7301. }
  7302. }
  7303. return Ok(JsonView(400, "操作失败!", ""));
  7304. }
  7305. catch (Exception ex)
  7306. {
  7307. return Ok(JsonView(400, ex.Message, ""));
  7308. }
  7309. }
  7310. /// <summary>
  7311. /// 获取三公费用标准city
  7312. /// </summary>
  7313. /// <param name="placeData"></param>
  7314. /// <param name="nationalTravelFeeId"></param>
  7315. /// <returns></returns>
  7316. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7317. {
  7318. string _city = string.Empty;
  7319. if (placeData.Count < 1) return _city;
  7320. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7321. if (data == null) return _city;
  7322. string country = data.Country;
  7323. string city = data.City;
  7324. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7325. else _city = city;
  7326. return _city;
  7327. }
  7328. ///// <summary>
  7329. ///// 团组模块 - 出入境费用 - 明细表导出
  7330. ///// </summary>
  7331. ///// <returns></returns>
  7332. //[HttpPost]
  7333. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7334. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7335. //{
  7336. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7337. // if (data.Code != 0)
  7338. // {
  7339. // return Ok(JsonView(false, data.Msg));
  7340. // }
  7341. // return Ok(JsonView(true, data.Msg, data.Data));
  7342. //}
  7343. /// <summary>
  7344. /// 团组模块 - 出入境费用 - 一键清空
  7345. /// </summary>
  7346. /// <returns></returns>
  7347. [HttpPost]
  7348. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7350. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7351. {
  7352. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7353. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7354. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7355. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7356. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7357. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7358. .SetColumns(x => new Grp_DayOtherPrice
  7359. {
  7360. IsDel = 1,
  7361. DeleteUserId = dto.UserId,
  7362. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7363. })
  7364. .ExecuteCommandAsync();
  7365. if (_view.Code == 0)
  7366. {
  7367. return Ok(JsonView(true, "操作成功"));
  7368. }
  7369. return Ok(JsonView(false, "操作失败"));
  7370. }
  7371. /// <summary>
  7372. /// 团组模块 - 出入境费用 - 子项删除
  7373. /// </summary>
  7374. /// <returns></returns>
  7375. [HttpPost]
  7376. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7378. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7379. {
  7380. try
  7381. {
  7382. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7383. if (data.Code != 0)
  7384. {
  7385. return Ok(JsonView(false, data.Msg));
  7386. }
  7387. return Ok(JsonView(true, "操作成功!", data.Data));
  7388. }
  7389. catch (Exception ex)
  7390. {
  7391. return Ok(JsonView(false, ex.Message));
  7392. }
  7393. }
  7394. /// <summary>
  7395. /// 删除三公其他费用
  7396. /// </summary>
  7397. /// <param name="dto"></param>
  7398. /// <returns></returns>
  7399. [HttpPost]
  7400. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7401. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7402. {
  7403. var jw = JsonView(false, "删除失败!");
  7404. var data = new Grp_DayOtherPrice()
  7405. {
  7406. Id = dto.Id,
  7407. IsDel = 1,
  7408. DeleteUserId = dto.DeleteUserId,
  7409. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7410. };
  7411. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7412. if (del > 0)
  7413. {
  7414. jw.Code = 200;
  7415. jw.Msg = "删除成功!";
  7416. }
  7417. return Ok(jw);
  7418. }
  7419. /// <summary>
  7420. /// 团组模块 - 出入境国家费用标准 List
  7421. /// </summary>
  7422. /// <returns></returns>
  7423. [HttpPost]
  7424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7425. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7426. {
  7427. int provinceId = dto.ProvinceId;
  7428. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7429. var nftData = await _sqlSugar
  7430. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7431. JoinType.Left, ntf.Currency == sd1.Id,
  7432. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7433. JoinType.Left, ntf.ProvinceId == c.Id
  7434. ))
  7435. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7436. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7437. {
  7438. Id = ntf.Id,
  7439. ProvinceId = ntf.ProvinceId,
  7440. ProvinceName = c.Name_CN,
  7441. Continent = ntf.Continent,
  7442. Country = ntf.Country,
  7443. City = ntf.City,
  7444. Currency = ntf.Currency,
  7445. CurrencyCode = sd1.Name,
  7446. CurrencyName = sd1.Remark,
  7447. RoomCost = ntf.RoomCost,
  7448. FoodCost = ntf.FoodCost,
  7449. PublicCost = ntf.PublicCost,
  7450. LastUpdateUserId = ntf.LastUpdateUserId,
  7451. LastUpdateUserName = u.CnName,
  7452. LastUpdateTime = ntf.LastUpdateTime
  7453. })
  7454. .ToListAsync();
  7455. return Ok(JsonView(true, "查询成功!", nftData));
  7456. }
  7457. /// <summary>
  7458. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7459. /// </summary>
  7460. /// <returns></returns>
  7461. [HttpPost]
  7462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7463. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7464. {
  7465. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7466. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7467. List<string> countryData = new List<string>();
  7468. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7469. countryData = countryData.Distinct().ToList();
  7470. List<dynamic> dataSource = new List<dynamic>();
  7471. foreach (var item in countryData)
  7472. {
  7473. var cityData1 = new List<string>();
  7474. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7475. var countryData2 = new
  7476. {
  7477. CountryName = item,
  7478. CityData = cityData1
  7479. };
  7480. if (!dataSource.Contains(countryData2))
  7481. {
  7482. dataSource.Add(countryData2);
  7483. }
  7484. }
  7485. return Ok(JsonView(true, "查询成功!", dataSource));
  7486. }
  7487. /// <summary>
  7488. /// 团组模块 - 出入境国家费用标准 Page List
  7489. /// </summary>
  7490. /// <returns></returns>
  7491. [HttpPost]
  7492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7493. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7494. {
  7495. int portId = dto.PortType,
  7496. pageIndex = dto.PageIndex,
  7497. pageSize = dto.PageSize;
  7498. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7499. if (pageIndex == 0) pageIndex = 1;
  7500. if (pageSize == 0) pageSize = 10;
  7501. RefAsync<int> total = 0;
  7502. var nationalTravelFeeData = await _sqlSugar
  7503. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7504. JoinType.Left, ntf.Currency == sd1.Id,
  7505. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7506. JoinType.Left, ntf.ProvinceId == sd2.Id
  7507. ))
  7508. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7509. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7510. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7511. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7512. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7513. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7514. {
  7515. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7516. Id = ntf.Id,
  7517. ProvinceId = ntf.ProvinceId,
  7518. ProvinceName = sd2.Name_CN,
  7519. Continent = ntf.Continent,
  7520. Country = ntf.Country,
  7521. City = ntf.City,
  7522. Currency = ntf.Currency,
  7523. CurrencyCode = sd1.Name,
  7524. CurrencyName = sd1.Remark,
  7525. RoomCost = ntf.RoomCost,
  7526. FoodCost = ntf.FoodCost,
  7527. PublicCost = ntf.PublicCost,
  7528. LastUpdateUserId = ntf.LastUpdateUserId,
  7529. LastUpdateUserName = u.CnName,
  7530. LastUpdateTime = ntf.LastUpdateTime,
  7531. Remark = ntf.Remark
  7532. })
  7533. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7534. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7535. }
  7536. /// <summary>
  7537. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7538. /// </summary>
  7539. /// <returns></returns>
  7540. [HttpPost]
  7541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7542. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7543. {
  7544. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7545. int portId = dto.PortType;
  7546. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7547. string whereSql = string.Empty;
  7548. if (!string.IsNullOrEmpty(dto.Country))
  7549. {
  7550. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7551. }
  7552. if (!string.IsNullOrEmpty(dto.City))
  7553. {
  7554. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7555. }
  7556. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7557. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7558. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7559. From Grp_NationalTravelFee gntf
  7560. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7561. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7562. Where gntf.Isdel = 0 {0} ", whereSql);
  7563. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7564. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7565. }
  7566. /// <summary>
  7567. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7568. /// </summary>
  7569. /// <returns></returns>
  7570. [HttpPost]
  7571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7572. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7573. {
  7574. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7575. }
  7576. /// <summary>
  7577. /// 团组模块 - 出入境国家费用标准 - Del
  7578. /// </summary>
  7579. /// <returns></returns>
  7580. [HttpPost]
  7581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7582. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7583. {
  7584. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7585. {
  7586. Id = dto.Id,
  7587. DeleteUserId = dto.DeleteUserId,
  7588. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7589. IsDel = 1
  7590. };
  7591. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7592. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7593. .WhereColumns(it => new { it.Id })
  7594. .ExecuteCommandAsync();
  7595. if (delStatus <= 0)
  7596. {
  7597. return Ok(JsonView(false, "删除失败!"));
  7598. }
  7599. return Ok(JsonView(true, "操作成功!"));
  7600. }
  7601. /// <summary>
  7602. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7603. /// 注:Get 请求Headers 加 Token
  7604. /// </summary>
  7605. /// <param name="groupId"></param>
  7606. /// <returns></returns>
  7607. [HttpGet("{groupId}")]
  7608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7609. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7610. {
  7611. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7612. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7613. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7614. data.ForEach(x =>
  7615. {
  7616. x.CreateUserId = _currUserInfo.UserId;
  7617. });
  7618. if (data.Any())
  7619. {
  7620. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7621. if (add > 0)
  7622. {
  7623. return Ok(JsonView(true, "操作成功!"));
  7624. }
  7625. }
  7626. return Ok(JsonView(false, "未操作!"));
  7627. }
  7628. #endregion
  7629. #region 团组经理模块 出入境费用-草稿
  7630. /// <summary>
  7631. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7632. /// </summary>
  7633. /// <returns></returns>
  7634. [HttpGet]
  7635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7636. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7637. {
  7638. var provData = await _groupRepository.ProvinceBasicSource();
  7639. return Ok(JsonView(true, "查询成功!", provData));
  7640. }
  7641. /// <summary>
  7642. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7643. /// </summary>
  7644. /// <returns></returns>
  7645. [HttpGet("{provinceId}")]
  7646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7647. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7648. {
  7649. //验证城市归属并给默认值
  7650. if (provinceId < 1) provinceId = 122;
  7651. /*
  7652. * 122 四川
  7653. * 108 贵州
  7654. * 103 重庆
  7655. * 132 云南
  7656. */
  7657. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7658. return Ok(JsonView(true, "查询成功!", new
  7659. {
  7660. WordTypeData = wordTypeData,
  7661. ExcelTypeData = excelTypeData,
  7662. }));
  7663. }
  7664. /// <summary>
  7665. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7666. /// </summary>
  7667. /// <returns></returns>
  7668. [HttpPost]
  7669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7670. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7671. {
  7672. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7673. .Where(x => x.IsDel == 0)
  7674. .OrderByDescending(x => x.CreateTime)
  7675. .Select(x => new { x.Id, x.DraftName })
  7676. .ToListAsync();
  7677. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7678. //SetDataInfoView
  7679. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7680. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7681. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7682. int provinceId = dto.ProvinceId;
  7683. if (provinceId < 1) provinceId = 122;
  7684. /*
  7685. * 122 四川
  7686. * 108 贵州
  7687. * 103 重庆
  7688. * 132 云南
  7689. */
  7690. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7691. //默认币种显示
  7692. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7693. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7694. return Ok(JsonView(true, "查询成功!", new
  7695. {
  7696. DraftNameDatas = draftNameDatas,
  7697. CurrencyData = _CurrencyData,
  7698. WordTypeData = wordTypeData,
  7699. ExcelTypeData = excelTypeData,
  7700. CurrencyInit = _currencyInfos,
  7701. ViewPermissionData = viewPermissionData
  7702. }));
  7703. }
  7704. /// <summary>
  7705. /// 团组模块 - 出入境费用-草稿
  7706. /// 实时汇率 tips
  7707. /// 机票费用 tips
  7708. /// </summary>
  7709. /// <returns></returns>
  7710. [HttpPost]
  7711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7712. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7713. {
  7714. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7715. return Ok(JsonView(true, "查询成功!", new
  7716. {
  7717. //GroupNameData = groupNameData.Data,
  7718. //visaData = visaData.Data,
  7719. //airData = airData.Data,
  7720. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7721. }));
  7722. }
  7723. /// <summary>
  7724. /// 团组模块 - 出入境费用-草稿
  7725. /// 签证费用 tips
  7726. /// </summary>
  7727. /// <returns></returns>
  7728. [HttpPost]
  7729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7730. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7731. {
  7732. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7733. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7734. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7735. .Select(x => x.NationalTravelFeeId)
  7736. .Distinct()
  7737. .ToListAsync();
  7738. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7739. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7740. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7741. .Select(x => x.Country)
  7742. .Distinct()
  7743. .ToArrayAsync();
  7744. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7745. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7746. return Ok(JsonView(true, "查询成功!", new
  7747. {
  7748. totalAmt = totalAmt,
  7749. remark = remark
  7750. }));
  7751. }
  7752. /// <summary>
  7753. /// 团组模块 - 出入境费用-草稿 - Info
  7754. /// </summary>
  7755. /// <returns></returns>
  7756. [HttpPost]
  7757. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7759. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7760. {
  7761. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7762. }
  7763. /// <summary>
  7764. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7765. /// </summary>
  7766. /// <returns></returns>
  7767. [HttpPost]
  7768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7769. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7770. {
  7771. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7772. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7773. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7774. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7775. foreach (var userId in dto.UserIds)
  7776. {
  7777. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7778. }
  7779. if (permissions.Any())
  7780. {
  7781. _sqlSugar.BeginTran();
  7782. try
  7783. {
  7784. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7785. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7786. if (result < 1)
  7787. {
  7788. _sqlSugar.RollbackTran();
  7789. return Ok(JsonView(false));
  7790. }
  7791. }
  7792. catch (Exception ex)
  7793. {
  7794. _sqlSugar.RollbackTran();
  7795. return Ok(JsonView(false, ex.Message));
  7796. }
  7797. _sqlSugar.CommitTran();
  7798. return Ok(JsonView(true));
  7799. }
  7800. return Ok(JsonView(false));
  7801. }
  7802. /// <summary>
  7803. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7804. /// </summary>
  7805. /// <returns></returns>
  7806. [HttpPost]
  7807. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7809. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7810. {
  7811. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7812. if (data.Code != 0)
  7813. {
  7814. return Ok(JsonView(false, data.Msg));
  7815. }
  7816. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7817. //汇率信息记录
  7818. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7819. return Ok(JsonView(true, data.Msg, data.Data));
  7820. }
  7821. /// <summary>
  7822. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7823. /// </summary>
  7824. /// <param name="dto"></param>
  7825. /// <returns></returns>
  7826. [HttpPost]
  7827. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7829. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7830. {
  7831. try
  7832. {
  7833. var id = dto.Id;
  7834. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7835. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7836. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7837. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7838. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7839. 3 团组成员名单 1 团组成员名单", ""));
  7840. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7841. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7842. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7843. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7844. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7845. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7846. //数据源
  7847. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7848. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7849. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7850. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7851. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7852. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7853. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7854. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7855. .Select((x, a, b) => new
  7856. {
  7857. x.Index,
  7858. itemName = a.Name,
  7859. CurrencyStr = b.Name,
  7860. x.Cost,
  7861. x.SubTotal,
  7862. x.Remark
  7863. })
  7864. .OrderBy((x) => x.Index)
  7865. .ToList(); //其他款项费用
  7866. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7867. var peiceItemCurrencys = new List<string>();
  7868. if (_DayAndCosts.Any())
  7869. {
  7870. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7871. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7872. }
  7873. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7874. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7875. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7876. {
  7877. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7878. }
  7879. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7880. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7881. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7882. if (dto.ExportType == 1) //明细表
  7883. {
  7884. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7885. {
  7886. //获取模板
  7887. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7888. //载入模板
  7889. Document doc = new Document(tempPath);
  7890. DocumentBuilder builder = new DocumentBuilder(doc);
  7891. //利用键值对存放数据
  7892. Dictionary<string, string> dic = new Dictionary<string, string>();
  7893. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7894. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7895. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7896. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7897. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7898. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7899. //境内费用(其他费用)
  7900. if (_EnterExitCosts.ChoiceOne == 1)
  7901. {
  7902. string row1_1 = "";
  7903. if (_EnterExitCosts.Visa > 0)
  7904. {
  7905. //insidePayTotal += _EnterExitCosts.Visa;
  7906. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7907. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7908. //{
  7909. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7910. //}
  7911. }
  7912. string row1_2 = "";
  7913. if (_EnterExitCosts.YiMiao > 0)
  7914. {
  7915. //insidePayTotal += _EnterExitCosts.YiMiao;
  7916. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7917. }
  7918. if (_EnterExitCosts.HeSuan > 0)
  7919. {
  7920. //insidePayTotal += _EnterExitCosts.HeSuan;
  7921. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7922. }
  7923. if (_EnterExitCosts.Service > 0)
  7924. {
  7925. //insidePayTotal += _EnterExitCosts.Service;
  7926. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7927. }
  7928. string row1_3 = "";
  7929. if (_EnterExitCosts.Safe > 0)
  7930. {
  7931. //insidePayTotal += _EnterExitCosts.Safe;
  7932. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7933. }
  7934. if (_EnterExitCosts.Ticket > 0)
  7935. {
  7936. //insidePayTotal += _EnterExitCosts.Ticket;
  7937. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7938. }
  7939. string row1 = "";
  7940. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7941. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7942. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7943. row1 += $"备注:{_EnterExitCosts.Remark}";
  7944. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7945. dic.Add("Row1Str", row1);
  7946. }
  7947. string airTotalStr = string.Empty,
  7948. airPriceStr = string.Empty;
  7949. //经济舱
  7950. if (_EnterExitCosts.SumJJC == 1)
  7951. {
  7952. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7953. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7954. }
  7955. //公务舱
  7956. if (_EnterExitCosts.SumGWC == 1)
  7957. {
  7958. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7959. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7960. }
  7961. //头等舱
  7962. if (_EnterExitCosts.SumTDC == 1)
  7963. {
  7964. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7965. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7966. }
  7967. //汇率描述
  7968. string rateStr = "";
  7969. if (peiceItemCurrencyInfos.Any())
  7970. {
  7971. rateStr = "\r\n汇率描述:";
  7972. foreach (var item in peiceItemCurrencyInfos)
  7973. {
  7974. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7975. }
  7976. }
  7977. string twoItemRemark = "备注:";
  7978. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7979. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7980. dic.Add("AirTotalStr", airTotalStr);
  7981. dic.Add("AirPriceStr", airPriceStr);
  7982. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7983. dic.Add("TwoItemRemark", twoItemRemark);
  7984. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7985. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7986. int table1Row = 0,
  7987. table2Row = 0,
  7988. table3Row = 0,
  7989. table4Row = 0,
  7990. table5Row = 0;
  7991. //住宿费
  7992. if (_EnterExitCosts.ChoiceThree == 1)
  7993. {
  7994. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7995. table1Row = dac1.Count;
  7996. #region 填充word表格内容
  7997. for (int i = 0; i < dac1.Count; i++)
  7998. {
  7999. var dac = dac1[i];
  8000. if (dac == null) continue;
  8001. builder.MoveToCell(0, i, 0, 0);
  8002. builder.Write("第" + dac.Days.ToString() + "晚:");
  8003. builder.MoveToCell(0, i, 1, 0);
  8004. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8005. //builder.Write(dac.Place == null ? "" : dac.Place);
  8006. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8007. builder.MoveToCell(0, i, 2, 0);
  8008. builder.Write("费用标准:");
  8009. string curr = "";
  8010. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8011. if (currData != null)
  8012. {
  8013. curr = currData.Name;
  8014. }
  8015. builder.MoveToCell(0, i, 3, 0);
  8016. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8017. builder.MoveToCell(0, i, 4, 0);
  8018. builder.Write("费用小计:");
  8019. builder.MoveToCell(0, i, 5, 0);
  8020. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8021. }
  8022. #endregion
  8023. }
  8024. else dic.Add("SubZS", "0.00");
  8025. //删除多余行
  8026. while (table1.Rows.Count > table1Row)
  8027. {
  8028. table1.Rows.RemoveAt(table1Row);
  8029. }
  8030. //伙食费
  8031. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8032. if (_EnterExitCosts.ChoiceFour == 1)
  8033. {
  8034. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8035. table2Row = dac2.Count;
  8036. #region 填充word表格内容
  8037. for (int i = 0; i < dac2.Count; i++)
  8038. {
  8039. var dac = dac2[i];
  8040. if (dac == null) continue;
  8041. builder.MoveToCell(1, i, 0, 0);
  8042. builder.Write("第" + dac.Days.ToString() + "天:");
  8043. builder.MoveToCell(1, i, 1, 0);
  8044. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8045. builder.MoveToCell(1, i, 2, 0);
  8046. builder.Write("费用标准:");
  8047. string curr = "";
  8048. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8049. if (currData != null)
  8050. {
  8051. curr = currData.Name;
  8052. }
  8053. builder.MoveToCell(1, i, 3, 0);
  8054. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8055. builder.MoveToCell(1, i, 4, 0);
  8056. builder.Write("费用小计:");
  8057. builder.MoveToCell(1, i, 5, 0);
  8058. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8059. }
  8060. #endregion
  8061. }
  8062. else dic.Add("SubHS", "0.00");
  8063. //删除多余行
  8064. while (table2.Rows.Count > table2Row)
  8065. {
  8066. table2.Rows.RemoveAt(table2Row);
  8067. }
  8068. //公杂费
  8069. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8070. if (_EnterExitCosts.ChoiceFive == 1)
  8071. {
  8072. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8073. table3Row = dac3.Count;
  8074. #region 填充word表格内容
  8075. for (int i = 0; i < dac3.Count; i++)
  8076. {
  8077. var dac = dac3[i];
  8078. if (dac == null) continue;
  8079. builder.MoveToCell(2, i, 0, 0);
  8080. builder.Write("第" + dac.Days.ToString() + "天:");
  8081. builder.MoveToCell(2, i, 1, 0);
  8082. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8083. builder.MoveToCell(2, i, 2, 0);
  8084. builder.Write("费用标准:");
  8085. string curr = "";
  8086. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8087. if (currData != null)
  8088. {
  8089. curr = currData.Name;
  8090. }
  8091. builder.MoveToCell(2, i, 3, 0);
  8092. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8093. builder.MoveToCell(2, i, 4, 0);
  8094. builder.Write("费用小计:");
  8095. builder.MoveToCell(2, i, 5, 0);
  8096. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8097. }
  8098. //删除多余行
  8099. while (table3.Rows.Count > table3Row)
  8100. {
  8101. table3.Rows.RemoveAt(table3Row);
  8102. }
  8103. #endregion
  8104. }
  8105. else dic.Add("SubGZF", "0.00");
  8106. //删除多余行
  8107. while (table3.Rows.Count > table3Row)
  8108. {
  8109. table3.Rows.RemoveAt(table3Row);
  8110. }
  8111. //培训费
  8112. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8113. if (_EnterExitCosts.ChoiceSix == 1)
  8114. {
  8115. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8116. dic.Add("SubPX", pxStr);
  8117. table4Row = dac4.Count;
  8118. #region 填充word表格内容
  8119. for (int i = 0; i < dac4.Count; i++)
  8120. {
  8121. var dac = dac4[i];
  8122. if (dac == null) continue;
  8123. builder.MoveToCell(3, i, 0, 0);
  8124. builder.Write("第" + dac.Days.ToString() + "天:");
  8125. builder.MoveToCell(3, i, 1, 0);
  8126. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8127. builder.MoveToCell(3, i, 2, 0);
  8128. builder.Write("费用标准:");
  8129. string curr = "";
  8130. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8131. if (currData != null)
  8132. {
  8133. curr = currData.Name;
  8134. }
  8135. builder.MoveToCell(3, i, 3, 0);
  8136. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8137. builder.MoveToCell(3, i, 4, 0);
  8138. builder.Write("费用小计:");
  8139. builder.MoveToCell(3, i, 5, 0);
  8140. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8141. }
  8142. #endregion
  8143. }
  8144. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8145. //删除多余行
  8146. while (table4.Rows.Count > table4Row)
  8147. {
  8148. table4.Rows.RemoveAt(table4Row);
  8149. }
  8150. //其他费用
  8151. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8152. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8153. {
  8154. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8155. dic.Add("titleQi", qtStr);
  8156. table5Row = dac5.Count;
  8157. #region 填充word表格内容
  8158. for (int i = 0; i < dac5.Count; i++)
  8159. {
  8160. var dac = dac5[i];
  8161. if (dac == null) continue;
  8162. builder.MoveToCell(4, i, 0, 0);
  8163. builder.Write("第" + dac.Index.ToString() + "项:");
  8164. builder.MoveToCell(4, i, 1, 0);
  8165. builder.Write(dac.itemName);
  8166. builder.MoveToCell(4, i, 2, 0);
  8167. builder.Write("费用标准:");
  8168. builder.MoveToCell(4, i, 3, 0);
  8169. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8170. builder.MoveToCell(4, i, 4, 0);
  8171. builder.Write("费用小计:");
  8172. builder.MoveToCell(4, i, 5, 0);
  8173. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8174. builder.MoveToCell(4, i, 6, 0);
  8175. builder.Write("备注:");
  8176. builder.MoveToCell(4, i, 7, 0);
  8177. builder.Write(dac.Remark);
  8178. }
  8179. #endregion
  8180. }
  8181. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8182. //删除多余行
  8183. while (table5.Rows.Count > table5Row)
  8184. {
  8185. table5.Rows.RemoveAt(table5Row);
  8186. }
  8187. //加上其他费用
  8188. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8189. decimal subJJC = 0.00M,
  8190. subGWC = 0.00M,
  8191. subTDC = 0.00M;
  8192. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8193. string totalLabel = string.Format("全部费用总计:");
  8194. //经济舱
  8195. if (_EnterExitCosts.SumJJC == 1)
  8196. {
  8197. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8198. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8199. }
  8200. //公务舱
  8201. if (_EnterExitCosts.SumGWC == 1)
  8202. {
  8203. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8204. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8205. }
  8206. //头等舱
  8207. if (_EnterExitCosts.SumTDC == 1)
  8208. {
  8209. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8210. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8211. }
  8212. //TotalLabel
  8213. dic.Add("TotalLabel", totalLabel);
  8214. #region 填充word模板书签内容
  8215. foreach (var key in dic.Keys)
  8216. {
  8217. Bookmark bookmark = doc.Range.Bookmarks[key];
  8218. if (bookmark != null)
  8219. {
  8220. builder.MoveToBookmark(key);
  8221. builder.Write(dic[key]);
  8222. }
  8223. }
  8224. #endregion
  8225. //文件名
  8226. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8227. strFileName = CommonFun.ValidFileName(strFileName);
  8228. AsposeHelper.removewatermark_v2180();
  8229. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8230. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8231. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8232. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8233. }
  8234. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8235. {
  8236. //获取模板
  8237. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8238. //载入模板
  8239. Document doc = new Document(tempPath);
  8240. DocumentBuilder builder = new DocumentBuilder(doc);
  8241. Dictionary<string, string> dic = new Dictionary<string, string>();
  8242. string returnCodeLabel = string.Empty;
  8243. if (nationalTravelFeeData.Any())
  8244. {
  8245. List<string> list = new List<string>();
  8246. foreach (var item in nationalTravelFeeData)
  8247. {
  8248. list.Add($"{item.Country}({item.City})");
  8249. }
  8250. list = list.Distinct().ToList();
  8251. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8252. }
  8253. var countryLabel = string.Empty;
  8254. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8255. if (countryData.Any())
  8256. {
  8257. countryLabel = string.Join("、", countryData);
  8258. }
  8259. dic.Add("ReturnCodeAir", returnCodeLabel);
  8260. dic.Add("VisitStartDate", "-");
  8261. dic.Add("VisitEndDate", "-");
  8262. dic.Add("Day", "-");
  8263. dic.Add("VisitCountry", countryLabel);
  8264. dic.Add("ClientUnit", "-");
  8265. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8266. //dic.Add("Names", Names);
  8267. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8268. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8269. decimal dac1totalPrice = 0.00M;
  8270. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8271. foreach (var dac in dac1)
  8272. {
  8273. if (dac.SubTotal == 0.00M)
  8274. {
  8275. continue;
  8276. }
  8277. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8278. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8279. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8280. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8281. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8282. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8283. builder.Write(currency);//币种
  8284. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8285. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8286. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8287. builder.Write("");//人数
  8288. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8289. builder.Write("");//天数
  8290. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8291. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8292. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8293. decimal rate = 0.00M;
  8294. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8295. builder.Write(rate.ToString("#0.0000"));//汇率
  8296. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8297. decimal rbmPrice = dac.SubTotal;
  8298. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8299. accommodationStartIndex++;
  8300. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8301. }
  8302. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8303. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8304. {
  8305. table1.Rows.RemoveAt(i - 1);
  8306. foodandotherStartIndex--;
  8307. }
  8308. if (dac2.Count == dac3.Count)//国家 币种 金额
  8309. {
  8310. for (int i = 0; i < dac2.Count; i++)
  8311. {
  8312. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8313. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8314. }
  8315. }
  8316. decimal dac2totalPrice = 0.00M;
  8317. foreach (var dac in dac2)
  8318. {
  8319. if (dac.SubTotal == 0)
  8320. {
  8321. continue;
  8322. }
  8323. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8324. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8325. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8326. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8327. builder.Write(currency);//币种
  8328. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8329. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8330. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8331. builder.Write("");//人数
  8332. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8333. builder.Write("");//天数
  8334. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8335. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8336. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8337. decimal rate = 0.00M;
  8338. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8339. builder.Write(rate.ToString("#0.0000"));//汇率
  8340. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8341. decimal rbmPrice = dac.SubTotal;
  8342. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8343. foodandotherStartIndex++;
  8344. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8345. }
  8346. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8347. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8348. {
  8349. table1.Rows.RemoveAt(i - 1);
  8350. }
  8351. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8352. string otherFeeStr = "";
  8353. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8354. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8355. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8356. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8357. foreach (var otherInfo in dac5)
  8358. {
  8359. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8360. }
  8361. #endregion
  8362. if (otherFeeStr.Length > 0)
  8363. {
  8364. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8365. otherFeeStr = $"({otherFeeStr})";
  8366. dic.Add("OtherFeeStr", otherFeeStr);
  8367. }
  8368. //总计
  8369. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8370. //国际旅费
  8371. string outsideAir = string.Empty;
  8372. string allPriceAir = string.Empty;
  8373. if (_EnterExitCosts.SumJJC == 1)
  8374. {
  8375. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8376. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8377. }
  8378. if (_EnterExitCosts.SumGWC == 1)
  8379. {
  8380. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8381. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8382. }
  8383. if (_EnterExitCosts.SumTDC == 1)
  8384. {
  8385. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8386. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8387. }
  8388. dic.Add("InTravelPrice", $"({outsideAir})");
  8389. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8390. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8391. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8392. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8393. foreach (var key in dic.Keys)
  8394. {
  8395. builder.MoveToBookmark(key);
  8396. builder.Write(dic[key]);
  8397. }
  8398. //模板文件名
  8399. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8400. strFileName = CommonFun.ValidFileName(strFileName);
  8401. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8402. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8403. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8404. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8405. }
  8406. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8407. {
  8408. //获取模板
  8409. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8410. //载入模板
  8411. WorkbookDesigner designer = new WorkbookDesigner();
  8412. designer.Workbook = new Workbook(tempPath);
  8413. Dictionary<string, string> dic = new Dictionary<string, string>();
  8414. string returnCodeLabel = string.Empty;
  8415. if (nationalTravelFeeData.Any())
  8416. {
  8417. List<string> list = new List<string>();
  8418. foreach (var item in nationalTravelFeeData)
  8419. {
  8420. list.Add($"{item.Country}({item.City})");
  8421. }
  8422. list = list.Distinct().ToList();
  8423. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8424. }
  8425. var countryLabel = string.Empty;
  8426. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8427. if (countryData.Any())
  8428. {
  8429. countryLabel = string.Join("、", countryData);
  8430. }
  8431. dic.Add("ReturnCodeAir", returnCodeLabel);
  8432. dic.Add("VisitStartDate", "-");
  8433. dic.Add("VisitEndDate", "-");
  8434. dic.Add("Day", "0");
  8435. dic.Add("VisitCountry", countryLabel);
  8436. dic.Add("ClientUnit", "-");
  8437. designer.SetDataSource("ClientUnit", "-");
  8438. designer.SetDataSource("VisitCountry", countryLabel);
  8439. designer.SetDataSource("Group", "-");
  8440. designer.SetDataSource("ClientUnitTitle", "-");
  8441. designer.SetDataSource("Name", "-");
  8442. designer.SetDataSource("VisitStartDate", "-");
  8443. designer.SetDataSource("Day", "0");
  8444. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8445. designer.SetDataSource("ReturnCodeAir", "-");
  8446. int startIndex = 10;
  8447. const int startIndexcopy = 10;
  8448. if (dac2.Count == dac3.Count)//国家 币种 金额
  8449. {
  8450. for (int i = 0; i < dac2.Count; i++)
  8451. {
  8452. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8453. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8454. }
  8455. }
  8456. DataTable dtdac1 = new DataTable();
  8457. List<string> place = new List<string>();
  8458. dtdac1.Columns.AddRange(new DataColumn[] {
  8459. new DataColumn(){ ColumnName = "city"},
  8460. new DataColumn(){ ColumnName = "curr"},
  8461. new DataColumn(){ ColumnName = "criterion"},
  8462. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8463. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8464. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8465. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8466. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8467. });
  8468. DataTable dtdac2 = new DataTable();
  8469. dtdac2.Columns.AddRange(new DataColumn[] {
  8470. new DataColumn(){ ColumnName = "city"},
  8471. new DataColumn(){ ColumnName = "curr"},
  8472. new DataColumn(){ ColumnName = "criterion"},
  8473. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8474. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8475. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8476. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8477. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8478. });
  8479. dtdac1.TableName = "tb1";
  8480. dtdac2.TableName = "tb2";
  8481. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8482. foreach (var item in dac1)
  8483. {
  8484. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8485. if (place.Contains(item.Place))
  8486. {
  8487. continue;
  8488. }
  8489. DataRow row = dtdac1.NewRow();
  8490. row["city"] = item.Place;
  8491. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8492. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8493. row["curr"] = currency;
  8494. row["rate"] = rate.ToString("#0.0000");
  8495. row["criterion"] = item.Cost.ToString("#0.00");
  8496. row["number"] = 1;
  8497. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8498. //row["costRMB"] = rbmPrice;
  8499. dtdac1.Rows.Add(row);
  8500. place.Add(item.Place);
  8501. }
  8502. place = new List<string>();
  8503. foreach (var item in dac2)
  8504. {
  8505. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8506. if (place.Contains(item.Place))
  8507. {
  8508. continue;
  8509. }
  8510. DataRow row = dtdac2.NewRow();
  8511. row["city"] = item.Place;
  8512. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8513. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8514. row["curr"] = currency;
  8515. row["rate"] = rate.ToString("#0.0000");
  8516. row["criterion"] = item.Cost.ToString("#0.00");
  8517. row["number"] = 1;
  8518. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8519. //row["cost"] = item.SubTotal;
  8520. //row["costRMB"] = rbmPrice;
  8521. dtdac2.Rows.Add(row);
  8522. place.Add(item.Place);
  8523. //dac2totalPrice += rbmPrice;
  8524. }
  8525. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8526. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8527. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8528. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8529. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8530. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8531. string cell4Str1 = string.Empty;
  8532. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8533. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8534. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8535. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8536. string cellStr = $" 5.其他费用(";
  8537. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8538. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8539. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8540. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8541. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8542. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8543. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8544. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8545. foreach (var otherInfo in dac5)
  8546. {
  8547. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8548. }
  8549. #endregion
  8550. if (cellStr.Length > 8)
  8551. {
  8552. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8553. }
  8554. cellStr += ")";
  8555. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8556. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8557. decimal pxFee = dac4.Sum(it => it.Cost);
  8558. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8559. string celllastStr1 = "";
  8560. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8561. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8562. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8563. celllastStr1 += $",国际旅费 元";
  8564. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8565. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8566. designer.SetDataSource("cell4Str", cell4Str);
  8567. designer.SetDataSource("cellStr", cellStr);
  8568. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8569. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8570. designer.SetDataSource("celllastStr", celllastStr);
  8571. Workbook wb = designer.Workbook;
  8572. var sheet = wb.Worksheets[0];
  8573. //绑定datatable数据集
  8574. designer.SetDataSource(dtdac1);
  8575. designer.SetDataSource(dtdac2);
  8576. designer.Process();
  8577. var rowStart = dtdac1.Rows.Count;
  8578. while (rowStart > 0)
  8579. {
  8580. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8581. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8582. startIndex++;
  8583. rowStart--;
  8584. }
  8585. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8586. startIndex += 1; //总计行
  8587. rowStart = dtdac2.Rows.Count;
  8588. while (rowStart > 0)
  8589. {
  8590. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8591. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8592. startIndex++;
  8593. rowStart--;
  8594. }
  8595. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8596. wb.CalculateFormula(true);
  8597. //模板文件名
  8598. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8599. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8600. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8601. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8602. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8603. }
  8604. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8605. {
  8606. //获取模板
  8607. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8608. //载入模板
  8609. Document doc = new Document(tempPath);
  8610. DocumentBuilder builder = new DocumentBuilder(doc);
  8611. Dictionary<string, string> dic = new Dictionary<string, string>();
  8612. dic.Add("GroupName", "-");
  8613. dic.Add("ClientUnit", "-");
  8614. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8615. //string missionLeaderJob = "";//负责人job
  8616. //int groupNumber = 0; //团人数
  8617. dic.Add("MissionLeader", "-"); //团负责人
  8618. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8619. dic.Add("GroupNumber", "0"); //团人数
  8620. dic.Add("Day", "0");
  8621. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8622. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8623. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8624. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8625. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8626. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8627. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8628. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8629. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8630. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8631. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8632. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8633. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8634. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8635. //其他费用
  8636. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8637. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8638. //其他费用合计
  8639. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8640. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8641. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8642. //公务舱合计
  8643. //国际旅费
  8644. //string outsideJJ = "";
  8645. //string allPriceJJ = "";
  8646. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8647. {
  8648. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8649. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8650. }
  8651. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8652. {
  8653. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8654. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8655. }
  8656. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8657. {
  8658. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8659. dic.Add("AirFeeTotal", airFeeTotalStr);
  8660. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8661. dic.Add("FeeTotal", feeTotalStr);
  8662. }
  8663. foreach (var key in dic.Keys)
  8664. {
  8665. builder.MoveToBookmark(key);
  8666. builder.Write(dic[key]);
  8667. }
  8668. //模板文件名
  8669. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8670. strFileName = CommonFun.ValidFileName(strFileName);
  8671. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8672. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8673. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8674. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8675. }
  8676. }
  8677. else if (dto.ExportType == 2) //表格
  8678. {
  8679. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8680. }
  8681. else if (dto.ExportType == 3)
  8682. {
  8683. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8684. }
  8685. return Ok(JsonView(400, "只可导出明细表!", ""));
  8686. }
  8687. catch (Exception ex)
  8688. {
  8689. return Ok(JsonView(400, ex.Message, ""));
  8690. }
  8691. }
  8692. /// <summary>
  8693. /// 获取三公费用标准city
  8694. /// </summary>
  8695. /// <param name="placeData"></param>
  8696. /// <param name="nationalTravelFeeId"></param>
  8697. /// <returns></returns>
  8698. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8699. {
  8700. string _city = string.Empty;
  8701. if (!placeData.Any()) return _city;
  8702. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8703. if (data == null) return _city;
  8704. string country = data.Country;
  8705. string city = data.City;
  8706. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8707. else _city = city;
  8708. return _city;
  8709. }
  8710. /// <summary>
  8711. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8712. /// </summary>
  8713. /// <returns></returns>
  8714. [HttpPost]
  8715. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8717. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8718. {
  8719. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8720. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8721. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8722. if (_view.Code == 0)
  8723. {
  8724. return Ok(JsonView(true, "操作成功"));
  8725. }
  8726. return Ok(JsonView(false, "操作失败"));
  8727. }
  8728. /// <summary>
  8729. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8730. /// </summary>
  8731. /// <returns></returns>
  8732. [HttpPost]
  8733. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8735. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8736. {
  8737. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8738. if (data.Code != 0)
  8739. {
  8740. return Ok(JsonView(false, data.Msg));
  8741. }
  8742. return Ok(JsonView(true, "操作成功!", data.Data));
  8743. }
  8744. /// <summary>
  8745. /// 三公其他费用草稿 删除
  8746. /// </summary>
  8747. /// <param name="dto"></param>
  8748. /// <returns></returns>
  8749. [HttpPost]
  8750. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8751. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8752. {
  8753. var jw = JsonView(false, "删除失败!");
  8754. var data = new Grp_DayOtherPriceDraft()
  8755. {
  8756. Id = dto.Id,
  8757. IsDel = 1,
  8758. DeleteUserId = dto.DeleteUserId,
  8759. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8760. };
  8761. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8762. if (del > 0)
  8763. {
  8764. jw.Code = 200;
  8765. jw.Msg = "删除成功!";
  8766. }
  8767. return Ok(jw);
  8768. }
  8769. /// <summary>
  8770. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8771. /// </summary>
  8772. /// <returns></returns>
  8773. [HttpPost]
  8774. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8775. {
  8776. var jw = JsonView(false);
  8777. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8778. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8779. jw.Code = StatusCodes.Status200OK;
  8780. jw.Msg = "操作成功!";
  8781. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8782. return Ok(jw);
  8783. }
  8784. /// <summary>
  8785. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8786. /// </summary>
  8787. /// <param name="dto"></param>
  8788. /// <returns></returns>
  8789. [HttpPost]
  8790. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8791. {
  8792. int userId = dto.UserId,
  8793. portId = dto.PortType,
  8794. groupId = dto.GroupId,
  8795. draftId = dto.DraftId;
  8796. _portTypeData.Add(1);
  8797. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8798. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8799. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8800. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8801. _sqlSugar.BeginTran();
  8802. try
  8803. {
  8804. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8805. if (draftDatas == null)
  8806. {
  8807. _sqlSugar.RollbackTran();
  8808. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8809. }
  8810. //验证可覆盖已有数据 两边创建人需为同一人;
  8811. int draftCreateUserId = draftDatas.CreateUserId,
  8812. formalCreateUserId = 0;
  8813. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8814. if (formalData != null)
  8815. {
  8816. formalCreateUserId = formalData.CreateUserId;
  8817. if (draftCreateUserId != formalCreateUserId)
  8818. {
  8819. _sqlSugar.RollbackTran();
  8820. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8821. }
  8822. }
  8823. //默认添加查看、编辑权限(创建人、自己)
  8824. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8825. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8826. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8827. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8828. newExterData.DiId = groupId;
  8829. newExterData.CreateUserId = userId;
  8830. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8831. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8832. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8833. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8834. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8835. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8836. //数据如果存在执行删除
  8837. if (enterExitCostInfo != null)
  8838. {
  8839. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8840. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8841. .Where(x => x.Id == enterExitCostInfo.Id)
  8842. .ExecuteCommand();
  8843. _sqlSugar.Updateable<Grp_DayAndCost>()
  8844. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8845. .Where(x => x.DiId == groupId)
  8846. .ExecuteCommand();
  8847. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8848. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8849. .Where(x => x.Diid == groupId)
  8850. .ExecuteCommand();
  8851. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8852. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8853. .Where(x => x.GroupId == groupId)
  8854. .ExecuteCommand();
  8855. }
  8856. //执行insert
  8857. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8858. if (insertId < 1)
  8859. {
  8860. _sqlSugar.RollbackTran();
  8861. return Ok(JsonView(false, "草稿数据导入失败!"));
  8862. }
  8863. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8864. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8865. #region 默认添加权限
  8866. #endregion
  8867. _sqlSugar.CommitTran();
  8868. //执行操作之后
  8869. //生成默认文件pdf并且通知人员
  8870. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8871. {
  8872. DiId = groupId,
  8873. ExportType = 1,
  8874. SubTypeId = 1005
  8875. }, "pdf");
  8876. //发送通知
  8877. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8878. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8879. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8880. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8881. //汇率信息记录
  8882. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8883. return Ok(JsonView(true));
  8884. }
  8885. catch (Exception ex)
  8886. {
  8887. _sqlSugar.RollbackTran();
  8888. return Ok(JsonView(false, ex.Message));
  8889. }
  8890. }
  8891. #endregion
  8892. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8893. /// <summary>
  8894. /// 获取币种基础数据(含逻辑处理)
  8895. /// </summary>
  8896. /// <returns></returns>
  8897. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8898. {
  8899. return await GeneralMethod.EnterExitCostInitRate();
  8900. }
  8901. /// <summary>
  8902. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8903. /// </summary>
  8904. /// <returns></returns>
  8905. [HttpPost]
  8906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8907. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8908. {
  8909. //验证城市归属并给默认值
  8910. int provinceId = dto.ProvinceId;
  8911. if (provinceId < 1) provinceId = 122;
  8912. var dataSource = await _sqlSugar
  8913. .Queryable<Sys_SetData>()
  8914. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8915. .ToListAsync();
  8916. var fileTypes = new List<EecSetDataInfoView>();
  8917. //三公费用-Word明细类型
  8918. var wordTypeData = dataSource
  8919. .Where(it => it.STid == 72)
  8920. .Select(x => new EecSetDataInfoView
  8921. {
  8922. ParentId = 1,
  8923. Id = x.Id,
  8924. Name = x.Name
  8925. })
  8926. .ToArray();
  8927. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8928. var excelTypeData = dataSource
  8929. .Where(it => it.STid == 73)
  8930. .Select(x => new EecSetDataInfoView
  8931. {
  8932. ParentId = 2,
  8933. Id = x.Id,
  8934. Name = x.Name
  8935. })
  8936. .ToArray();
  8937. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8938. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8939. fileTypes.Add(groupNameList);
  8940. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8941. //默认币种显示
  8942. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8943. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8944. return Ok(JsonView(true, "查询成功!", new
  8945. {
  8946. FileTypeData = fileTypes,
  8947. CurrencyInit = _currencyInfos,
  8948. viewPermissionData = viewPermissionData
  8949. }));
  8950. }
  8951. /// <summary>
  8952. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8953. /// </summary>
  8954. /// <returns></returns>
  8955. [HttpPost]
  8956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8957. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8958. {
  8959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8960. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8961. RefAsync<int> total = 0;
  8962. int diId = 0;
  8963. var status = int.TryParse(dto.GroupName, out diId);
  8964. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8965. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8966. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8967. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8968. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8969. .OrderByDescending(x => x.VisitStartDate)
  8970. .Select(x => new EnterExitCostMobileGroupView()
  8971. {
  8972. Id = x.Id,
  8973. GroupName = x.TeamName,
  8974. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8975. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8976. ProvinceId = x.CityId
  8977. })
  8978. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8979. //处理省份Id
  8980. if (data.Any())
  8981. {
  8982. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8983. if (provCityDatas.Any())
  8984. {
  8985. foreach (var item in data)
  8986. {
  8987. var provinceId = item.ProvinceId;
  8988. var isDefualtVal = true;
  8989. if (provinceId > 0)
  8990. {
  8991. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8992. if (parentId != null)
  8993. {
  8994. isDefualtVal = false;
  8995. item.ProvinceId = (int)parentId;
  8996. }
  8997. }
  8998. if (isDefualtVal)
  8999. {
  9000. item.ProvinceId = 122; //默认四川
  9001. }
  9002. }
  9003. }
  9004. }
  9005. //处理是否显示
  9006. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9007. {
  9008. foreach (var item in data)
  9009. {
  9010. item.IsView = true;
  9011. }
  9012. }
  9013. return Ok(JsonView(true, "查询成功!", data, total));
  9014. }
  9015. /// <summary>
  9016. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9017. /// </summary>
  9018. /// <returns></returns>
  9019. [HttpPost]
  9020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9021. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9022. {
  9023. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9024. RefAsync<int> total = 0;
  9025. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9026. .Where(x => x.IsDel == 0 && x.STid == 66)
  9027. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9028. .Select(x => new
  9029. {
  9030. id = x.Id,
  9031. name = x.Name,
  9032. remark = x.Remark,
  9033. })
  9034. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9035. return Ok(JsonView(true, "查询成功!", data, total));
  9036. }
  9037. /// <summary>
  9038. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9039. /// </summary>
  9040. /// <returns></returns>
  9041. [HttpPost]
  9042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9043. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9044. {
  9045. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9046. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9047. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9048. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9049. var groupOtherRateData = groupRateData.TeamRates;
  9050. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9051. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9052. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9053. groupOtherRateData = groupOtherRateData
  9054. .Select(x => new TeamRateDescAddCurrencyIdView
  9055. {
  9056. CurrencyId = x.CurrencyId,
  9057. CurrencyName = x.CurrencyName,
  9058. CurrencyCode = x.CurrencyCode,
  9059. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9060. }).ToList();
  9061. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9062. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9063. }
  9064. /// <summary>
  9065. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9066. /// </summary>
  9067. /// <returns></returns>
  9068. [HttpPost]
  9069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9070. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9071. {
  9072. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9073. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9074. var tipsData = new List<int>() { 1, 2, 3 };
  9075. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9076. if (dto.TipsType == 1)
  9077. {
  9078. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9079. }
  9080. else if (dto.TipsType == 2)
  9081. {
  9082. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9083. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9084. }
  9085. else if (dto.TipsType == 3)
  9086. {
  9087. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  9088. return Ok(JsonView(true, "查询成功!", airData.Data));
  9089. }
  9090. return Ok(JsonView(false));
  9091. }
  9092. /// <summary>
  9093. /// 团组模块 - 出入境国家费用标准-移动端 List
  9094. /// </summary>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9098. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9099. {
  9100. Stopwatch sw = new Stopwatch();
  9101. sw.Start();
  9102. int provinceId = dto.ProvinceId;
  9103. if (provinceId < 1) provinceId = 122; // 默认四川
  9104. RefAsync<int> total = 0;
  9105. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9106. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9107. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9108. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9109. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9110. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9111. .Select((ntf, sd, u, sd1) => new
  9112. {
  9113. Id = ntf.Id,
  9114. Area = $"{ntf.Country}-{ntf.City}",
  9115. Currency = ntf.Currency,
  9116. CurrencyCode = sd.Name,
  9117. CurrencyName = sd.Remark,
  9118. RoomCost = ntf.RoomCost,
  9119. FoodCost = ntf.FoodCost,
  9120. PublicCost = ntf.PublicCost,
  9121. TrainCost = ntf.TrainCost,
  9122. LastUpdateUserId = ntf.LastUpdateUserId,
  9123. LastUpdateUserName = u.CnName,
  9124. LastUpdateTime = ntf.LastUpdateTime
  9125. })
  9126. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9127. sw.Stop();
  9128. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9129. }
  9130. /// <summary>
  9131. /// 团组模块 - 出入境费用-移动端 - Info
  9132. /// </summary>
  9133. /// <returns></returns>
  9134. [HttpPost]
  9135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9136. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9137. {
  9138. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9139. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9140. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9141. return Ok(data);
  9142. }
  9143. /// <summary>
  9144. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9145. /// </summary>
  9146. /// <returns></returns>
  9147. [HttpPost]
  9148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9149. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9150. {
  9151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9152. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9153. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9154. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9155. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9156. mobileInfo.DiId = dto.DiId;
  9157. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9158. if (eecInfo == null) return Ok(mobileInfo);
  9159. //验证查看权限
  9160. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9161. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9162. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9163. mobileInfo.IsAssignPerm = isSet;
  9164. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9165. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9166. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9167. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9168. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9169. {
  9170. SubId = dac.Id,
  9171. DiId = dac.DiId,
  9172. Type = dac.Type,
  9173. Days = dac.Days,
  9174. NationalTravelFeeId = dac.NationalTravelFeeId,
  9175. Arae = $"{ntf.Country}-{ntf.City}",
  9176. Cost = dac.Cost,
  9177. Currency = dac.Currency,
  9178. CurrencyName = sd.Name,
  9179. SubTotal = dac.SubTotal,
  9180. })
  9181. .ToList();
  9182. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9183. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9184. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9185. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9186. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9187. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9188. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9189. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9190. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9191. //其他款项
  9192. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9193. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9194. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9195. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9196. .OrderBy((dop, sd1, sd2) => dop.Index)
  9197. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9198. {
  9199. SubId = dop.Id,
  9200. DiId = dop.Diid,
  9201. Index = dop.Index,
  9202. SetDataId = dop.SetDataId,
  9203. SetDataName = sd1.Name,
  9204. Cost = dop.Cost,
  9205. Currency = dop.Currency,
  9206. CurrencyName = sd2.Remark,
  9207. SubTotal = dop.SubTotal,
  9208. Remark = dop.Remark,
  9209. })
  9210. .ToArray();
  9211. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9212. return Ok(mobileInfo);
  9213. }
  9214. /// <summary>
  9215. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9216. /// </summary>
  9217. /// <returns></returns>
  9218. [HttpPost]
  9219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9220. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9221. {
  9222. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9223. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9224. //验证查看权限
  9225. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9226. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9227. var userIds = await _sqlSugar
  9228. .Queryable<Grp_EnterExitCostPermission>()
  9229. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9230. .Select(x => x.UserId)
  9231. .ToArrayAsync();
  9232. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9233. var perUsersView = new List<dynamic>();
  9234. foreach (var item in perUsers)
  9235. {
  9236. bool isView1 = false;
  9237. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9238. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9239. }
  9240. return Ok(JsonView(perUsersView));
  9241. }
  9242. /// <summary>
  9243. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9244. /// </summary>
  9245. /// <returns></returns>
  9246. [HttpPost]
  9247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9248. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9249. {
  9250. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9251. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9252. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9253. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9254. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9255. //验证查看权限
  9256. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9257. //if (!isView) return Ok(JsonView(false, msg));
  9258. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9259. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9260. var subType = dto.SubType;
  9261. if (subType == 1) //1:境内费用
  9262. {
  9263. var oneData = new ChoiceOneMobileSubInfoView()
  9264. {
  9265. Id = eecInfo.Id,
  9266. ChoiceOne = eecInfo.ChoiceOne,
  9267. ChoiceOneTotalCost = eecInfo.InsidePay,
  9268. Visa = eecInfo.Visa,
  9269. VisaRemark = eecInfo.VisaRemark,
  9270. YiMiao = eecInfo.YiMiao,
  9271. HeSuan = eecInfo.HeSuan,
  9272. Service = eecInfo.Service,
  9273. Ticket = eecInfo.Ticket,
  9274. Safe = eecInfo.Safe,
  9275. FirstItemRemark = eecInfo.FirstItemRemark
  9276. };
  9277. return Ok(JsonView(oneData));
  9278. }
  9279. else if (subType == 2) //2:国际旅费
  9280. {
  9281. var twoData = new ChoiceTwoMobileSubInfoView()
  9282. {
  9283. Id = eecInfo.Id,
  9284. ChoiceTwoJJ = eecInfo.SumJJC,
  9285. OutsideJJPay = eecInfo.OutsideJJPay,
  9286. ChoiceTwoGW = eecInfo.SumGWC,
  9287. OutsideGWPay = eecInfo.OutsideGWPay,
  9288. ChoiceTwoTD = eecInfo.SumTDC,
  9289. OutsideTDPay = eecInfo.OutsideTDPay,
  9290. AirJJ = eecInfo.AirJJ,
  9291. AirGW = eecInfo.AirGW,
  9292. AirTD = eecInfo.AirTD,
  9293. CityTranffic = eecInfo.CityTranffic,
  9294. TwoItemRemark = eecInfo.TwoItemRemark
  9295. };
  9296. return Ok(JsonView(twoData));
  9297. }
  9298. else if (subType == 3) //3:住宿费
  9299. {
  9300. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9301. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9302. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9303. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9304. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9305. {
  9306. SubId = dac.Id,
  9307. DiId = dac.DiId,
  9308. Type = dac.Type,
  9309. Days = dac.Days,
  9310. NationalTravelFeeId = dac.NationalTravelFeeId,
  9311. Arae = $"{ntf.Country}-{ntf.City}",
  9312. Cost = dac.Cost,
  9313. Currency = dac.Currency,
  9314. CurrencyName = sd.Name,
  9315. SubTotal = dac.SubTotal,
  9316. })
  9317. .ToArray();
  9318. var data = new ChoiceMobileSubInfo3To6View()
  9319. {
  9320. ParentId = eecInfo.Id,
  9321. Choice = eecInfo.ChoiceThree,
  9322. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9323. Details = dayAndCostDatas
  9324. };
  9325. return Ok(JsonView(data));
  9326. }
  9327. else if (subType == 4) //4:伙食费
  9328. {
  9329. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9330. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9331. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9332. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9333. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9334. {
  9335. SubId = dac.Id,
  9336. DiId = dac.DiId,
  9337. Type = dac.Type,
  9338. Days = dac.Days,
  9339. NationalTravelFeeId = dac.NationalTravelFeeId,
  9340. Arae = $"{ntf.Country}-{ntf.City}",
  9341. Cost = dac.Cost,
  9342. Currency = dac.Currency,
  9343. CurrencyName = sd.Name,
  9344. SubTotal = dac.SubTotal,
  9345. })
  9346. .ToArray();
  9347. var data = new ChoiceMobileSubInfo3To6View()
  9348. {
  9349. ParentId = eecInfo.Id,
  9350. Choice = eecInfo.ChoiceFour,
  9351. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9352. Details = dayAndCostDatas
  9353. };
  9354. return Ok(JsonView(data));
  9355. }
  9356. else if (subType == 5) //5:公杂费
  9357. {
  9358. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9359. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9360. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9361. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9362. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9363. {
  9364. SubId = dac.Id,
  9365. DiId = dac.DiId,
  9366. Type = dac.Type,
  9367. Days = dac.Days,
  9368. NationalTravelFeeId = dac.NationalTravelFeeId,
  9369. Arae = $"{ntf.Country}-{ntf.City}",
  9370. Cost = dac.Cost,
  9371. Currency = dac.Currency,
  9372. CurrencyName = sd.Name,
  9373. SubTotal = dac.SubTotal,
  9374. })
  9375. .ToArray();
  9376. var data = new ChoiceMobileSubInfo3To6View()
  9377. {
  9378. ParentId = eecInfo.Id,
  9379. Choice = eecInfo.ChoiceFive,
  9380. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9381. Details = dayAndCostDatas
  9382. };
  9383. return Ok(JsonView(data));
  9384. }
  9385. else if (subType == 6) //6:培训费
  9386. {
  9387. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9388. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9389. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9390. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9391. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9392. {
  9393. SubId = dac.Id,
  9394. DiId = dac.DiId,
  9395. Type = dac.Type,
  9396. Days = dac.Days,
  9397. NationalTravelFeeId = dac.NationalTravelFeeId,
  9398. Arae = $"{ntf.Country}-{ntf.City}",
  9399. Cost = dac.Cost,
  9400. Currency = dac.Currency,
  9401. CurrencyName = sd.Name,
  9402. SubTotal = dac.SubTotal,
  9403. })
  9404. .ToArray();
  9405. var data = new ChoiceMobileSubInfo3To6View()
  9406. {
  9407. ParentId = eecInfo.Id,
  9408. Choice = eecInfo.ChoiceSix,
  9409. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9410. Details = dayAndCostDatas
  9411. };
  9412. return Ok(JsonView(data));
  9413. }
  9414. else if (subType == 7) //7:其他
  9415. {
  9416. //其他款项
  9417. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9418. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9419. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9420. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9421. .OrderBy((dop, sd1, sd2) => dop.Index)
  9422. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9423. {
  9424. SubId = dop.Id,
  9425. DiId = dop.Diid,
  9426. Index = dop.Index,
  9427. SetDataId = dop.SetDataId,
  9428. SetDataName = sd1.Name,
  9429. Cost = dop.Cost,
  9430. Currency = dop.Currency,
  9431. CurrencyName = sd2.Name,
  9432. SubTotal = dop.SubTotal,
  9433. Remark = dop.Remark,
  9434. })
  9435. .ToArray();
  9436. var data = new ChoiceSevenMobileSubInfoView()
  9437. {
  9438. ParentId = eecInfo.Id,
  9439. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9440. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9441. Details = otherData
  9442. };
  9443. return Ok(JsonView(data));
  9444. }
  9445. return Ok(JsonView(false));
  9446. }
  9447. #region op
  9448. /// <summary>
  9449. /// 移动端更新费用消息通知
  9450. /// </summary>
  9451. /// <param name="diid"></param>
  9452. /// <param name="id"></param>
  9453. /// <param name="currUserId"></param>
  9454. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9455. {
  9456. try
  9457. {
  9458. ////生成默认文件pdf并且通知人员
  9459. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9460. //{
  9461. // DiId = diid,
  9462. // ExportType = 1,
  9463. // SubTypeId = 1005
  9464. //}, "pdf");
  9465. ////发送通知
  9466. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9467. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9468. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9469. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9470. ////汇率信息记录
  9471. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9472. }
  9473. catch (Exception ex)
  9474. {
  9475. //记录日志
  9476. throw;
  9477. }
  9478. }
  9479. /// <summary>
  9480. /// 验证出入境费用数据是否存在
  9481. /// 不存在添加
  9482. /// </summary>
  9483. /// <param name="diId"></param>
  9484. /// <param name="currUserId"></param>
  9485. /// <returns></returns>
  9486. /// <exception cref="CustomException"></exception>
  9487. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9488. {
  9489. var parentId = 0;
  9490. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9491. if (info != null)
  9492. {
  9493. parentId = info.Id;
  9494. }
  9495. else
  9496. {
  9497. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9498. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9499. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9500. parentId = addId;
  9501. }
  9502. return parentId;
  9503. }
  9504. /// <summary>
  9505. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9506. /// </summary>
  9507. /// <returns></returns>
  9508. [HttpPost]
  9509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9510. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9511. {
  9512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9513. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9514. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9515. //验证编辑权限
  9516. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9517. //if (!isEdit) return Ok(JsonView(false, msg));
  9518. var permissions = new List<Grp_EnterExitCostPermission>();
  9519. foreach (var userId in dto.UserIds)
  9520. {
  9521. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9522. }
  9523. if (permissions.Any())
  9524. {
  9525. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9526. {
  9527. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9528. }
  9529. _sqlSugar.BeginTran();
  9530. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9531. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9532. if (result < 1)
  9533. {
  9534. _sqlSugar.RollbackTran();
  9535. return Ok(JsonView(false));
  9536. }
  9537. _sqlSugar.CommitTran();
  9538. return Ok(JsonView(true));
  9539. }
  9540. return Ok(JsonView(false));
  9541. }
  9542. /// <summary>
  9543. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9544. /// </summary>
  9545. /// <returns></returns>
  9546. [HttpPost]
  9547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9548. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9549. {
  9550. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9551. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9552. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9553. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9554. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9555. int id = dto.Id;
  9556. if (id <= 0) //add
  9557. {
  9558. //int provinceId = dto.ProvinceId;
  9559. int groupId = dto.DiId;
  9560. //if (provinceId < 1) provinceId = 122;
  9561. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9562. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9563. if (add < 1) return Ok(JsonView(false));
  9564. id = add;
  9565. }
  9566. else //update
  9567. {
  9568. ////验证编辑权限
  9569. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9570. //if (!isEdit) return Ok(JsonView(false, msg));
  9571. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9572. if (upd < 1) return Ok(JsonView(false));
  9573. }
  9574. #region 汇率变更时更改币种相关费用
  9575. var opDayCosts = new List<Grp_DayAndCost>();
  9576. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9577. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9578. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9579. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9580. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9581. .Select((dac, sd) => new
  9582. {
  9583. dac.Id,
  9584. dac.DiId,
  9585. CurrencyCode = sd.Name,
  9586. dac.Cost
  9587. })
  9588. .ToList();
  9589. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9590. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9591. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9592. .Select((dop, sd) => new
  9593. {
  9594. dop.Id,
  9595. dop.Diid,
  9596. CurrencyCode = sd.Name,
  9597. dop.Cost
  9598. })
  9599. .ToList();
  9600. if (dayCosts.Count > 0)
  9601. {
  9602. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9603. foreach (var dc in new_dayCosts)
  9604. {
  9605. var thisCurrency = dc.Key.ToUpper();
  9606. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9607. if (thisRate == 0.00M) continue;
  9608. foreach (var dcSub in dc)
  9609. {
  9610. opDayCosts.Add(new Grp_DayAndCost()
  9611. {
  9612. Id = dcSub.Id,
  9613. DiId = dcSub.DiId,
  9614. Cost = dcSub.Cost,
  9615. SubTotal = dcSub.Cost * thisRate,
  9616. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9617. });
  9618. }
  9619. }
  9620. if (opDayCosts.Count > 0)
  9621. {
  9622. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9623. }
  9624. }
  9625. if (dayOtherCosts.Count > 0)
  9626. {
  9627. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9628. foreach (var dc in new_dayOtherCosts)
  9629. {
  9630. var thisCurrency = dc.Key.ToUpper();
  9631. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9632. if (thisRate == 0.00M) continue;
  9633. foreach (var dcSub in dc)
  9634. {
  9635. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9636. {
  9637. Id = dcSub.Id,
  9638. Diid = dcSub.Diid,
  9639. Cost = dcSub.Cost,
  9640. SubTotal = dcSub.Cost * thisRate,
  9641. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9642. });
  9643. }
  9644. }
  9645. if (opDayOtherCosts.Count > 0)
  9646. {
  9647. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9648. }
  9649. }
  9650. #endregion
  9651. //消息通知
  9652. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9653. //汇率信息记录
  9654. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9655. return Ok(JsonView(new { parentId = id }));
  9656. }
  9657. /// <summary>
  9658. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9659. /// </summary>
  9660. /// <returns></returns>
  9661. [HttpPost]
  9662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9663. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9664. {
  9665. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9666. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9667. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9668. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9669. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9670. int id = dto.Id;
  9671. if (id <= 0) //add
  9672. {
  9673. checkboxInfo.CreateUserId = dto.CurrUserId;
  9674. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9675. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9676. if (add < 1) return Ok(JsonView(false));
  9677. }
  9678. else //update
  9679. {
  9680. ////验证编辑权限
  9681. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9682. //if (!isEdit) return Ok(JsonView(false, msg));
  9683. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9684. .UpdateColumns(x => new
  9685. {
  9686. x.ChoiceOne,
  9687. x.ChoiceTwo,
  9688. x.SumJJC,
  9689. x.SumGWC,
  9690. x.SumTDC,
  9691. x.ChoiceThree,
  9692. x.ChoiceFour,
  9693. x.ChoiceFive,
  9694. x.ChoiceSix,
  9695. x.OtherExpenses_Checked
  9696. })
  9697. .Where(x => x.Id == id)
  9698. .ExecuteCommandAsync();
  9699. if (upd < 1) return Ok(JsonView(false));
  9700. }
  9701. return Ok(JsonView(new { parentId = id }));
  9702. }
  9703. /// <summary>
  9704. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9705. /// </summary>
  9706. /// <returns></returns>
  9707. [HttpPost]
  9708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9709. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9710. {
  9711. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9712. // if (provinceId < 1) provinceId = 122;
  9713. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9714. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9715. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9716. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9717. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9718. var checkboxInfo = new Grp_EnterExitCost()
  9719. {
  9720. Id = id,
  9721. //ProvinceId = provinceId,
  9722. DiId = diId,
  9723. CreateUserId = currUserId
  9724. };
  9725. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9726. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9727. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9728. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9729. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9730. if (id <= 0) //add
  9731. {
  9732. checkboxInfo.CreateUserId = dto.CurrUserId;
  9733. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9734. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9735. if (add < 1) return Ok(JsonView(false));
  9736. }
  9737. else //update
  9738. {
  9739. ////验证编辑权限
  9740. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9741. //if (!isEdit) return Ok(JsonView(false, msg));
  9742. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9743. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9744. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9745. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9746. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9747. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9748. .Where(x => x.Id == id)
  9749. .ExecuteCommandAsync();
  9750. if (upd < 1) return Ok(JsonView(false));
  9751. }
  9752. return Ok(JsonView(new { parentId = id }));
  9753. }
  9754. /// <summary>
  9755. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9756. /// </summary>
  9757. /// <returns></returns>
  9758. [HttpPost]
  9759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9760. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9761. {
  9762. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9763. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9764. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9765. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9766. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9767. info.FirstItemRemark = dto.FirstItemRemark;
  9768. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9769. int id = dto.Id;
  9770. if (id <= 0) //add
  9771. {
  9772. info.CreateUserId = dto.CurrUserId;
  9773. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9774. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9775. if (add < 1) return Ok(JsonView(false));
  9776. id = add;
  9777. }
  9778. else //update
  9779. {
  9780. ////验证编辑权限
  9781. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9782. //if (!isEdit) return Ok(JsonView(false, msg));
  9783. var upd = await _sqlSugar.Updateable(info)
  9784. .UpdateColumns(x => new
  9785. {
  9786. x.ChoiceOne,
  9787. x.InsidePay,
  9788. x.VisaRemark,
  9789. x.Visa,
  9790. x.Service,
  9791. x.Safe,
  9792. x.Ticket,
  9793. x.HeSuan,
  9794. x.YiMiao,
  9795. x.FirstItemRemark
  9796. })
  9797. .Where(x => x.Id == id)
  9798. .ExecuteCommandAsync();
  9799. if (upd < 1) return Ok(JsonView(false));
  9800. }
  9801. //消息通知
  9802. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9803. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9804. }
  9805. /// <summary>
  9806. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9807. /// </summary>
  9808. /// <returns></returns>
  9809. [HttpPost]
  9810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9811. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9812. {
  9813. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9814. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9815. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9816. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9817. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9818. info.DiId = dto.DiId;
  9819. //info.ProvinceId = dto.ProvinceId;
  9820. info.OutsideJJPay = dto.OutsideJJPay;
  9821. info.OutsideGWPay = dto.OutsideGWPay;
  9822. info.OutsideTDPay = dto.OutsideTDPay;
  9823. info.AirJJ = dto.AirJJ;
  9824. info.AirGW = dto.AirGW;
  9825. info.AirTD = dto.AirTD;
  9826. info.CityTranffic = dto.CityTranffic;
  9827. info.TwoItemRemark = dto.TwoItemRemark;
  9828. info.SumJJC = dto.ChoiceTwoJJ;
  9829. info.SumGWC = dto.ChoiceTwoGW;
  9830. info.SumTDC = dto.ChoiceTwoTD;
  9831. int id = dto.Id;
  9832. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9833. if (id <= 0) //add
  9834. {
  9835. info.CreateUserId = dto.CurrUserId;
  9836. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9837. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9838. if (addId <= 0) return Ok(JsonView(false));
  9839. id = addId;
  9840. }
  9841. else //update
  9842. {
  9843. ////验证编辑权限
  9844. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9845. //if (!isEdit) return Ok(JsonView(false, msg));
  9846. var upd = await _sqlSugar.Updateable(info)
  9847. .UpdateColumns(x => new
  9848. {
  9849. x.SumJJC,
  9850. x.OutsideJJPay,
  9851. x.SumGWC,
  9852. x.OutsideGWPay,
  9853. x.SumTDC,
  9854. x.OutsideTDPay,
  9855. x.AirJJ,
  9856. x.AirGW,
  9857. x.AirTD,
  9858. x.CityTranffic,
  9859. x.TwoItemRemark
  9860. })
  9861. .Where(x => x.Id == id)
  9862. .ExecuteCommandAsync();
  9863. if (upd < 1) return Ok(JsonView(false));
  9864. }
  9865. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9866. gwcItemTotal = info.AirGW + info.CityTranffic;
  9867. tdcItemTotal = info.AirTD + info.CityTranffic;
  9868. //消息通知
  9869. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9870. return Ok(JsonView(new
  9871. {
  9872. parentId = id,
  9873. choiceTwoJJ = dto.ChoiceTwoJJ,
  9874. jjcItemTotal = jjcItemTotal,
  9875. choiceTwoGW = dto.ChoiceTwoGW,
  9876. gwcItemTotal = gwcItemTotal,
  9877. choiceTwoTD = dto.ChoiceTwoTD,
  9878. tdcItemTotal = tdcItemTotal
  9879. }));
  9880. }
  9881. /// <summary>
  9882. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9883. /// </summary>
  9884. /// <returns></returns>
  9885. [HttpPost]
  9886. [ApiExplorerSettings(IgnoreApi = true)]
  9887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9888. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9889. {
  9890. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9891. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9892. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9893. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9894. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9895. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9896. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9897. var infos = infos1.Select(x => new Grp_DayAndCost
  9898. {
  9899. Id = x.Id,
  9900. DiId = dto.DiId,
  9901. Type = dto.FeeType,
  9902. Days = x.Days,
  9903. NationalTravelFeeId = x.NationalTravelFeeId,
  9904. Cost = x.Cost,
  9905. Currency = x.Currency,
  9906. SubTotal = x.SubTotal,
  9907. CreateUserId = dto.CurrUserId
  9908. })
  9909. .ToList();
  9910. var adds = infos.Where(x => x.Id <= 0).ToList();
  9911. var upds = infos.Where(x => x.Id > 0).ToList();
  9912. if (adds.Count > 0)
  9913. {
  9914. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9915. if (add < 1) return Ok(JsonView(false));
  9916. }
  9917. if (upds.Count > 0)
  9918. {
  9919. var upd = await _sqlSugar.Updateable(adds)
  9920. .UpdateColumns(x => new
  9921. {
  9922. x.Days,
  9923. x.NationalTravelFeeId,
  9924. x.Cost,
  9925. x.Currency,
  9926. x.SubTotal
  9927. })
  9928. .WhereColumns(x => new { x.Id })
  9929. .ExecuteCommandAsync();
  9930. if (upd < 1) return Ok(JsonView(false));
  9931. }
  9932. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9933. //消息通知
  9934. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9935. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9936. return Ok(JsonView(new { itemTotal = itemTotal }));
  9937. }
  9938. /// <summary>
  9939. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9940. /// </summary>
  9941. /// <returns></returns>
  9942. [HttpPost]
  9943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9944. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9945. {
  9946. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9947. int subId = dto.SubId, feeType = dto.FeeType;
  9948. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9949. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9950. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9951. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9952. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9953. subInfo.Id = subId;
  9954. subInfo.DiId = dto.DiId;
  9955. if (feeType == 3) subInfo.Type = 1;
  9956. else if (feeType == 4) subInfo.Type = 2;
  9957. else if (feeType == 5) subInfo.Type = 3;
  9958. else if (feeType == 6) subInfo.Type = 4;
  9959. subInfo.CreateUserId = dto.CurrUserId;
  9960. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9961. if (parentId < 1) return Ok(JsonView(false));
  9962. //子表op
  9963. if (subId < 1)
  9964. {
  9965. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9966. if (subAdd < 1) return Ok(JsonView(false));
  9967. }
  9968. else
  9969. {
  9970. ////验证编辑权限
  9971. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9972. //if (!isEdit) return Ok(JsonView(false, msg));
  9973. var subUpd = await _sqlSugar.Updateable(subInfo)
  9974. .UpdateColumns(x => new
  9975. {
  9976. x.Days,
  9977. x.NationalTravelFeeId,
  9978. x.Cost,
  9979. x.Currency,
  9980. x.SubTotal
  9981. })
  9982. .WhereColumns(x => new { x.Id })
  9983. .ExecuteCommandAsync();
  9984. if (subUpd < 1) return Ok(JsonView(false));
  9985. }
  9986. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9987. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9988. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9989. }
  9990. /// <summary>
  9991. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9992. /// </summary>
  9993. /// <returns></returns>
  9994. [HttpPost]
  9995. [ApiExplorerSettings(IgnoreApi = true)]
  9996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9997. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9998. {
  9999. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10000. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10001. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10002. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10003. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10004. {
  10005. Id = x.Id,
  10006. Diid = dto.DiId,
  10007. SetDataId = x.SetDataId,
  10008. Index = x.Index,
  10009. Cost = x.Cost,
  10010. Currency = x.Currency,
  10011. SubTotal = x.SubTotal,
  10012. CreateUserId = dto.CurrUserId,
  10013. Remark = x.Remark
  10014. }).ToList();
  10015. var adds = infos.Where(x => x.Id <= 0).ToList();
  10016. var upds = infos.Where(x => x.Id > 0).ToList();
  10017. if (adds.Count > 0)
  10018. {
  10019. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10020. if (add < 1) return Ok(JsonView(false));
  10021. }
  10022. if (upds.Count > 0)
  10023. {
  10024. var upd = await _sqlSugar.Updateable(adds)
  10025. .UpdateColumns(x => new
  10026. {
  10027. x.Index,
  10028. x.SetDataId,
  10029. x.Cost,
  10030. x.Currency,
  10031. x.SubTotal,
  10032. x.Remark
  10033. })
  10034. .WhereColumns(x => new { x.Id })
  10035. .ExecuteCommandAsync();
  10036. if (upd < 1) return Ok(JsonView(false));
  10037. }
  10038. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10039. //消息通知
  10040. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10041. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10042. return Ok(JsonView(new { itemTotal = itemTotal }));
  10043. }
  10044. /// <summary>
  10045. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10046. /// </summary>
  10047. /// <returns></returns>
  10048. [HttpPost]
  10049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10050. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10051. {
  10052. int subId = dto.SubId;
  10053. int diId = dto.Diid;
  10054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10055. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10056. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10057. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10058. subInfo.Id = subId;
  10059. subInfo.Diid = dto.Diid;
  10060. subInfo.CreateUserId = dto.CurrUserId;
  10061. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10062. if (parentId < 1) return Ok(JsonView(false));
  10063. #region 子表op
  10064. if (subId < 1)//add
  10065. {
  10066. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10067. if (subAdd < 1) return Ok(JsonView(false));
  10068. }
  10069. else //upd
  10070. {
  10071. ////验证编辑权限
  10072. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10073. //if (!isEdit) return Ok(JsonView(false, msg));
  10074. var subUpd = await _sqlSugar.Updateable(subInfo)
  10075. .UpdateColumns(x => new
  10076. {
  10077. x.Index,
  10078. x.SetDataId,
  10079. x.Cost,
  10080. x.Currency,
  10081. x.SubTotal,
  10082. x.Remark
  10083. })
  10084. .WhereColumns(x => new { x.Id })
  10085. .ExecuteCommandAsync();
  10086. if (subUpd < 1) return Ok(JsonView(false));
  10087. }
  10088. #endregion
  10089. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10090. //消息通知
  10091. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10092. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10093. }
  10094. /// <summary>
  10095. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10096. /// </summary>
  10097. /// <returns></returns>
  10098. [HttpPost]
  10099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10100. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10101. {
  10102. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10103. if (data.Code != 0)
  10104. {
  10105. return Ok(JsonView(false, data.Msg));
  10106. }
  10107. return Ok(JsonView(true, "操作成功!", data.Data));
  10108. }
  10109. /// <summary>
  10110. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10111. /// </summary>
  10112. /// <param name="dto"></param>
  10113. /// <returns></returns>
  10114. [HttpPost]
  10115. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10116. {
  10117. var data = new Grp_DayOtherPrice()
  10118. {
  10119. Id = dto.Id,
  10120. IsDel = 1,
  10121. DeleteUserId = dto.DeleteUserId,
  10122. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10123. };
  10124. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10125. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10126. return Ok(JsonView(false, "删除失败!"));
  10127. }
  10128. #endregion
  10129. #endregion
  10130. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10131. /// <summary>
  10132. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10133. /// </summary>
  10134. /// <returns></returns>
  10135. [HttpGet]
  10136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10137. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10138. {
  10139. var provData = await _groupRepository.ProvinceBasicSource();
  10140. return Ok(JsonView(true, "查询成功!", provData));
  10141. }
  10142. /// <summary>
  10143. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10144. /// </summary>
  10145. /// <returns></returns>
  10146. [HttpPost]
  10147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10148. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10149. {
  10150. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10151. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10152. RefAsync<int> total = 0;
  10153. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10154. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10155. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10156. .Select(x => new
  10157. {
  10158. Id = x.Id,
  10159. DraftName = x.DraftName,
  10160. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10161. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10162. .Any()
  10163. })
  10164. .OrderByDescending(x => x.Id)
  10165. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10166. return Ok(JsonView(true, "查询成功!", data, total));
  10167. }
  10168. /// <summary>
  10169. /// 出入境费用-草稿 移动端
  10170. /// 获取币种基础数据(含逻辑处理)
  10171. /// </summary>
  10172. /// <returns></returns>
  10173. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10174. {
  10175. return await GeneralMethod.EnterExitCostInitRate();
  10176. }
  10177. /// <summary>
  10178. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10179. /// </summary>
  10180. /// <returns></returns>
  10181. [HttpPost]
  10182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10183. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10184. {
  10185. //验证城市归属并给默认值
  10186. int provinceId = dto.ProvinceId;
  10187. if (provinceId < 1) provinceId = 122;
  10188. var dataSource = await _sqlSugar
  10189. .Queryable<Sys_SetData>()
  10190. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10191. .ToListAsync();
  10192. //三公费用-Word明细类型
  10193. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10194. .Select(x => new SetDataInfoView
  10195. {
  10196. Id = x.Id,
  10197. Name = x.Name,
  10198. Remark = x.Remark
  10199. })
  10200. .ToList();
  10201. //三公费用-Excel明细类型
  10202. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10203. .Select(x => new SetDataInfoView
  10204. {
  10205. Id = x.Id,
  10206. Name = x.Name,
  10207. Remark = x.Remark
  10208. })
  10209. .ToList();
  10210. //默认币种显示
  10211. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10212. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10213. return Ok(JsonView(true, "查询成功!", new
  10214. {
  10215. WordTypeData = wordTypeData,
  10216. ExcelTypeData = excelTypeData,
  10217. CurrencyInit = _currencyInfos,
  10218. viewPermissionData = viewPermissionData
  10219. }));
  10220. }
  10221. /// <summary>
  10222. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10223. /// </summary>
  10224. /// <returns></returns>
  10225. [HttpPost]
  10226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10227. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10228. {
  10229. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10230. RefAsync<int> total = 0;
  10231. int diId = 0;
  10232. var status = int.TryParse(dto.GroupName, out diId);
  10233. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10234. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10235. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10236. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10237. .OrderByDescending(x => x.VisitStartDate)
  10238. .Select(x => new
  10239. {
  10240. Id = x.Id,
  10241. GroupName = x.TeamName
  10242. })
  10243. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10244. return Ok(JsonView(true, "查询成功!", data, total));
  10245. }
  10246. /// <summary>
  10247. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10248. /// </summary>
  10249. /// <returns></returns>
  10250. [HttpPost]
  10251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10252. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10253. {
  10254. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10255. RefAsync<int> total = 0;
  10256. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10257. .Where(x => x.IsDel == 0 && x.STid == 66)
  10258. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10259. .Select(x => new
  10260. {
  10261. id = x.Id,
  10262. name = x.Name,
  10263. remark = x.Remark,
  10264. })
  10265. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10266. return Ok(JsonView(true, "查询成功!", data, total));
  10267. }
  10268. /// <summary>
  10269. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10270. /// </summary>
  10271. /// <returns></returns>
  10272. [HttpPost]
  10273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10274. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10275. {
  10276. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10277. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10278. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10279. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10280. var groupOtherRateData = groupRateData.TeamRates;
  10281. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10282. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10283. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10284. groupOtherRateData = groupOtherRateData
  10285. .Select(x => new TeamRateDescAddCurrencyIdView
  10286. {
  10287. CurrencyId = x.CurrencyId,
  10288. CurrencyName = x.CurrencyName,
  10289. CurrencyCode = x.CurrencyCode,
  10290. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10291. }).ToList();
  10292. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10293. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10294. }
  10295. /// <summary>
  10296. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10297. /// </summary>
  10298. /// <returns></returns>
  10299. [HttpPost]
  10300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10301. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10302. {
  10303. int portType = dto.PortType;
  10304. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10305. var tipsData = new List<int>() { 1, 2, 3 };
  10306. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10307. if (dto.TipsType == 1)
  10308. {
  10309. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10310. }
  10311. else if (dto.TipsType == 2)
  10312. {
  10313. if (portType == 2)
  10314. {
  10315. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10316. }
  10317. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10318. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10319. .Select(x => x.NationalTravelFeeId)
  10320. .Distinct()
  10321. .ToListAsync();
  10322. if (portType == 2)
  10323. {
  10324. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10325. }
  10326. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10327. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10328. .Select(x => x.Country)
  10329. .Distinct()
  10330. .ToArrayAsync();
  10331. if (portType == 2)
  10332. {
  10333. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10334. }
  10335. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10336. return Ok(JsonView(true, "查询成功!", new
  10337. {
  10338. totalAmt = totalAmt,
  10339. remark = remark
  10340. }));
  10341. }
  10342. else if (dto.TipsType == 3)
  10343. {
  10344. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10345. }
  10346. return Ok(JsonView(false));
  10347. }
  10348. /// <summary>
  10349. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10350. /// </summary>
  10351. /// <returns></returns>
  10352. [HttpPost]
  10353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10354. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10355. {
  10356. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10357. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10358. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10359. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10360. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10361. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10362. var info = new Grp_EnterExitCostDraft()
  10363. {
  10364. ProvinceId = dto.ProvinceId,
  10365. DraftName = dto.DraftName,
  10366. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10367. CreateUserId = dto.CurrUserId
  10368. };
  10369. _sqlSugar.BeginTran();
  10370. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10371. if (draftId < 1)
  10372. {
  10373. _sqlSugar.RollbackTran();
  10374. return Ok(JsonView(false, "草稿创建失败!"));
  10375. }
  10376. //添加默认权限
  10377. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10378. _sqlSugar.CommitTran();
  10379. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10380. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10381. mobileInfo.Id = draftId;
  10382. mobileInfo.DraftName = dto.DraftName;
  10383. mobileInfo.Currencys = rateInfos;
  10384. mobileInfo.IsAssignPerm = assignPerm;
  10385. return Ok(JsonView(mobileInfo));
  10386. }
  10387. /// <summary>
  10388. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10389. /// </summary>
  10390. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10391. /// <summary>
  10392. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10393. /// </summary>
  10394. /// <returns></returns>
  10395. [HttpPost]
  10396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10397. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10398. {
  10399. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10400. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10401. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10402. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10403. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10404. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10405. //验证查看编辑权限
  10406. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10407. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10408. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10409. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10410. mobileInfo.IsAssignPerm = assignPerm;
  10411. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10412. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10413. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10414. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10415. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10416. {
  10417. ParentId = dac.ParentId,
  10418. SubId = dac.Id,
  10419. Type = dac.Type,
  10420. Days = dac.Days,
  10421. NationalTravelFeeId = dac.NationalTravelFeeId,
  10422. Arae = $"{ntf.Country}-{ntf.City}",
  10423. Cost = dac.Cost,
  10424. Currency = dac.Currency,
  10425. CurrencyName = sd.Name,
  10426. SubTotal = dac.SubTotal,
  10427. })
  10428. .ToList();
  10429. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10430. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10431. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10432. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10433. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10434. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10435. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10436. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10437. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10438. //其他款项
  10439. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10440. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10441. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10442. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10443. .OrderBy((dop, sd1, sd2) => dop.Index)
  10444. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10445. {
  10446. ParentId = dop.ParentId,
  10447. SubId = dop.Id,
  10448. Index = dop.Index,
  10449. SetDataId = dop.SetDataId,
  10450. SetDataName = sd1.Name,
  10451. Cost = dop.Cost,
  10452. Currency = dop.Currency,
  10453. CurrencyName = sd2.Remark,
  10454. SubTotal = dop.SubTotal,
  10455. Remark = dop.Remark,
  10456. })
  10457. .ToArray();
  10458. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10459. return Ok(mobileInfo);
  10460. }
  10461. /// <summary>
  10462. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10463. /// </summary>
  10464. /// <returns></returns>
  10465. [HttpPost]
  10466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10467. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10468. {
  10469. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10470. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10471. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10472. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10473. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10474. //验证查看编辑权限
  10475. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10476. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10477. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10478. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10479. var subType = dto.SubType;
  10480. if (subType == 1) //1:境内费用
  10481. {
  10482. var oneData = new ChoiceOneMobileSubInfoView()
  10483. {
  10484. Id = eecInfo.Id,
  10485. ChoiceOne = eecInfo.ChoiceOne,
  10486. ChoiceOneTotalCost = eecInfo.InsidePay,
  10487. Visa = eecInfo.Visa,
  10488. VisaRemark = eecInfo.VisaRemark,
  10489. YiMiao = eecInfo.YiMiao,
  10490. HeSuan = eecInfo.HeSuan,
  10491. Service = eecInfo.Service,
  10492. Ticket = eecInfo.Ticket,
  10493. Safe = eecInfo.Safe,
  10494. FirstItemRemark = eecInfo.FirstItemRemark
  10495. };
  10496. return Ok(JsonView(oneData));
  10497. }
  10498. else if (subType == 2) //2:国际旅费
  10499. {
  10500. var twoData = new ChoiceTwoMobileSubInfoView()
  10501. {
  10502. Id = eecInfo.Id,
  10503. ChoiceTwoJJ = eecInfo.SumJJC,
  10504. OutsideJJPay = eecInfo.OutsideJJPay,
  10505. ChoiceTwoGW = eecInfo.SumGWC,
  10506. OutsideGWPay = eecInfo.OutsideGWPay,
  10507. ChoiceTwoTD = eecInfo.SumTDC,
  10508. OutsideTDPay = eecInfo.OutsideTDPay,
  10509. AirJJ = eecInfo.AirJJ,
  10510. AirGW = eecInfo.AirGW,
  10511. AirTD = eecInfo.AirTD,
  10512. CityTranffic = eecInfo.CityTranffic,
  10513. TwoItemRemark = eecInfo.TwoItemRemark
  10514. };
  10515. return Ok(JsonView(twoData));
  10516. }
  10517. else if (subType == 3) //3:住宿费
  10518. {
  10519. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10520. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10521. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10522. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10523. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10524. {
  10525. ParentId = dac.ParentId,
  10526. SubId = dac.Id,
  10527. Type = dac.Type,
  10528. Days = dac.Days,
  10529. NationalTravelFeeId = dac.NationalTravelFeeId,
  10530. Arae = $"{ntf.Country}-{ntf.City}",
  10531. Cost = dac.Cost,
  10532. Currency = dac.Currency,
  10533. CurrencyName = sd.Name,
  10534. SubTotal = dac.SubTotal,
  10535. })
  10536. .ToArray();
  10537. var data = new ChoiceDraftMobileSubInfo3To6View()
  10538. {
  10539. ParentId = eecInfo.Id,
  10540. Choice = eecInfo.ChoiceThree,
  10541. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10542. Details = dayAndCostDatas
  10543. };
  10544. return Ok(JsonView(data));
  10545. }
  10546. else if (subType == 4) //4:伙食费
  10547. {
  10548. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10549. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10550. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10551. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10552. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10553. {
  10554. ParentId = dac.ParentId,
  10555. SubId = dac.Id,
  10556. Type = dac.Type,
  10557. Days = dac.Days,
  10558. NationalTravelFeeId = dac.NationalTravelFeeId,
  10559. Arae = $"{ntf.Country}-{ntf.City}",
  10560. Cost = dac.Cost,
  10561. Currency = dac.Currency,
  10562. CurrencyName = sd.Name,
  10563. SubTotal = dac.SubTotal,
  10564. })
  10565. .ToArray();
  10566. var data = new ChoiceDraftMobileSubInfo3To6View()
  10567. {
  10568. ParentId = eecInfo.Id,
  10569. Choice = eecInfo.ChoiceFour,
  10570. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10571. Details = dayAndCostDatas
  10572. };
  10573. return Ok(JsonView(data));
  10574. }
  10575. else if (subType == 5) //5:公杂费
  10576. {
  10577. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10578. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10579. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10580. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10581. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10582. {
  10583. ParentId = dac.ParentId,
  10584. SubId = dac.Id,
  10585. Type = dac.Type,
  10586. Days = dac.Days,
  10587. NationalTravelFeeId = dac.NationalTravelFeeId,
  10588. Arae = $"{ntf.Country}-{ntf.City}",
  10589. Cost = dac.Cost,
  10590. Currency = dac.Currency,
  10591. CurrencyName = sd.Name,
  10592. SubTotal = dac.SubTotal,
  10593. })
  10594. .ToArray();
  10595. var data = new ChoiceDraftMobileSubInfo3To6View()
  10596. {
  10597. ParentId = eecInfo.Id,
  10598. Choice = eecInfo.ChoiceFive,
  10599. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10600. Details = dayAndCostDatas
  10601. };
  10602. return Ok(JsonView(data));
  10603. }
  10604. else if (subType == 6) //6:培训费
  10605. {
  10606. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10607. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10608. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10609. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10610. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10611. {
  10612. ParentId = dac.ParentId,
  10613. SubId = dac.Id,
  10614. Type = dac.Type,
  10615. Days = dac.Days,
  10616. NationalTravelFeeId = dac.NationalTravelFeeId,
  10617. Arae = $"{ntf.Country}-{ntf.City}",
  10618. Cost = dac.Cost,
  10619. Currency = dac.Currency,
  10620. CurrencyName = sd.Name,
  10621. SubTotal = dac.SubTotal,
  10622. })
  10623. .ToArray();
  10624. var data = new ChoiceDraftMobileSubInfo3To6View()
  10625. {
  10626. ParentId = eecInfo.Id,
  10627. Choice = eecInfo.ChoiceSix,
  10628. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10629. Details = dayAndCostDatas
  10630. };
  10631. return Ok(JsonView(data));
  10632. }
  10633. else if (subType == 7) //7:其他
  10634. {
  10635. //其他款项
  10636. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10637. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10638. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10639. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10640. .OrderBy((dop, sd1, sd2) => dop.Index)
  10641. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10642. {
  10643. ParentId = dop.ParentId,
  10644. SubId = dop.Id,
  10645. Index = dop.Index,
  10646. SetDataId = dop.SetDataId,
  10647. SetDataName = sd1.Name,
  10648. Cost = dop.Cost,
  10649. Currency = dop.Currency,
  10650. CurrencyName = sd2.Name,
  10651. SubTotal = dop.SubTotal,
  10652. Remark = dop.Remark,
  10653. })
  10654. .ToArray();
  10655. var data = new ChoiceSevenDraftMobileSubInfoView()
  10656. {
  10657. ParentId = eecInfo.Id,
  10658. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10659. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10660. Details = otherData
  10661. };
  10662. return Ok(JsonView(data));
  10663. }
  10664. return Ok(JsonView(false));
  10665. }
  10666. #region op
  10667. /// <summary>
  10668. /// 移动端更新费用消息通知
  10669. /// </summary>
  10670. /// <param name="draftId"></param>
  10671. /// <param name="id"></param>
  10672. /// <param name="currUserId"></param>
  10673. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10674. {
  10675. try
  10676. {
  10677. ////生成默认文件pdf并且通知人员
  10678. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10679. //{
  10680. // DiId = draftId,
  10681. // ExportType = 1,
  10682. // SubTypeId = 1005
  10683. //}, "pdf");
  10684. ////发送通知
  10685. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10686. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10687. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10688. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10689. ////汇率信息记录
  10690. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10691. }
  10692. catch (Exception ex)
  10693. {
  10694. //记录日志
  10695. throw;
  10696. }
  10697. }
  10698. /// <summary>
  10699. /// 验证出入境费用数据是否存在
  10700. /// 不存在添加
  10701. /// </summary>
  10702. /// <param name="draftId"></param>
  10703. /// <param name="currUserId"></param>
  10704. /// <returns></returns>
  10705. /// <exception cref="CustomException"></exception>
  10706. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10707. {
  10708. var parentId = 0;
  10709. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10710. if (info != null) parentId = info.Id;
  10711. else
  10712. {
  10713. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10714. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10715. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10716. parentId = addId;
  10717. }
  10718. return parentId;
  10719. }
  10720. /// <summary>
  10721. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10722. /// </summary>
  10723. /// <returns></returns>
  10724. [HttpPost]
  10725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10726. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10727. {
  10728. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10729. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10730. //验证查看权限
  10731. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10732. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10733. var userIds = await _sqlSugar
  10734. .Queryable<Grp_EnterExitCostDraftPermission>()
  10735. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10736. .Select(x => x.UserId)
  10737. .ToArrayAsync();
  10738. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10739. var perUsersView = new List<dynamic>();
  10740. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10741. var viewPermissionData = new List<PermissionViewUserview>();
  10742. if (feeBasePerm.Any())
  10743. {
  10744. foreach (var item in feeBasePerm)
  10745. {
  10746. if (item.Users.Any())
  10747. {
  10748. viewPermissionData.AddRange(item.Users);
  10749. }
  10750. }
  10751. }
  10752. foreach (var item in perUsers)
  10753. {
  10754. bool isView1 = false;
  10755. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10756. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10757. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10758. }
  10759. return Ok(JsonView(perUsersView));
  10760. }
  10761. /// <summary>
  10762. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10763. /// </summary>
  10764. /// <returns></returns>
  10765. [HttpPost]
  10766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10767. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10768. {
  10769. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10770. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10771. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10772. //验证查看编辑权限
  10773. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10774. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10775. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10776. foreach (var userId in dto.UserIds)
  10777. {
  10778. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10779. }
  10780. if (permissions.Any())
  10781. {
  10782. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10783. {
  10784. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10785. }
  10786. _sqlSugar.BeginTran();
  10787. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10788. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10789. if (result < 1)
  10790. {
  10791. _sqlSugar.RollbackTran();
  10792. return Ok(JsonView(false));
  10793. }
  10794. _sqlSugar.CommitTran();
  10795. return Ok(JsonView(true));
  10796. }
  10797. return Ok(JsonView(false));
  10798. }
  10799. /// <summary>
  10800. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10801. /// </summary>
  10802. /// <returns></returns>
  10803. [HttpPost]
  10804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10805. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10806. {
  10807. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10808. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10809. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10810. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10811. int id = dto.DraftId;
  10812. if (id <= 0) //add
  10813. {
  10814. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10815. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10816. if (add < 1) return Ok(JsonView(false));
  10817. id = add;
  10818. }
  10819. else //update
  10820. {
  10821. //验证查看编辑权限
  10822. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10823. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10824. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10825. if (upd < 1) return Ok(JsonView(false));
  10826. }
  10827. return Ok(JsonView(new { parentId = id }));
  10828. }
  10829. /// <summary>
  10830. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10831. /// </summary>
  10832. /// <returns></returns>
  10833. [HttpPost]
  10834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10835. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10836. {
  10837. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10838. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10839. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10840. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10841. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10842. int id = dto.DraftId;
  10843. if (id <= 0) //add
  10844. {
  10845. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10846. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10847. if (add < 1) return Ok(JsonView(false));
  10848. id = add;
  10849. }
  10850. else //update
  10851. {
  10852. //验证查看编辑权限
  10853. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10854. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10855. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10856. if (upd < 1) return Ok(JsonView(false));
  10857. }
  10858. #region 汇率变更时更改币种相关费用
  10859. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10860. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10861. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10862. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10863. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10864. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10865. .Select((dac, sd) => new
  10866. {
  10867. dac.Id,
  10868. dac.ParentId,
  10869. CurrencyCode = sd.Name,
  10870. dac.Cost
  10871. })
  10872. .ToList();
  10873. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10874. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10875. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10876. .Select((dop, sd) => new
  10877. {
  10878. dop.Id,
  10879. dop.ParentId,
  10880. CurrencyCode = sd.Name,
  10881. dop.Cost
  10882. })
  10883. .ToList();
  10884. if (dayCosts.Count > 0)
  10885. {
  10886. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10887. foreach (var dc in new_dayCosts)
  10888. {
  10889. var thisCurrency = dc.Key.ToUpper();
  10890. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10891. if (thisRate == 0.00M) continue;
  10892. foreach (var dcSub in dc)
  10893. {
  10894. opDayCosts.Add(new Grp_DayAndCostDraft()
  10895. {
  10896. Id = dcSub.Id,
  10897. ParentId = dcSub.ParentId,
  10898. Cost = dcSub.Cost,
  10899. SubTotal = dcSub.Cost * thisRate,
  10900. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10901. });
  10902. }
  10903. }
  10904. if (opDayCosts.Count > 0)
  10905. {
  10906. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10907. }
  10908. }
  10909. if (dayOtherCosts.Count > 0)
  10910. {
  10911. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10912. foreach (var dc in new_dayOtherCosts)
  10913. {
  10914. var thisCurrency = dc.Key.ToUpper();
  10915. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10916. if (thisRate == 0.00M) continue;
  10917. foreach (var dcSub in dc)
  10918. {
  10919. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10920. {
  10921. Id = dcSub.Id,
  10922. ParentId = dcSub.ParentId,
  10923. Cost = dcSub.Cost,
  10924. SubTotal = dcSub.Cost * thisRate,
  10925. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10926. });
  10927. }
  10928. }
  10929. if (opDayOtherCosts.Count > 0)
  10930. {
  10931. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10932. }
  10933. }
  10934. #endregion
  10935. ////消息通知
  10936. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10937. ////汇率信息记录
  10938. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10939. return Ok(JsonView(new { parentId = id }));
  10940. }
  10941. /// <summary>
  10942. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10943. /// </summary>
  10944. /// <returns></returns>
  10945. [HttpPost]
  10946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10947. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10948. {
  10949. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10950. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10951. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10952. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10953. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10954. int id = dto.DraftId;
  10955. if (id <= 0) //add
  10956. {
  10957. checkboxInfo.ProvinceId = dto.ProvinceId;
  10958. checkboxInfo.CreateUserId = dto.CurrUserId;
  10959. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10960. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10961. if (add < 1) return Ok(JsonView(false));
  10962. }
  10963. else //update
  10964. {
  10965. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10966. .UpdateColumns(x => new
  10967. {
  10968. x.ChoiceOne,
  10969. x.ChoiceTwo,
  10970. x.SumJJC,
  10971. x.SumGWC,
  10972. x.SumTDC,
  10973. x.ChoiceThree,
  10974. x.ChoiceFour,
  10975. x.ChoiceFive,
  10976. x.ChoiceSix,
  10977. x.OtherExpenses_Checked
  10978. })
  10979. .Where(x => x.Id == id)
  10980. .ExecuteCommandAsync();
  10981. if (upd < 1) return Ok(JsonView(false));
  10982. }
  10983. return Ok(JsonView(new { parentId = id }));
  10984. }
  10985. /// <summary>
  10986. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  10987. /// </summary>
  10988. /// <returns></returns>
  10989. [HttpPost]
  10990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10991. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  10992. {
  10993. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  10994. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10995. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10996. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10997. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10998. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10999. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11000. var checkboxInfo = new Grp_EnterExitCostDraft()
  11001. {
  11002. Id = draftId,
  11003. ProvinceId = dto.ProvinceId,
  11004. CreateUserId = currUserId
  11005. };
  11006. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11007. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11008. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11009. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11010. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11011. if (draftId <= 0) //add
  11012. {
  11013. checkboxInfo.CreateUserId = dto.CurrUserId;
  11014. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11015. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11016. if (add < 1) return Ok(JsonView(false));
  11017. }
  11018. else //update
  11019. {
  11020. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11021. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11022. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11023. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11024. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11025. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11026. .Where(x => x.Id == draftId)
  11027. .ExecuteCommandAsync();
  11028. if (upd < 1) return Ok(JsonView(false));
  11029. }
  11030. return Ok(JsonView(new { parentId = draftId }));
  11031. }
  11032. /// <summary>
  11033. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11034. /// </summary>
  11035. /// <returns></returns>
  11036. [HttpPost]
  11037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11038. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11039. {
  11040. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11042. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11043. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11044. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11045. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11046. info.ProvinceId = dto.ProvinceId;
  11047. info.FirstItemRemark = dto.FirstItemRemark;
  11048. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11049. if (id <= 0) //add
  11050. {
  11051. info.CreateUserId = dto.CurrUserId;
  11052. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11053. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11054. if (add < 1) return Ok(JsonView(false));
  11055. id = add;
  11056. }
  11057. else //update
  11058. {
  11059. var upd = await _sqlSugar.Updateable(info)
  11060. .UpdateColumns(x => new
  11061. {
  11062. x.ChoiceOne,
  11063. x.InsidePay,
  11064. x.VisaRemark,
  11065. x.Visa,
  11066. x.Service,
  11067. x.Safe,
  11068. x.Ticket,
  11069. x.HeSuan,
  11070. x.YiMiao,
  11071. x.FirstItemRemark
  11072. })
  11073. .Where(x => x.Id == id)
  11074. .ExecuteCommandAsync();
  11075. if (upd < 1) return Ok(JsonView(false));
  11076. }
  11077. ////消息通知
  11078. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11079. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11080. }
  11081. /// <summary>
  11082. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11083. /// </summary>
  11084. /// <returns></returns>
  11085. [HttpPost]
  11086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11087. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11088. {
  11089. int id = dto.DraftId;
  11090. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11091. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11092. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11093. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11094. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11095. info.ProvinceId = dto.ProvinceId;
  11096. info.OutsideJJPay = dto.OutsideJJPay;
  11097. info.OutsideGWPay = dto.OutsideGWPay;
  11098. info.OutsideTDPay = dto.OutsideTDPay;
  11099. info.AirJJ = dto.AirJJ;
  11100. info.AirGW = dto.AirGW;
  11101. info.AirTD = dto.AirTD;
  11102. info.CityTranffic = dto.CityTranffic;
  11103. info.TwoItemRemark = dto.TwoItemRemark;
  11104. info.SumJJC = dto.ChoiceTwoJJ;
  11105. info.SumGWC = dto.ChoiceTwoGW;
  11106. info.SumTDC = dto.ChoiceTwoTD;
  11107. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11108. if (id <= 0) //add
  11109. {
  11110. info.CreateUserId = dto.CurrUserId;
  11111. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11112. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11113. if (addId <= 0) return Ok(JsonView(false));
  11114. id = addId;
  11115. }
  11116. else //update
  11117. {
  11118. var upd = await _sqlSugar.Updateable(info)
  11119. .UpdateColumns(x => new
  11120. {
  11121. x.SumJJC,
  11122. x.OutsideJJPay,
  11123. x.SumGWC,
  11124. x.OutsideGWPay,
  11125. x.SumTDC,
  11126. x.OutsideTDPay,
  11127. x.AirJJ,
  11128. x.AirGW,
  11129. x.AirTD,
  11130. x.CityTranffic,
  11131. x.TwoItemRemark
  11132. })
  11133. .Where(x => x.Id == id)
  11134. .ExecuteCommandAsync();
  11135. if (upd < 1) return Ok(JsonView(false));
  11136. }
  11137. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11138. gwcItemTotal = info.AirGW + info.CityTranffic;
  11139. tdcItemTotal = info.AirTD + info.CityTranffic;
  11140. ////消息通知
  11141. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11142. return Ok(JsonView(new
  11143. {
  11144. parentId = id,
  11145. choiceTwoJJ = dto.ChoiceTwoJJ,
  11146. jjcItemTotal = jjcItemTotal,
  11147. choiceTwoGW = dto.ChoiceTwoGW,
  11148. gwcItemTotal = gwcItemTotal,
  11149. choiceTwoTD = dto.ChoiceTwoTD,
  11150. tdcItemTotal = tdcItemTotal
  11151. }));
  11152. }
  11153. /// <summary>
  11154. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11155. /// </summary>
  11156. /// <returns></returns>
  11157. [HttpPost]
  11158. [ApiExplorerSettings(IgnoreApi = true)]
  11159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11160. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11161. {
  11162. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11163. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11164. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11165. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11166. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11167. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11168. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11169. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11170. {
  11171. Id = x.Id,
  11172. ParentId = dto.DraftId,
  11173. Type = dto.FeeType,
  11174. Days = x.Days,
  11175. NationalTravelFeeId = x.NationalTravelFeeId,
  11176. Cost = x.Cost,
  11177. Currency = x.Currency,
  11178. SubTotal = x.SubTotal,
  11179. CreateUserId = dto.CurrUserId
  11180. })
  11181. .ToList();
  11182. var adds = infos.Where(x => x.Id <= 0).ToList();
  11183. var upds = infos.Where(x => x.Id > 0).ToList();
  11184. if (adds.Count > 0)
  11185. {
  11186. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11187. if (add < 1) return Ok(JsonView(false));
  11188. }
  11189. if (upds.Count > 0)
  11190. {
  11191. var upd = await _sqlSugar.Updateable(adds)
  11192. .UpdateColumns(x => new
  11193. {
  11194. x.Days,
  11195. x.NationalTravelFeeId,
  11196. x.Cost,
  11197. x.Currency,
  11198. x.SubTotal
  11199. })
  11200. .WhereColumns(x => new { x.Id })
  11201. .ExecuteCommandAsync();
  11202. if (upd < 1) return Ok(JsonView(false));
  11203. }
  11204. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11205. ////消息通知
  11206. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11207. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11208. return Ok(JsonView(new { itemTotal = itemTotal }));
  11209. }
  11210. /// <summary>
  11211. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11212. /// </summary>
  11213. /// <returns></returns>
  11214. [HttpPost]
  11215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11216. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11217. {
  11218. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11219. int subId = dto.SubId, feeType = dto.FeeType;
  11220. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11221. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11222. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11223. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11224. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11225. subInfo.Id = subId;
  11226. subInfo.ParentId = dto.DraftId;
  11227. if (feeType == 3) subInfo.Type = 1;
  11228. else if (feeType == 4) subInfo.Type = 2;
  11229. else if (feeType == 5) subInfo.Type = 3;
  11230. else if (feeType == 6) subInfo.Type = 4;
  11231. subInfo.CreateUserId = dto.CurrUserId;
  11232. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11233. if (parentId < 1) return Ok(JsonView(false));
  11234. //子表op
  11235. if (subId < 1)
  11236. {
  11237. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11238. if (subAdd < 1) return Ok(JsonView(false));
  11239. }
  11240. else
  11241. {
  11242. var subUpd = await _sqlSugar.Updateable(subInfo)
  11243. .UpdateColumns(x => new
  11244. {
  11245. x.Days,
  11246. x.NationalTravelFeeId,
  11247. x.Cost,
  11248. x.Currency,
  11249. x.SubTotal
  11250. })
  11251. .WhereColumns(x => new { x.Id })
  11252. .ExecuteCommandAsync();
  11253. if (subUpd < 1) return Ok(JsonView(false));
  11254. }
  11255. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11256. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11257. }
  11258. /// <summary>
  11259. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11260. /// </summary>
  11261. /// <returns></returns>
  11262. [HttpPost]
  11263. [ApiExplorerSettings(IgnoreApi = true)]
  11264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11265. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11266. {
  11267. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11268. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11269. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11270. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11271. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11272. {
  11273. Id = x.Id,
  11274. ParentId = dto.DraftId,
  11275. SetDataId = x.SetDataId,
  11276. Index = x.Index,
  11277. Cost = x.Cost,
  11278. Currency = x.Currency,
  11279. SubTotal = x.SubTotal,
  11280. CreateUserId = dto.CurrUserId,
  11281. Remark = x.Remark
  11282. }).ToList();
  11283. var adds = infos.Where(x => x.Id <= 0).ToList();
  11284. var upds = infos.Where(x => x.Id > 0).ToList();
  11285. if (adds.Count > 0)
  11286. {
  11287. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11288. if (add < 1) return Ok(JsonView(false));
  11289. }
  11290. if (upds.Count > 0)
  11291. {
  11292. var upd = await _sqlSugar.Updateable(adds)
  11293. .UpdateColumns(x => new
  11294. {
  11295. x.Index,
  11296. x.SetDataId,
  11297. x.Cost,
  11298. x.Currency,
  11299. x.SubTotal,
  11300. x.Remark
  11301. })
  11302. .WhereColumns(x => new { x.Id })
  11303. .ExecuteCommandAsync();
  11304. if (upd < 1) return Ok(JsonView(false));
  11305. }
  11306. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11307. //消息通知
  11308. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11309. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11310. return Ok(JsonView(new { itemTotal = itemTotal }));
  11311. }
  11312. /// <summary>
  11313. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11314. /// </summary>
  11315. /// <returns></returns>
  11316. [HttpPost]
  11317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11318. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11319. {
  11320. int subId = dto.SubId, id = dto.DraftId;
  11321. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11322. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11323. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11324. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11325. subInfo.Id = subId;
  11326. subInfo.ParentId = id;
  11327. subInfo.CreateUserId = dto.CurrUserId;
  11328. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11329. if (parentId < 1) return Ok(JsonView(false));
  11330. #region 子表op
  11331. if (subId < 1)//add
  11332. {
  11333. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11334. if (subAdd < 1) return Ok(JsonView(false));
  11335. }
  11336. else //upd
  11337. {
  11338. var subUpd = await _sqlSugar.Updateable(subInfo)
  11339. .UpdateColumns(x => new
  11340. {
  11341. x.Index,
  11342. x.SetDataId,
  11343. x.Cost,
  11344. x.Currency,
  11345. x.SubTotal,
  11346. x.Remark
  11347. })
  11348. .WhereColumns(x => new { x.Id })
  11349. .ExecuteCommandAsync();
  11350. if (subUpd < 1) return Ok(JsonView(false));
  11351. }
  11352. #endregion
  11353. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11354. ////消息通知
  11355. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11356. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11357. }
  11358. /// <summary>
  11359. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11360. /// </summary>
  11361. /// <returns></returns>
  11362. [HttpPost]
  11363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11364. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11365. {
  11366. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11367. if (data.Code != 0)
  11368. {
  11369. return Ok(JsonView(false, data.Msg));
  11370. }
  11371. return Ok(JsonView(true, "操作成功!", data.Data));
  11372. }
  11373. /// <summary>
  11374. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11375. /// </summary>
  11376. /// <param name="dto"></param>
  11377. /// <returns></returns>
  11378. [HttpPost]
  11379. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11380. {
  11381. var data = new Grp_DayOtherPriceDraft()
  11382. {
  11383. Id = dto.Id,
  11384. IsDel = 1,
  11385. DeleteUserId = dto.DeleteUserId,
  11386. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11387. };
  11388. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11389. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11390. return Ok(JsonView(false, "删除失败!"));
  11391. }
  11392. #endregion
  11393. #endregion
  11394. #region 团组经理模块 出入境费用报价表
  11395. /// <summary>
  11396. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11397. /// </summary>
  11398. /// <returns></returns>
  11399. [HttpPost]
  11400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11401. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11402. {
  11403. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11404. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11405. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11406. initRates.Insert(0, cnyInfo);
  11407. liveRates.Insert(0, cnyInfo);
  11408. return Ok(JsonView(true, "查询成功!", new
  11409. {
  11410. InitRates = initRates,
  11411. LiveRates = liveRates
  11412. }));
  11413. }
  11414. /// <summary>
  11415. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11416. /// </summary>
  11417. /// <returns></returns>
  11418. [HttpPost]
  11419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11420. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  11421. {
  11422. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11423. }
  11424. /// <summary>
  11425. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11426. /// </summary>
  11427. /// <returns></returns>
  11428. [HttpPost]
  11429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11430. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  11431. {
  11432. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11433. }
  11434. /// <summary>
  11435. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11436. /// </summary>
  11437. /// <returns></returns>
  11438. [HttpPost]
  11439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11440. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11441. {
  11442. int groupId = dto.DiId,
  11443. currUserId = dto.CurrUserId;
  11444. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11445. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11446. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11447. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  11448. var infoView = info.Data as EnterExitCostInfoView;
  11449. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11450. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11451. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11452. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11453. var eecRates = infoView.Currencys;
  11454. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11455. int pplNum = 1;
  11456. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11457. var views = new List<QuoteSubItemInfo>();
  11458. #region 数据填充
  11459. var intTravelCosts = new List<QuoteSubItemInfo>();
  11460. #region 机票费用 1354
  11461. int intTravelIndex = 1;
  11462. if (infoView.SumJJC == 1)
  11463. {
  11464. intTravelCosts.Add(new QuoteSubItemInfo
  11465. {
  11466. ItemId = 1354,
  11467. Index = intTravelIndex,
  11468. FeeName = "经济舱",
  11469. UnitPrice = infoView.AirJJ,
  11470. Currency = "CNY",
  11471. Quantity = 1,
  11472. PplNum = 1,
  11473. TotalAmt = infoView.AirJJ,
  11474. Remark = "",
  11475. });
  11476. intTravelIndex++;
  11477. }
  11478. if (infoView.SumGWC == 1)
  11479. {
  11480. intTravelCosts.Add(new QuoteSubItemInfo
  11481. {
  11482. ItemId = 1354,
  11483. Index = intTravelIndex,
  11484. FeeName = "公务舱",
  11485. UnitPrice = infoView.AirGW,
  11486. Currency = "CNY",
  11487. Quantity = 1,
  11488. PplNum = 1,
  11489. TotalAmt = infoView.AirGW,
  11490. Remark = "",
  11491. });
  11492. intTravelIndex++;
  11493. }
  11494. if (infoView.SumTDC == 1)
  11495. {
  11496. intTravelCosts.Add(new QuoteSubItemInfo
  11497. {
  11498. ItemId = 1354,
  11499. Index = intTravelIndex,
  11500. FeeName = "头等舱",
  11501. UnitPrice = infoView.AirTD,
  11502. Currency = "CNY",
  11503. Quantity = 1,
  11504. PplNum = 1,
  11505. TotalAmt = infoView.AirTD,
  11506. Remark = "",
  11507. });
  11508. intTravelIndex++;
  11509. }
  11510. intTravelCosts.Add(new QuoteSubItemInfo
  11511. {
  11512. ItemId = 1354,
  11513. Index = intTravelIndex,
  11514. FeeName = "城市间交通费用",
  11515. UnitPrice = infoView.CityTranffic,
  11516. Currency = "CNY",
  11517. Quantity = 1,
  11518. PplNum = pplNum,
  11519. TotalAmt = infoView.CityTranffic * pplNum,
  11520. Remark = "",
  11521. });
  11522. views.AddRange(intTravelCosts);
  11523. #endregion
  11524. var accomCosts = new List<QuoteSubItemInfo>();
  11525. #region 住宿费 1355
  11526. if (infoView.QuarterageData.Any())
  11527. {
  11528. int accomIndex = 1;
  11529. int accomItemTypeId = 1355;
  11530. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11531. foreach (var item in groupData)
  11532. {
  11533. string feeName = string.Empty;
  11534. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11535. if (countryInfo != null)
  11536. {
  11537. feeName = countryInfo.Country;
  11538. var city = countryInfo.City;
  11539. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11540. {
  11541. feeName += $"-{city}";
  11542. }
  11543. }
  11544. var hotelInfo = item.FirstOrDefault();
  11545. if (hotelInfo == null) continue;
  11546. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11547. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11548. int quantity = item.ToList().Count;
  11549. accomCosts.Add(new QuoteSubItemInfo
  11550. {
  11551. ItemId = accomItemTypeId,
  11552. Index = accomIndex,
  11553. FeeName = feeName,
  11554. UnitPrice = hotelInfo.Cost,
  11555. Currency = thisCurrency,
  11556. Quantity = quantity,
  11557. PplNum = pplNum,
  11558. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11559. Remark = "",
  11560. });
  11561. accomIndex++;
  11562. }
  11563. views.AddRange(accomCosts);
  11564. }
  11565. #endregion
  11566. var mealCosts = new List<QuoteSubItemInfo>();
  11567. #region 餐饮费 1356
  11568. if (infoView.BoardWagesData.Any())
  11569. {
  11570. var mealIndex = 1;
  11571. int mealItemTypeId = 1356;
  11572. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11573. foreach (var item in groupData)
  11574. {
  11575. string feeName = string.Empty;
  11576. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11577. if (countryInfo != null)
  11578. {
  11579. feeName = countryInfo.Country;
  11580. var city = countryInfo.City;
  11581. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11582. {
  11583. feeName += $"-{city}";
  11584. }
  11585. }
  11586. var mealInfo = item.FirstOrDefault();
  11587. if (mealInfo == null) continue;
  11588. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11589. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11590. int quantity = item.ToList().Count;
  11591. mealCosts.Add(new QuoteSubItemInfo
  11592. {
  11593. ItemId = mealItemTypeId,
  11594. Index = mealIndex,
  11595. FeeName = feeName,
  11596. UnitPrice = mealInfo.Cost,
  11597. Currency = thisCurrency,
  11598. Quantity = quantity,
  11599. PplNum = pplNum,
  11600. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11601. Remark = "",
  11602. });
  11603. mealIndex++;
  11604. }
  11605. views.AddRange(mealCosts);
  11606. }
  11607. #endregion
  11608. var miscCosts = new List<QuoteSubItemInfo>();
  11609. #region 公杂费 1364
  11610. if (infoView.MiscellaneousFeeData.Any())
  11611. {
  11612. var miscIndex = 1;
  11613. int miscItemTypeId = 1364;
  11614. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11615. foreach (var item in groupData)
  11616. {
  11617. string feeName = string.Empty;
  11618. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11619. if (countryInfo != null)
  11620. {
  11621. feeName = countryInfo.Country;
  11622. var city = countryInfo.City;
  11623. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11624. {
  11625. feeName += $"-{city}";
  11626. }
  11627. }
  11628. var miscInfo = item.FirstOrDefault();
  11629. if (miscInfo == null) continue;
  11630. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11631. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11632. int quantity = item.ToList().Count;
  11633. mealCosts.Add(new QuoteSubItemInfo
  11634. {
  11635. ItemId = miscItemTypeId,
  11636. Index = miscIndex,
  11637. FeeName = feeName,
  11638. UnitPrice = miscInfo.Cost,
  11639. Currency = thisCurrency,
  11640. Quantity = quantity,
  11641. PplNum = pplNum,
  11642. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11643. Remark = "",
  11644. });
  11645. miscIndex++;
  11646. }
  11647. views.AddRange(mealCosts);
  11648. }
  11649. #endregion
  11650. #region 签证+保险 1362
  11651. int visaInsIndex = 1;
  11652. int visaInsItemTypeId = 1362;
  11653. if (infoView.Visa > 0)
  11654. {
  11655. views.Add(new QuoteSubItemInfo()
  11656. {
  11657. ItemId = visaInsItemTypeId,
  11658. Index = visaInsIndex,
  11659. FeeName = $"签证",
  11660. UnitPrice = infoView.Visa,
  11661. Currency = $"CNY",
  11662. Quantity = 1,
  11663. PplNum = pplNum,
  11664. TotalAmt = infoView.Visa * pplNum,
  11665. Remark = "",
  11666. });
  11667. visaInsIndex++;
  11668. }
  11669. if (infoView.Safe > 0)
  11670. {
  11671. views.Add(new QuoteSubItemInfo()
  11672. {
  11673. ItemId = visaInsItemTypeId,
  11674. Index = visaInsIndex,
  11675. FeeName = $"保险",
  11676. UnitPrice = infoView.Safe,
  11677. Currency = $"CNY",
  11678. Quantity = 1,
  11679. PplNum = pplNum,
  11680. TotalAmt = infoView.Safe * pplNum,
  11681. Remark = "",
  11682. });
  11683. }
  11684. #endregion
  11685. #region 服务费 1363
  11686. int serviceFeeIndex = 1;
  11687. int serviceFeeItemTypeId = 1363;
  11688. if (infoView.Service > 0)
  11689. {
  11690. views.Add(new QuoteSubItemInfo()
  11691. {
  11692. ItemId = serviceFeeItemTypeId,
  11693. Index = serviceFeeIndex,
  11694. FeeName = $"服务费",
  11695. UnitPrice = infoView.Service,
  11696. Currency = $"CNY",
  11697. Quantity = 1,
  11698. PplNum = pplNum,
  11699. TotalAmt = infoView.Service * pplNum,
  11700. Remark = "",
  11701. });
  11702. }
  11703. #endregion
  11704. #endregion
  11705. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11706. result.Rates = eecRates.ToArray();
  11707. if (result.FeeItems.Any())
  11708. {
  11709. result.FeeItems.Select(x =>
  11710. {
  11711. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11712. if (feeInfos.Any()) x.Infos = feeInfos;
  11713. return x;
  11714. }
  11715. )
  11716. .OrderBy(x => x.Index)
  11717. .ToList();
  11718. }
  11719. return Ok(JsonView(result));
  11720. }
  11721. /// <summary>
  11722. /// 团组模块 - 出入境费用报价表 - Info
  11723. /// </summary>
  11724. /// <returns></returns>
  11725. [HttpPost]
  11726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11727. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11728. {
  11729. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11730. if (!info.Rates.Any())
  11731. {
  11732. var rates = await GeneralMethod.EnterExitCostInitRate();
  11733. info.Rates = rates.ToArray();
  11734. }
  11735. return Ok(JsonView(info));
  11736. }
  11737. /// <summary>
  11738. /// 团组模块 - 出入境费用报价表 - OP
  11739. /// </summary>
  11740. /// <returns></returns>
  11741. [HttpPost]
  11742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11743. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11744. {
  11745. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11746. }
  11747. /// <summary>
  11748. /// 团组模块 - 出入境费用报价表 - 删除 项
  11749. /// </summary>
  11750. /// <returns></returns>
  11751. [HttpPost]
  11752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11753. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11754. {
  11755. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11756. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11757. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11758. }
  11759. /// <summary>
  11760. /// 团组模块 - 出入境费用报价表 - 导出
  11761. /// </summary>
  11762. /// <returns></returns>
  11763. [HttpPost]
  11764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11765. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11766. {
  11767. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11768. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11769. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11770. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11771. var rates = info.Rates;
  11772. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11773. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11774. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11775. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11776. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11777. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11778. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11779. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11780. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11781. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11782. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11783. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11784. //获取模板
  11785. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11786. var designer = new WorkbookDesigner();
  11787. designer.Workbook = new Workbook(tempPath);
  11788. designer.SetDataSource("QuoteName", info.Name);
  11789. designer.SetDataSource("CompanyTitle", "公司名称");
  11790. designer.SetDataSource("CompanyLabel", "");
  11791. #region 国际旅费
  11792. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  11793. if (intTravelCosts.Infos.Any())
  11794. {
  11795. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11796. StringBuilder label = new StringBuilder();
  11797. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11798. if (infos.Any())
  11799. {
  11800. label.Append(infos.Sum(x => x.PplNum));
  11801. label.Append("人全程机票:");
  11802. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11803. label.AppendLine("元");
  11804. }
  11805. foreach (var item in intTravelCosts.Infos)
  11806. {
  11807. label.Append(item.FeeName);
  11808. label.Append(":");
  11809. label.Append(item.UnitPrice.TruncDecimals(2));
  11810. label.Append("元/人*");
  11811. label.Append(item.PplNum);
  11812. label.AppendLine("人");
  11813. }
  11814. if (label.HasValue())
  11815. {
  11816. label.Append("\r\n以上小计:");
  11817. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11818. label.Append("元");
  11819. }
  11820. designer.SetDataSource("IntTravelLabel", label.ToString());
  11821. }
  11822. #endregion
  11823. #region 住宿费
  11824. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  11825. if (accomCosts.Infos.Any())
  11826. {
  11827. string currencyName = string.Empty;
  11828. decimal rate = 1.0000M;
  11829. StringBuilder label = new StringBuilder();
  11830. label.AppendLine("全程五星酒店,每人1间房");
  11831. foreach (var item in accomCosts.Infos)
  11832. {
  11833. string hotelName = string.Empty;
  11834. if (item.FeeName.Contains("-"))
  11835. {
  11836. var feeName = item.FeeName.Split('-');
  11837. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11838. }
  11839. else hotelName = $"\r\n{item.FeeName}:";
  11840. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11841. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11842. rate = rateInfo?.Rate ?? 1.0000M;
  11843. label.Append(hotelName);
  11844. label.Append(item.UnitPrice.TruncDecimals(2));
  11845. label.Append(currencyName);
  11846. label.Append("/间/晚*");
  11847. label.Append(item.Quantity.ToString("#0"));
  11848. label.AppendLine("人");
  11849. }
  11850. if (label.HasValue())
  11851. {
  11852. label.Append("\r\n以上小计:");
  11853. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11854. label.Append("元(");
  11855. label.Append(currencyName);
  11856. label.Append("汇率:");
  11857. label.Append(rate.TruncDecimals(4));
  11858. label.Append(")");
  11859. }
  11860. designer.SetDataSource("AccomLabel", label.ToString());
  11861. }
  11862. #endregion
  11863. #region 餐饮费
  11864. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11865. if (mealCosts.Infos.Any())
  11866. {
  11867. string currencyName = string.Empty;
  11868. decimal rate = 1.0000M;
  11869. StringBuilder label = new StringBuilder();
  11870. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11871. foreach (var item in mealCosts.Infos)
  11872. {
  11873. string name = string.Empty;
  11874. if (item.FeeName.Contains("-"))
  11875. {
  11876. var feeName = item.FeeName.Split('-');
  11877. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11878. }
  11879. else name = $"\r\n{item.FeeName}:";
  11880. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11881. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11882. rate = rateInfo?.Rate ?? 1.0000M;
  11883. label.Append(name);
  11884. label.Append(item.UnitPrice.TruncDecimals(2));
  11885. label.Append(currencyName);
  11886. label.Append("/天*");
  11887. label.Append(item.Quantity.ToString("#0"));
  11888. label.Append("*");
  11889. label.Append(item.PplNum);
  11890. label.Append("人\r\n");
  11891. }
  11892. if (label.HasValue())
  11893. {
  11894. label.Append("\r\n以上小计:");
  11895. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11896. label.Append("元\r\n(");
  11897. label.Append("汇率:");
  11898. label.Append(rate.TruncDecimals(4));
  11899. label.Append(")");
  11900. }
  11901. designer.SetDataSource("MealLabel", label.ToString());
  11902. }
  11903. #endregion
  11904. #region 车辆安排
  11905. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11906. if (vehArranges.Infos.Any())
  11907. {
  11908. string currencyName = string.Empty;
  11909. //decimal rate = 1.0000M;
  11910. StringBuilder label = new StringBuilder();
  11911. foreach (var item in vehArranges.Infos)
  11912. {
  11913. label.Append(item.Remark);
  11914. label.AppendLine();
  11915. label.AppendLine();
  11916. label.Append(item.FeeName);
  11917. label.Append("\r\n\r\n费用:");
  11918. label.Append(item.FeeName);
  11919. label.Append(item.TotalAmt.TruncDecimals(2));
  11920. }
  11921. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11922. }
  11923. #endregion
  11924. #region 邀请函发放对象
  11925. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11926. #endregion
  11927. designer.Process();
  11928. //文件名
  11929. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11930. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11931. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11932. return Ok(JsonView(true, "成功", url));
  11933. }
  11934. #endregion
  11935. #region 签证费用录入
  11936. /// <summary>
  11937. /// 根据diid查询签证费用列表
  11938. /// </summary>
  11939. /// <param name="dto"></param>
  11940. /// <returns></returns>
  11941. [HttpPost]
  11942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11943. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11944. {
  11945. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11946. if (groupData.Code != 0)
  11947. {
  11948. return Ok(JsonView(false, groupData.Msg));
  11949. }
  11950. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11951. }
  11952. /// <summary>
  11953. /// 根据签证费用Id查询单条数据及c表数据
  11954. /// </summary>
  11955. /// <param name="dto"></param>
  11956. /// <returns></returns>
  11957. [HttpPost]
  11958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11959. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11960. {
  11961. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11962. if (groupData.Code != 0)
  11963. {
  11964. return Ok(JsonView(false, groupData.Msg));
  11965. }
  11966. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11967. }
  11968. /// <summary>
  11969. /// 签证费用删除
  11970. /// </summary>
  11971. /// <param name="dto"></param>
  11972. /// <returns></returns>
  11973. [HttpPost]
  11974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11975. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11976. {
  11977. _sqlSugar.BeginTran();
  11978. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11979. if (!res)
  11980. {
  11981. _sqlSugar.RollbackTran();
  11982. return Ok(JsonView(false, "删除失败"));
  11983. }
  11984. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11985. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  11986. .SetColumns(a => new Grp_CreditCardPayment()
  11987. {
  11988. IsDel = 1,
  11989. DeleteUserId = dto.DeleteUserId,
  11990. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11991. })
  11992. .ExecuteCommand();
  11993. if (resSub < 1)
  11994. {
  11995. _sqlSugar.RollbackTran();
  11996. return Ok(JsonView(false, "删除失败"));
  11997. }
  11998. _sqlSugar.CommitTran();
  11999. return Ok(JsonView(true, "删除成功!"));
  12000. }
  12001. /// <summary>
  12002. /// 签证费用录入下拉框初始化
  12003. /// </summary>
  12004. /// <returns></returns>
  12005. [HttpPost]
  12006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12007. public async Task<IActionResult> VisaPriceAddSelect()
  12008. {
  12009. //支付方式
  12010. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12011. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12012. //币种
  12013. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12014. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12015. //乘客类型
  12016. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12017. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12018. //卡类型
  12019. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12020. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12021. //代办费类型
  12022. var agencyFeeTypeData = new List<dynamic>() {
  12023. new { id = 0 , Text = "未选择" },
  12024. new { id = 1 , Text = "小公务" },
  12025. new { id = 2 , Text = "大公务" },
  12026. };
  12027. //签证费用标准国家Data
  12028. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12029. var data = new
  12030. {
  12031. Payment = _Payment,
  12032. CurrencyList = _CurrencyList,
  12033. PassengerType = _PassengerType,
  12034. BankCard = _BankCard,
  12035. AgencyFeeType = agencyFeeTypeData,
  12036. CountryFeeData = visaCountryFeeData
  12037. };
  12038. return Ok(JsonView(true, "查询成功!", data));
  12039. }
  12040. /// <summary>
  12041. /// 签证费用录入操作(Status:1.新增,2.修改)
  12042. /// </summary>
  12043. /// <param name="dto"></param>
  12044. /// <returns></returns>
  12045. [HttpPost]
  12046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12047. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12048. {
  12049. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12050. if (groupData.Code != 0)
  12051. {
  12052. return Ok(JsonView(false, groupData.Msg));
  12053. }
  12054. #region 应用推送
  12055. try
  12056. {
  12057. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12058. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12059. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12060. //2024-10-21 新增LZ UID
  12061. var userIds = new List<int>() { 21 };
  12062. string title = $"系统通知";
  12063. string content = "";
  12064. var diId = dto.DiId;
  12065. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12066. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12067. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12068. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12069. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12070. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12071. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12072. }
  12073. catch (Exception ex)
  12074. {
  12075. }
  12076. #endregion
  12077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12078. }
  12079. #endregion
  12080. #region 签证提成录入
  12081. /// <summary>
  12082. /// 签证提成录入
  12083. /// 基础数据
  12084. /// </summary>
  12085. /// <returns></returns>
  12086. [HttpGet]
  12087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12088. public async Task<IActionResult> VisaCommissionInit()
  12089. {
  12090. return Ok(await _visaCommissionRep.Init());
  12091. }
  12092. /// <summary>
  12093. /// 签证提成录入
  12094. /// Item
  12095. /// </summary>
  12096. /// <param name="_dto"></param>
  12097. /// <returns></returns>
  12098. [HttpPost]
  12099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12100. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12101. {
  12102. var validator = new VisaCommissionItemDtoValidator();
  12103. var validatorRes = await validator.ValidateAsync(_dto);
  12104. if (!validatorRes.IsValid)
  12105. {
  12106. StringBuilder sb = new StringBuilder();
  12107. foreach (var item in validatorRes.Errors)
  12108. {
  12109. sb.AppendLine(item.ErrorMessage);
  12110. }
  12111. return Ok(JsonView(false, sb.ToString()));
  12112. }
  12113. return Ok(await _visaCommissionRep.Item(_dto));
  12114. }
  12115. /// <summary>
  12116. /// 签证提成录入
  12117. /// Save
  12118. /// </summary>
  12119. /// <param name="_dto"></param>
  12120. /// <returns></returns>
  12121. [HttpPost]
  12122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12123. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12124. {
  12125. //参数验证
  12126. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12127. foreach (var item in _dto.Items)
  12128. {
  12129. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12130. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12131. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12132. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12133. }
  12134. return Ok(await _visaCommissionRep.Save(_dto));
  12135. }
  12136. /// <summary>
  12137. /// 签证提成录入
  12138. /// Create
  12139. /// </summary>
  12140. /// <param name="_dto"></param>
  12141. /// <returns></returns>
  12142. [HttpPost]
  12143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12144. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12145. {
  12146. var validator = new VisaCommissionCreateDtoValidator();
  12147. var validatorRes = await validator.ValidateAsync(_dto);
  12148. if (!validatorRes.IsValid)
  12149. {
  12150. StringBuilder sb = new StringBuilder();
  12151. foreach (var item in validatorRes.Errors)
  12152. {
  12153. sb.AppendLine(item.ErrorMessage);
  12154. }
  12155. return Ok(JsonView(false, sb.ToString()));
  12156. }
  12157. return Ok(await _visaCommissionRep.Create(_dto));
  12158. }
  12159. /// <summary>
  12160. /// 签证提成录入
  12161. /// Put(编辑)
  12162. /// </summary>
  12163. /// <param name="id"></param>
  12164. /// <param name="_dto"></param>
  12165. /// <returns></returns>
  12166. [HttpPut]
  12167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12168. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12169. {
  12170. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12171. var validator = new VisaCommissionCreateDtoValidator();
  12172. var validatorRes = await validator.ValidateAsync(_dto);
  12173. if (!validatorRes.IsValid)
  12174. {
  12175. StringBuilder sb = new StringBuilder();
  12176. foreach (var item in validatorRes.Errors)
  12177. {
  12178. sb.AppendLine(item.ErrorMessage);
  12179. }
  12180. return Ok(JsonView(false, sb.ToString()));
  12181. }
  12182. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12183. }
  12184. /// <summary>
  12185. /// 签证提成录入
  12186. /// Del
  12187. /// </summary>
  12188. /// <param name="id"></param>
  12189. /// <param name="currUserId"></param>
  12190. /// <returns></returns>
  12191. [HttpPost]
  12192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12193. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12194. {
  12195. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12196. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12197. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12198. }
  12199. #endregion
  12200. #region op费用录入
  12201. /// <summary>
  12202. /// 根据diid查询op费用列表
  12203. /// </summary>
  12204. /// <param name="dto"></param>
  12205. /// <returns></returns>
  12206. [HttpPost]
  12207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12208. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12209. {
  12210. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12211. if (groupData.Code != 0)
  12212. {
  12213. return Ok(JsonView(false, groupData.Msg));
  12214. }
  12215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12216. }
  12217. /// <summary>
  12218. /// 根据op费用Id查询单条数据及c表数据
  12219. /// </summary>
  12220. /// <param name="dto"></param>
  12221. /// <returns></returns>
  12222. [HttpPost]
  12223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12224. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12225. {
  12226. try
  12227. {
  12228. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12229. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12230. var data = new
  12231. {
  12232. CarTouristGuideGround = _groupData,
  12233. CreditCardPayment = _creditCardPayment
  12234. };
  12235. return Ok(JsonView(true, "查询成功!", data));
  12236. }
  12237. catch (Exception ex)
  12238. {
  12239. return Ok(JsonView(false, "程序错误!"));
  12240. }
  12241. }
  12242. /// <summary>
  12243. /// op费用删除
  12244. /// </summary>
  12245. /// <param name="dto"></param>
  12246. /// <returns></returns>
  12247. [HttpPost]
  12248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12249. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12250. {
  12251. try
  12252. {
  12253. _sqlSugar.BeginTran();
  12254. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12255. if (!res)
  12256. {
  12257. return Ok(JsonView(false, "删除失败"));
  12258. }
  12259. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12260. {
  12261. IsDel = 1,
  12262. DeleteUserId = dto.DeleteUserId,
  12263. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12264. }).ExecuteCommandAsync();
  12265. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12266. {
  12267. IsDel = 1,
  12268. DeleteUserId = dto.DeleteUserId,
  12269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12270. }).ExecuteCommandAsync();
  12271. #region 删除超支相关数据
  12272. //删除导入的超支数据
  12273. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12274. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12275. {
  12276. IsDel = 1,
  12277. DeleteUserId = dto.DeleteUserId,
  12278. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12279. }).ExecuteCommand();
  12280. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12281. {
  12282. IsDel = 1,
  12283. DeleteUserId = dto.DeleteUserId,
  12284. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12285. }).ExecuteCommand();
  12286. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12287. {
  12288. IsDel = 1,
  12289. DeleteUserId = dto.DeleteUserId,
  12290. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12291. }).ExecuteCommand();
  12292. #endregion
  12293. _sqlSugar.CommitTran();
  12294. return Ok(JsonView(true, "删除成功!"));
  12295. }
  12296. catch (Exception ex)
  12297. {
  12298. _sqlSugar.RollbackTran();
  12299. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12300. }
  12301. }
  12302. /// <summary>
  12303. /// op费用录入操作(Status:1.新增,2.修改)
  12304. /// </summary>
  12305. /// <param name="dto"></param>
  12306. /// <returns></returns>
  12307. [HttpPost]
  12308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12309. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12310. {
  12311. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12312. if (groupData.Code != 0)
  12313. {
  12314. return Ok(JsonView(false, groupData.Msg));
  12315. }
  12316. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12317. }
  12318. /// <summary>
  12319. /// 填写费用详细页面初始化绑定
  12320. /// </summary>
  12321. /// <param name="dto"></param>
  12322. /// <returns></returns>
  12323. [HttpPost]
  12324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12325. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12326. {
  12327. try
  12328. {
  12329. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12330. if (groupData.Code != 0)
  12331. {
  12332. return Ok(JsonView(false, groupData.Msg));
  12333. }
  12334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12335. }
  12336. catch (Exception ex)
  12337. {
  12338. return Ok(JsonView(false, ex.Message));
  12339. }
  12340. }
  12341. /// <summary>
  12342. /// 根据op费用Id查询详细数据
  12343. /// </summary>
  12344. /// <param name="dto"></param>
  12345. /// <returns></returns>
  12346. [HttpPost]
  12347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12348. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12349. {
  12350. try
  12351. {
  12352. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12353. if (groupData.Code != 0)
  12354. {
  12355. return Ok(JsonView(false, groupData.Msg));
  12356. }
  12357. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12358. }
  12359. catch (Exception ex)
  12360. {
  12361. return Ok(JsonView(false, ex.Message));
  12362. }
  12363. }
  12364. /// <summary>
  12365. /// OP费用录入填写详情
  12366. /// </summary>
  12367. /// <param name="dto"></param>
  12368. /// <returns></returns>
  12369. [HttpPost]
  12370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12371. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12372. {
  12373. try
  12374. {
  12375. #region 参数校验
  12376. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12377. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12378. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12379. #endregion
  12380. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12381. if (groupData.Code != 0)
  12382. {
  12383. return Ok(JsonView(false, groupData.Msg));
  12384. }
  12385. //自动审核
  12386. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12387. #region 应用推送
  12388. try
  12389. {
  12390. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12391. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12392. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12393. //2024-10-21 新增LZ UID
  12394. var userIds = new List<int>() { 21 };
  12395. string title = $"系统通知";
  12396. var diId = dto.DiId;
  12397. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12398. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12399. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12400. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12401. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12402. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12403. }
  12404. catch (Exception ex)
  12405. {
  12406. }
  12407. #endregion
  12408. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12409. }
  12410. catch (Exception ex)
  12411. {
  12412. return Ok(JsonView(false, ex.Message));
  12413. }
  12414. }
  12415. /// <summary>
  12416. /// 获取三公详细所有城市
  12417. /// </summary>
  12418. /// <returns></returns>
  12419. [HttpGet]
  12420. public IActionResult OpCarCityResult()
  12421. {
  12422. var jw = JsonView(false);
  12423. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12424. {
  12425. x.Id,
  12426. x.Country,
  12427. x.City,
  12428. }).ToList();
  12429. if (data.Count > 0)
  12430. {
  12431. jw = JsonView(true, "获取成功!", data);
  12432. }
  12433. else
  12434. {
  12435. jw.Msg = "城市数据为空!";
  12436. jw.Data = new string[0];
  12437. }
  12438. return Ok(jw);
  12439. }
  12440. /// <summary>
  12441. /// 导出地接费用明细
  12442. /// </summary>
  12443. /// <param name="dto"></param>
  12444. /// <returns></returns>
  12445. [HttpPost]
  12446. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12447. {
  12448. var jw = JsonView(false);
  12449. if (dto.Diid < 1)
  12450. {
  12451. jw.Msg = "请输入正确的diid!";
  12452. return Ok(jw);
  12453. }
  12454. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12455. if (group == null)
  12456. {
  12457. jw.Msg = "未找到团组信息!";
  12458. return Ok(jw);
  12459. }
  12460. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12461. if (localGuideArr.Count == 0)
  12462. {
  12463. jw.Msg = "该团组暂无地接信息!";
  12464. return Ok(jw);
  12465. }
  12466. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12467. var overspendSoure = new Dictionary<int, int>
  12468. {
  12469. { 91, 982 }, //车
  12470. { 92 , 1059} ,//导游
  12471. { 994 , 1073}, //翻译
  12472. { 988 , 1074 }, //早餐
  12473. { 93 , 1075 }, //午餐
  12474. { 989 , 1076 }, //晚餐
  12475. };
  12476. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12477. foreach (var groupArr in localGroup)
  12478. {
  12479. var keyValue = groupArr.Key;
  12480. if (int.TryParse(keyValue, out int cityid))
  12481. {
  12482. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12483. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12484. }
  12485. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12486. foreach (var item in groupArr)
  12487. {
  12488. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12489. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12490. new Grp_CarTouristGuideGroundReservationsContentExtend
  12491. {
  12492. Count = a.Count,
  12493. CreateTime = a.CreateTime,
  12494. CreateUserId = a.CreateUserId,
  12495. CTGGRId = a.CTGGRId,
  12496. Currency = a.Currency,
  12497. DatePrice = a.DatePrice,
  12498. DeleteTime = a.DeleteTime,
  12499. DeleteUserId = a.DeleteUserId,
  12500. DiId = a.DiId,
  12501. Id = a.Id,
  12502. IsDel = a.IsDel,
  12503. Price = a.Price,
  12504. PriceContent = a.PriceContent,
  12505. Remark = a.Remark,
  12506. SId = a.SId,
  12507. SidName = b.Name,
  12508. Units = a.Units,
  12509. }
  12510. ).ToList();
  12511. if (content.Count > 0)
  12512. {
  12513. contentArr.Add(content);
  12514. }
  12515. }
  12516. //open excel
  12517. //set excel
  12518. //save excel
  12519. try
  12520. {
  12521. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12522. IWorkbook workbook;
  12523. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12524. {
  12525. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12526. }
  12527. else
  12528. {
  12529. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12530. }
  12531. ISheet sheet = workbook.GetSheetAt(0);
  12532. var rowStartIndex = 2;
  12533. var clounmCount = 10;
  12534. var initStyleRow = sheet.GetRow(2);
  12535. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12536. //var overspendArrDetail =
  12537. var existsId = new List<CarCompare>();
  12538. var lastElem = arr.Last();
  12539. var thisSid = -1;
  12540. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12541. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12542. {
  12543. Name = "未知币种!",
  12544. Remark = "未知币种!",
  12545. };
  12546. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12547. Action cloneRowFn = () =>
  12548. {
  12549. rowStartIndex++;
  12550. var cloneRow = sheet.CreateRow(rowStartIndex);
  12551. // 复制样式
  12552. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12553. {
  12554. ICell sourceCell = initStyleRow.GetCell(i);
  12555. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12556. // 确保单元格存在样式
  12557. if (sourceCell.CellStyle != null)
  12558. {
  12559. targetCell.CellStyle = sourceCell.CellStyle;
  12560. }
  12561. }
  12562. };
  12563. var mergeRow = () =>
  12564. {
  12565. for (int i = 2; i < sheet.LastRowNum; i++)
  12566. {
  12567. var row = sheet.GetRow(i);
  12568. var cellFirst = row.GetCell(0);
  12569. var thisIndex = i + 1;
  12570. while (thisIndex < sheet.LastRowNum)
  12571. {
  12572. var nextRow = sheet.GetRow(thisIndex);
  12573. var nextCellFirst = nextRow.GetCell(0);
  12574. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12575. {
  12576. thisIndex++;
  12577. }
  12578. else
  12579. {
  12580. break;
  12581. }
  12582. }
  12583. thisIndex--;
  12584. if (thisIndex != i)
  12585. {
  12586. //合并row
  12587. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12588. i, // 起始行索引(0-based)
  12589. thisIndex, // 结束行索引(0-based)
  12590. 0, // 起始列索引(0-based)
  12591. 0 // 结束列索引(0-based)
  12592. );
  12593. sheet.AddMergedRegion(cellRangeAddress);
  12594. i = thisIndex;
  12595. }
  12596. }
  12597. };
  12598. var chaoshiNumber = 0;
  12599. var totalNumber = 0.00M;
  12600. string lastStr = "";
  12601. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12602. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12603. {
  12604. b.IsAuditGM,
  12605. x.Id,
  12606. x.Area,
  12607. b.PayPercentage,
  12608. b.PayMoney,
  12609. }).ToList();
  12610. string yesPayment = "", noPayment = "";
  12611. foreach (var item in queryCarArrByCityAndDiid)
  12612. {
  12613. if (item.IsAuditGM == 1)
  12614. {
  12615. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12616. }
  12617. else
  12618. {
  12619. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12620. }
  12621. }
  12622. lastStr = yesPayment + noPayment;
  12623. foreach (var item in arr)
  12624. {
  12625. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12626. {
  12627. if (thisSid != item.SId)
  12628. {
  12629. if (thisSid == -1)
  12630. {
  12631. thisSid = item.SId;
  12632. }
  12633. else
  12634. {
  12635. //合并小计行
  12636. //创建合并区域的实例
  12637. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12638. rowStartIndex, // 起始行索引(0-based)
  12639. rowStartIndex, // 结束行索引(0-based)
  12640. 0, // 起始列索引(0-based)
  12641. 3 // 结束列索引(0-based)
  12642. );
  12643. sheet.AddMergedRegion(cellRangeAddress);
  12644. var CellStyle = workbook.CreateCellStyle();
  12645. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12646. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12647. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12648. for (int i = 0; i <= clounmCount; i++)
  12649. {
  12650. if (i > 6)
  12651. {
  12652. var CellStyle1 = workbook.CreateCellStyle();
  12653. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12654. IFont Font = workbook.CreateFont(); // 创建字体
  12655. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12656. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12657. CellStyle1.SetFont(Font);
  12658. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12659. }
  12660. else
  12661. {
  12662. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12663. }
  12664. }
  12665. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12666. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12667. //超时合计
  12668. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12669. //超时数
  12670. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12671. //超时合计费用
  12672. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12673. thisSid = item.SId;
  12674. cloneRowFn();
  12675. chaoshiNumber = 0;
  12676. totalNumber = 0;
  12677. }
  12678. }
  12679. IRow row = sheet.GetRow(rowStartIndex);
  12680. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12681. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12682. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12683. if (isOpenOverspendSoure)
  12684. {
  12685. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12686. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12687. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12688. }
  12689. for (int i = 0; i <= clounmCount; i++)
  12690. {
  12691. var cell = row.GetCell(i);
  12692. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12693. if (cell == null)
  12694. {
  12695. cell = row.CreateCell(i);
  12696. }
  12697. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12698. fontRed.CloneStyleFrom(cell.CellStyle);
  12699. IFont Font = workbook.CreateFont(); // 创建字体
  12700. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12701. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12702. fontRed.SetFont(Font);
  12703. byte[] rgb = new byte[3] { 255, 242, 204 };
  12704. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12705. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12706. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12707. if (workbook is XSSFWorkbook)
  12708. {
  12709. BackgroundColor255_242_204.FillForegroundColor = 0;
  12710. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12711. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12712. }
  12713. else
  12714. {
  12715. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12716. }
  12717. if (i == 1 || i > 6)
  12718. {
  12719. if (i > 6)
  12720. {
  12721. fontRed.FillForegroundColor = 0;
  12722. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12723. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12724. }
  12725. cell.CellStyle = fontRed;
  12726. }
  12727. if (i > 2 && i < 7)
  12728. {
  12729. cell.CellStyle = BackgroundColor255_242_204;
  12730. }
  12731. cell.SetCellValue(setCellValue); //写入单元格
  12732. }
  12733. if (overspendSoure.ContainsKey(thisSid))
  12734. {
  12735. var overspendId = overspendSoure[thisSid];
  12736. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12737. }
  12738. cloneRowFn();
  12739. existsId.Add(new CarCompare
  12740. {
  12741. DataPrice = item.DatePrice.ObjToDate(),
  12742. Sid = item.SId
  12743. });
  12744. }
  12745. if (item.Equals(lastElem))
  12746. {
  12747. //合并小计行
  12748. //创建合并区域的实例
  12749. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12750. rowStartIndex, // 起始行索引(0-based)
  12751. rowStartIndex, // 结束行索引(0-based)
  12752. 0, // 起始列索引(0-based)
  12753. 3 // 结束列索引(0-based)
  12754. );
  12755. sheet.AddMergedRegion(cellRangeAddress);
  12756. var CellStyle = workbook.CreateCellStyle();
  12757. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12758. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12759. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12760. for (int i = 0; i <= clounmCount; i++)
  12761. {
  12762. if (i > 6)
  12763. {
  12764. var CellStyle1 = workbook.CreateCellStyle();
  12765. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12766. IFont Font = workbook.CreateFont(); // 创建字体
  12767. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12768. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12769. CellStyle1.SetFont(Font);
  12770. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12771. }
  12772. else
  12773. {
  12774. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12775. }
  12776. }
  12777. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12778. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12779. //超时合计
  12780. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12781. //超时数
  12782. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12783. //超时合计费用
  12784. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12785. cloneRowFn();
  12786. // 创建合并区域的实例
  12787. cellRangeAddress = new CellRangeAddress(
  12788. rowStartIndex, // 起始行索引(0-based)
  12789. rowStartIndex, // 结束行索引(0-based)
  12790. 0, // 起始列索引(0-based)
  12791. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12792. );
  12793. // 添加合并区域
  12794. sheet.AddMergedRegion(cellRangeAddress);
  12795. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12796. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12797. }
  12798. }
  12799. mergeRow();
  12800. // 保存修改后的Excel文件到新文件
  12801. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12802. // new FileStream(newFilePath, FileMode.CreateNew)
  12803. using (var stream = new MemoryStream())
  12804. {
  12805. workbook.Write(stream, true);
  12806. stream.Flush();
  12807. stream.Seek(0, SeekOrigin.Begin);
  12808. MemoryStream memoryStream = new MemoryStream();
  12809. stream.CopyTo(memoryStream);
  12810. memoryStream.Seek(0, SeekOrigin.Begin);
  12811. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12812. }
  12813. workbook.Close();
  12814. workbook.Dispose();
  12815. }
  12816. catch (Exception ex)
  12817. {
  12818. jw.Msg = "出现异常!" + ex.Message;
  12819. return Ok(jw);
  12820. }
  12821. }
  12822. if (Zips.Count > 0)
  12823. {
  12824. IOOperatorHelper io = new IOOperatorHelper();
  12825. var byts = io.ConvertZipStream(Zips);
  12826. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12827. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12828. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12829. }
  12830. else
  12831. {
  12832. jw.Msg = "暂无生成文件!";
  12833. }
  12834. return Ok(jw);
  12835. }
  12836. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12837. {
  12838. string outStr = string.Empty;
  12839. switch (i)
  12840. {
  12841. case 0:
  12842. outStr = arr[0].SidName;
  12843. break;
  12844. case 1:
  12845. outStr = arr[0].DataPriceStr;
  12846. break;
  12847. case 2:
  12848. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  12849. break;
  12850. case 4:
  12851. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  12852. break;
  12853. case 7:
  12854. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12855. {
  12856. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  12857. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  12858. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  12859. }
  12860. break;
  12861. case 8:
  12862. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12863. {
  12864. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12865. }
  12866. break;
  12867. case 9:
  12868. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12869. {
  12870. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12871. }
  12872. break;
  12873. case 10:
  12874. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12875. {
  12876. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12877. }
  12878. break;
  12879. }
  12880. return outStr;
  12881. }
  12882. #region OP行程单
  12883. /// <summary>
  12884. /// OP行程单初始化
  12885. /// </summary>
  12886. /// <param name="dto"></param>
  12887. /// <returns></returns>
  12888. [HttpPost]
  12889. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12890. {
  12891. var jw = JsonView(false);
  12892. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12893. var group = groupList.First();
  12894. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12895. if (group == null)
  12896. {
  12897. jw.Msg = "暂无团组!";
  12898. return Ok(jw);
  12899. }
  12900. group = groupList.Find(x => x.Id == diid);
  12901. if (group == null)
  12902. {
  12903. jw.Msg = "请输入正确的团组ID!";
  12904. return Ok(jw);
  12905. }
  12906. string city = string.Empty;
  12907. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12908. if (blackCode.Count > 0)
  12909. {
  12910. var black = blackCode.First();
  12911. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12912. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12913. if (blackSp.Length > 0)
  12914. {
  12915. try
  12916. {
  12917. var cityArrCode = new List<string>(20);
  12918. foreach (var item in blackSp)
  12919. {
  12920. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12921. var IndexSelect = itemSp[2];
  12922. var cityArrCodeLength = cityArrCode.Count - 1;
  12923. var startCity = IndexSelect.Substring(0, 3);
  12924. if (cityArrCodeLength > 0)
  12925. {
  12926. var arrEndCity = cityArrCode[cityArrCodeLength];
  12927. if (arrEndCity != startCity)
  12928. {
  12929. cityArrCode.Add(startCity.ToUpper());
  12930. }
  12931. }
  12932. else
  12933. {
  12934. cityArrCode.Add(startCity.ToUpper());
  12935. }
  12936. var endCity = IndexSelect.Substring(3, 3);
  12937. cityArrCode.Add(endCity.ToUpper());
  12938. }
  12939. var cityThree = string.Empty;
  12940. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12941. cityThree = cityThree.TrimEnd(',');
  12942. if (string.IsNullOrWhiteSpace(cityThree))
  12943. {
  12944. throw new
  12945. Exception("error");
  12946. }
  12947. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12948. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12949. foreach (var item in cityArrCode)
  12950. {
  12951. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12952. if (find != null)
  12953. {
  12954. city += find.City + "/";
  12955. }
  12956. else
  12957. {
  12958. city += item + "三字码未收入/";
  12959. }
  12960. }
  12961. city = city.TrimEnd('/');
  12962. }
  12963. catch (Exception e)
  12964. {
  12965. city = "黑屏代码格式不正确!";
  12966. }
  12967. }
  12968. }
  12969. else
  12970. {
  12971. city = "未录入黑屏代码";
  12972. }
  12973. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12974. {
  12975. Date = x.Date,
  12976. Days = x.Days,
  12977. Diffgroup = x.Diffgroup,
  12978. Diid = x.Diid,
  12979. Traffic_First = x.Traffic_First,
  12980. Traffic_Second = x.Traffic_Second,
  12981. Trip = x.Trip,
  12982. WeekDay = x.WeekDay,
  12983. Id = x.Id
  12984. }).ToList();
  12985. jw.Data = new
  12986. {
  12987. groupList = groupList.Select(x => new
  12988. {
  12989. x.Id,
  12990. x.TeamName,
  12991. x.TourCode
  12992. }).ToList(),
  12993. groupInfo = new
  12994. {
  12995. group.VisitDays,
  12996. group.TourCode,
  12997. group.VisitPNumber,
  12998. group.TeamName,
  12999. city
  13000. },
  13001. OpTravelList
  13002. };
  13003. jw.Code = 200;
  13004. jw.Msg = "操作成功!";
  13005. return Ok(jw);
  13006. }
  13007. /// <summary>
  13008. /// 删除团组行程单
  13009. /// </summary>
  13010. /// <returns></returns>
  13011. [HttpPost]
  13012. public IActionResult DelTravel(DelOpTravelDto dto)
  13013. {
  13014. var jw = JsonView(false);
  13015. if (dto.UserId <= 0 || dto.Diid <= 0)
  13016. {
  13017. jw.Msg = "请输入正确的参数!";
  13018. return Ok(jw);
  13019. }
  13020. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13021. .SetColumns(x => new Grp_TravelList
  13022. {
  13023. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13024. DeleteUserId = dto.UserId,
  13025. IsDel = 1,
  13026. }).ExecuteCommand();
  13027. jw = JsonView(true);
  13028. return Ok(jw);
  13029. }
  13030. /// <summary>
  13031. /// 行程单保存
  13032. /// </summary>
  13033. /// <returns></returns>
  13034. [HttpPost]
  13035. public IActionResult TravelSave(TravelSaveDto dto)
  13036. {
  13037. var jw = JsonView(false);
  13038. if (dto.Arr.Count > 0)
  13039. {
  13040. try
  13041. {
  13042. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13043. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13044. .ToList();
  13045. _sqlSugar.BeginTran();
  13046. foreach (var item in dto.Arr)
  13047. {
  13048. if (item.Id == 0)
  13049. {
  13050. throw new Exception("请传入正确的Id");
  13051. }
  13052. //比较上一次的差异
  13053. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13054. if (findTravel != null)
  13055. {
  13056. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13057. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13058. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13059. }
  13060. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13061. .SetColumns(x => new Grp_TravelList
  13062. {
  13063. Trip = item.Trip
  13064. }).ExecuteCommand();
  13065. }
  13066. _sqlSugar.CommitTran();
  13067. jw = JsonView(true);
  13068. }
  13069. catch (Exception ex)
  13070. {
  13071. _sqlSugar.RollbackTran();
  13072. jw.Msg = "程序异常!" + ex.Message;
  13073. }
  13074. }
  13075. else
  13076. {
  13077. jw.Msg = "请传入正确的参数!";
  13078. }
  13079. return Ok(jw);
  13080. }
  13081. private string CheckStr(string original, string changed)
  13082. {
  13083. // 创建diff_match_patch对象
  13084. var dmp = new diff_match_patch();
  13085. // 计算差异
  13086. List<Diff> diffs = dmp.diff_main(original, changed);
  13087. // 清理和合并差异
  13088. dmp.diff_cleanupSemantic(diffs);
  13089. // 使用StringBuilder构建最终的字符串
  13090. StringBuilder finalString = new StringBuilder();
  13091. // 输出差异结果,并构建变动后的字符串
  13092. foreach (Diff diff in diffs)
  13093. {
  13094. switch (diff.operation)
  13095. {
  13096. case Operation.EQUAL:
  13097. // 相等的部分,直接添加到最终字符串
  13098. finalString.Append(diff.text);
  13099. break;
  13100. case Operation.INSERT:
  13101. // 插入的部分,添加标记并添加到最终字符串
  13102. finalString.Append("[++]" + diff.text + "[++]");
  13103. break;
  13104. case Operation.DELETE:
  13105. // 删除的部分,不添加到最终字符串
  13106. //finalString.Append("[++]" + diff.text + "[++]");
  13107. break;
  13108. }
  13109. }
  13110. // 输出变动后的字符串
  13111. return finalString.ToString();
  13112. }
  13113. private class tagContent
  13114. {
  13115. public DateTime Date { get; set; }
  13116. public string StartTag { get; set; }
  13117. public string EndTag { get; set; }
  13118. public string Content { get; set; }
  13119. public static int tagLength { get { return 3; } }
  13120. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13121. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13122. public bool IsFinally { get; set; }
  13123. }
  13124. private List<string> ExtractContentBetweenTags(string input, string tag)
  13125. {
  13126. List<string> results = new List<string>();
  13127. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13128. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13129. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13130. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13131. string[] strValueArr = new string[1];
  13132. foreach (System.Text.RegularExpressions.Match match in matches)
  13133. {
  13134. var strValue = match.Groups[1].Value;
  13135. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13136. }
  13137. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13138. return results;
  13139. }
  13140. /// <summary>
  13141. /// 导出行程单
  13142. /// </summary>
  13143. /// <param name="dto"></param>
  13144. /// <returns></returns>
  13145. [HttpPost]
  13146. public IActionResult ExportTravel(ExportTravelDto dto)
  13147. {
  13148. var jw = JsonView(false);
  13149. jw.Data = "";
  13150. int diid = 0;
  13151. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13152. if (Find == null)
  13153. {
  13154. jw.Msg = "请选择正确的团组!";
  13155. return Ok(jw);
  13156. }
  13157. else
  13158. {
  13159. diid = Find.Id;
  13160. }
  13161. //数据源
  13162. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13163. DataTable dtBlack = null;
  13164. try
  13165. {
  13166. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13167. }
  13168. catch (Exception)
  13169. {
  13170. jw.Msg = "机票黑屏代码有误!";
  13171. return Ok(jw);
  13172. }
  13173. string CityStr = string.Empty;
  13174. if (dtBlack.Rows.Count == 0)
  13175. {
  13176. jw.Msg = "机票黑屏代码有误!";
  13177. return Ok(jw);
  13178. }
  13179. else
  13180. {
  13181. foreach (DataRow row in dtBlack.Rows)
  13182. {
  13183. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13184. {
  13185. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13186. return Ok(jw);
  13187. }
  13188. }
  13189. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13190. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13191. }
  13192. // 指定的文字
  13193. var targetTextDic = new Dictionary<string, List<string>>();
  13194. //创建数据源Table
  13195. DataTable dtSource = new DataTable();
  13196. dtSource.Columns.Add("Days", typeof(string));
  13197. dtSource.Columns.Add("Date", typeof(string));
  13198. dtSource.Columns.Add("Week", typeof(string));
  13199. dtSource.Columns.Add("Traffic", typeof(string));
  13200. dtSource.Columns.Add("Trip", typeof(string));
  13201. //获取数据,放到datatable
  13202. foreach (var item in _travelList)
  13203. {
  13204. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13205. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13206. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13207. .Replace("[++]", string.Empty);
  13208. DataRow dr = dtSource.NewRow();
  13209. dr["Days"] = item.Days;
  13210. dr["Date"] = item.Date;
  13211. dr["Week"] = item.WeekDay;
  13212. dr["Traffic"] = item.Traffic_First
  13213. + "\r\n"
  13214. + item.Traffic_Second;
  13215. dr["Trip"] = item.Trip;
  13216. dtSource.Rows.Add(dr);
  13217. }
  13218. Dictionary<string, string> dic = new Dictionary<string, string>();
  13219. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13220. dic.Add("City", CityStr);
  13221. dic.Add("Days", Find.VisitDays.ToString());
  13222. dic.Add("DeleCode", Find.TourCode);
  13223. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13224. //模板路径
  13225. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13226. //载入模板
  13227. Document doc = null;
  13228. DocumentBuilder builder = null;
  13229. try
  13230. {
  13231. //载入模板
  13232. doc = new Document(tempPath);
  13233. builder = new DocumentBuilder(doc);
  13234. }
  13235. catch (Exception)
  13236. {
  13237. jw.Msg = "模板位置不存在!";
  13238. return Ok(jw);
  13239. }
  13240. foreach (var key in dic.Keys)
  13241. {
  13242. Bookmark bookmark = doc.Range.Bookmarks[key];
  13243. if (bookmark != null)
  13244. {
  13245. builder.MoveToBookmark(key);
  13246. builder.Write(dic[key]);
  13247. }
  13248. }
  13249. //获取word里所有表格
  13250. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13251. //获取所填表格的序数
  13252. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13253. try
  13254. {
  13255. //循环赋值
  13256. for (int i = 0; i < dtSource.Rows.Count; i++)
  13257. {
  13258. builder.MoveToCell(0, i + 1, 0, 0);
  13259. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13260. builder.MoveToCell(0, i + 1, 1, 0);
  13261. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13262. builder.MoveToCell(0, i + 1, 2, 0);
  13263. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13264. var trip = dtSource.Rows[i]["Trip"].ToString();
  13265. builder.MoveToCell(0, i + 1, 3, 0);
  13266. builder.Write(trip);
  13267. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13268. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13269. // 获取特定索引的段落
  13270. Paragraph paragraph = (Paragraph)paragraphs[0];
  13271. Run run = paragraph.Runs[0];
  13272. Aspose.Words.Font font = run.Font;
  13273. font.Name = "黑体";
  13274. //设置双休红色
  13275. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13276. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13277. paragraph = (Paragraph)paragraphs[1];
  13278. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13279. {
  13280. run = paragraph.Runs[0];
  13281. font = run.Font;
  13282. font.Color = Color.Red;
  13283. }
  13284. }
  13285. }
  13286. catch (Exception ex)
  13287. {
  13288. }
  13289. //删除多余行
  13290. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13291. {
  13292. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13293. }
  13294. var targetTextList = new List<string>();
  13295. // 遍历文档中的表格
  13296. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13297. {
  13298. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13299. {
  13300. var cellIndex = 0;
  13301. foreach (Cell cell in row.Cells)
  13302. {
  13303. if (cellIndex == 1 && row.Cells.Count == 4)
  13304. {
  13305. foreach (var target in targetTextDic.Keys)
  13306. {
  13307. if (cell.GetText().Contains(target))
  13308. {
  13309. targetTextList = targetTextDic[target];
  13310. break;
  13311. }
  13312. }
  13313. }
  13314. // 遍历单元格中的所有段落
  13315. foreach (Paragraph paragraph in cell.Paragraphs)
  13316. {
  13317. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13318. List<Run> runs = new List<Run>();
  13319. foreach (Run run in paragraph.Runs)
  13320. {
  13321. runs.Add(run);
  13322. }
  13323. foreach (Run run in runs)
  13324. {
  13325. foreach (var targetText in targetTextList)
  13326. {
  13327. // 检查文字是否包含指定文字
  13328. if (run.Text.Contains(targetText))
  13329. {
  13330. // 将包含的部分设置为红色
  13331. HighlightText(run, targetText, Color.Red);
  13332. }
  13333. }
  13334. }
  13335. }
  13336. cellIndex++;
  13337. }
  13338. }
  13339. }
  13340. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13341. if (!Directory.Exists(savePath))
  13342. {
  13343. try
  13344. {
  13345. Directory.CreateDirectory(savePath);
  13346. }
  13347. catch
  13348. {
  13349. }
  13350. }
  13351. string path = savePath + Find.TeamName + "出访日程";
  13352. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13353. try
  13354. {
  13355. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13356. string postfix = ".docx";
  13357. if (dto.IsPDF == 1)
  13358. {
  13359. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13360. postfix = ".pdf";
  13361. }
  13362. doc.Save(path + postfix, saveFormat);
  13363. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13364. }
  13365. catch (Exception)
  13366. {
  13367. jw = JsonView(false);
  13368. }
  13369. return Ok(jw);
  13370. }
  13371. /// <summary>
  13372. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13373. /// </summary>
  13374. /// <param name="num"></param>
  13375. /// <returns></returns>
  13376. string GetNum(string num)
  13377. {
  13378. string str = "";
  13379. switch (num)
  13380. {
  13381. case "1":
  13382. str = "一";
  13383. break;
  13384. case "2":
  13385. str = "二";
  13386. break;
  13387. case "3":
  13388. str = "三";
  13389. break;
  13390. case "4":
  13391. str = "四";
  13392. break;
  13393. case "5":
  13394. str = "五";
  13395. break;
  13396. case "6":
  13397. str = "六";
  13398. break;
  13399. case "7":
  13400. str = "七";
  13401. break;
  13402. case "8":
  13403. str = "八";
  13404. break;
  13405. case "9":
  13406. str = "九";
  13407. break;
  13408. case "10":
  13409. str = "十";
  13410. break;
  13411. case "11":
  13412. str = "十一";
  13413. break;
  13414. case "12":
  13415. str = "十二";
  13416. break;
  13417. case "一":
  13418. str = "1";
  13419. break;
  13420. case "二":
  13421. str = "2";
  13422. break;
  13423. case "三":
  13424. str = "3";
  13425. break;
  13426. case "四":
  13427. str = "4";
  13428. break;
  13429. case "五":
  13430. str = "5";
  13431. break;
  13432. case "六":
  13433. str = "6";
  13434. break;
  13435. case "七":
  13436. str = "7";
  13437. break;
  13438. case "八":
  13439. str = "8";
  13440. break;
  13441. case "九":
  13442. str = "9";
  13443. break;
  13444. case "十":
  13445. str = "10";
  13446. break;
  13447. case "十一":
  13448. str = "11";
  13449. break;
  13450. case "十二":
  13451. str = "12";
  13452. break;
  13453. }
  13454. return str;
  13455. }
  13456. // 高亮包含指定文字的部分
  13457. void HighlightText(Run run, string targetText, Color color)
  13458. {
  13459. string text = run.Text;
  13460. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13461. if (startIndex >= 0)
  13462. {
  13463. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13464. // 前部分
  13465. if (startIndex > 0)
  13466. {
  13467. Run beforeRun = (Run)run.Clone(true);
  13468. beforeRun.Text = text.Substring(0, startIndex);
  13469. parentParagraph.InsertBefore(beforeRun, run);
  13470. }
  13471. // 匹配部分
  13472. Run matchRun = (Run)run.Clone(true);
  13473. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13474. matchRun.Font.Color = color;
  13475. parentParagraph.InsertBefore(matchRun, run);
  13476. // 后部分
  13477. if (startIndex + targetText.Length < text.Length)
  13478. {
  13479. Run afterRun = (Run)run.Clone(true);
  13480. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13481. parentParagraph.InsertBefore(afterRun, run);
  13482. }
  13483. // 删除原始Run
  13484. run.Remove();
  13485. }
  13486. }
  13487. #endregion
  13488. #endregion
  13489. #region 团组成本
  13490. /// <summary>
  13491. /// 团组成本数据初始化
  13492. /// </summary>
  13493. /// <param name="dto"></param>
  13494. /// <returns></returns>
  13495. [HttpPost]
  13496. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13497. {
  13498. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13499. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13500. WHEN COUNT(*) >= 0 THEN 'True'
  13501. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13502. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13503. ").ToList(); //团组列表
  13504. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13505. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13506. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13507. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13508. if (groupinfoValue != null)
  13509. {
  13510. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13511. var spArr = new string[1] { countryArr };
  13512. if (countryArr.Contains("|"))
  13513. {
  13514. spArr = countryArr.Split("|");
  13515. }
  13516. else if (countryArr.Contains("、"))
  13517. {
  13518. spArr = countryArr.Split("、");
  13519. }
  13520. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13521. {
  13522. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13523. if (dbQueryCountry != null)
  13524. {
  13525. visaCountryInfoArr.Add(dbQueryCountry);
  13526. }
  13527. }
  13528. }
  13529. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13530. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13531. #region 屏蔽黑屏代码生成
  13532. //var create = _GroupCostRepository.
  13533. // CreateGroupCostByBlackCode(dto.Diid);
  13534. //if (groupCost.Count == 0 && create.Code == 0)
  13535. //{
  13536. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13537. //}
  13538. #endregion
  13539. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13540. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13541. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13542. groupCostMap = groupCostMap.Select(x =>
  13543. {
  13544. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13545. {
  13546. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13547. }
  13548. return x;
  13549. }).ToList();
  13550. //GroupCostParameter.Add(new
  13551. // Grp_GroupCostParameter());
  13552. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13553. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13554. return Ok(JsonView(new
  13555. {
  13556. groupList,
  13557. groupInfo,
  13558. groupChecks,
  13559. groupCost = groupCostMap,
  13560. hotelNumber,
  13561. GroupCostParameter = GroupCostParameterMap,
  13562. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13563. {
  13564. x.VisaCountry,
  13565. x.VisaPrice,
  13566. x.Id,
  13567. }).ToList(),
  13568. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13569. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13570. hotelIsTrue = hotelIsTrue,
  13571. }));
  13572. }
  13573. /// <summary>
  13574. /// 团组成本信息保存
  13575. /// </summary>
  13576. /// <param name="dto"></param>
  13577. /// <returns></returns>
  13578. [HttpPost]
  13579. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13580. {
  13581. if (dto.Diid <= 0 || dto.Userid <= 0)
  13582. {
  13583. return Ok(JsonView(false));
  13584. }
  13585. JsonView jw = null;
  13586. bool isTrue = false;
  13587. #region 复制团组成本
  13588. //if (dto.Diid == 2581)
  13589. //{
  13590. // dto.Diid = 2599;
  13591. // dto.CheckBoxs.ForEach(x =>
  13592. // {
  13593. // x.Diid = 2599;
  13594. // });
  13595. // dto.GroupCosts.ForEach(x =>
  13596. // {
  13597. // x.Diid = 2599;
  13598. // });
  13599. // dto.CostTypeHotelNumbers.ForEach(x =>
  13600. // {
  13601. // x.Diid = 2599;
  13602. // });
  13603. // dto.GroupCostParameters.ForEach(x =>
  13604. // {
  13605. // x.DiId = 2599;
  13606. // });
  13607. //}
  13608. #endregion
  13609. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13610. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13611. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13612. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13613. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13614. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13615. try
  13616. {
  13617. _sqlSugar.BeginTran();
  13618. isTrue = await _GroupCostRepository.
  13619. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13620. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13621. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13622. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13623. _sqlSugar.CommitTran();
  13624. jw = JsonView(true, "保存成功!", isTrue);
  13625. }
  13626. catch (Exception)
  13627. {
  13628. _sqlSugar.RollbackTran();
  13629. jw = JsonView(false);
  13630. }
  13631. return Ok(jw);
  13632. }
  13633. /// <summary>
  13634. /// 司兼导数据
  13635. /// </summary>
  13636. /// <param name="dto"></param>
  13637. /// <returns></returns>
  13638. [HttpPost]
  13639. public IActionResult GetCarGuides(CarGuidesDto dto)
  13640. {
  13641. JsonView jw = null;
  13642. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13643. jw = JsonView(true, "获取成功!", Data);
  13644. return Ok(jw);
  13645. }
  13646. /// <summary>
  13647. /// 导游数据
  13648. /// </summary>
  13649. /// <param name="dto"></param>
  13650. /// <returns></returns>
  13651. [HttpPost]
  13652. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13653. {
  13654. JsonView jw = null;
  13655. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13656. // 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
  13657. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13658. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13659. jw = JsonView(true, "获取成功!", Data);
  13660. return Ok(jw);
  13661. }
  13662. /// <summary>
  13663. /// 成本车数据
  13664. /// </summary>
  13665. /// <param name="dto"></param>
  13666. /// <returns></returns>
  13667. [HttpPost]
  13668. public IActionResult GetCarInfo(CarGuidesDto dto)
  13669. {
  13670. JsonView jw = null;
  13671. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13672. jw = JsonView(true, "获取成功!", Data);
  13673. return Ok(jw);
  13674. }
  13675. /// <summary>
  13676. /// 景点数据
  13677. /// </summary>
  13678. /// <param name="dto"></param>
  13679. /// <returns></returns>
  13680. [HttpPost]
  13681. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13682. {
  13683. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13684. return Ok(JsonView(true, "获取成功!", Data));
  13685. }
  13686. /// <summary>
  13687. /// 成本通知
  13688. /// </summary>
  13689. /// <param name="dto"></param>
  13690. /// <returns></returns>
  13691. [HttpPost]
  13692. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13693. {
  13694. if (dto.Diid < 0)
  13695. {
  13696. return Ok(JsonView(false));
  13697. }
  13698. JsonView jw = null;
  13699. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13700. if (GroupCostParameter != null)
  13701. {
  13702. int IsShare = 0;
  13703. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13704. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13705. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13706. string msg = string.Empty;
  13707. if (isTrue)
  13708. {
  13709. if (IsShare == 0)
  13710. {
  13711. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13712. }
  13713. else
  13714. {
  13715. #region 企微通知对应岗位用户
  13716. try
  13717. {
  13718. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13719. }
  13720. catch (Exception ex)
  13721. {
  13722. }
  13723. #endregion
  13724. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13725. }
  13726. jw = JsonView(isTrue, msg, new { IsShare });
  13727. }
  13728. else
  13729. {
  13730. msg = "修改失败!";
  13731. jw = JsonView(isTrue, msg);
  13732. }
  13733. }
  13734. else
  13735. {
  13736. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13737. }
  13738. return Ok(jw);
  13739. }
  13740. /// <summary>
  13741. /// 导出报价单
  13742. /// </summary>
  13743. /// <param name="dto"></param>
  13744. /// <returns></returns>
  13745. [HttpPost]
  13746. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13747. {
  13748. if (dto.Diid == 0)
  13749. {
  13750. return Ok(JsonView(false, "请传递团组id"));
  13751. }
  13752. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13753. if (deleInfo.Code != 0)
  13754. {
  13755. return Ok(JsonView(false, "团组信息查询失败!"));
  13756. }
  13757. var di = deleInfo.Data as DelegationInfoWebView;
  13758. if (di != null)
  13759. {
  13760. di.TeamName = di.TeamName.Replace("|", "、");
  13761. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13762. //文件名
  13763. string strFileName = di.TeamName + "-收款账单.doc";
  13764. //获取模板
  13765. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13766. //载入模板
  13767. Document doc = new Document(tmppath);
  13768. decimal TotalPrice = 0.00M;
  13769. string itemStr = string.Empty;
  13770. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13771. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13772. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13773. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13774. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13775. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13776. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13777. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13778. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13779. foreach (var cost in groupCostType)
  13780. {
  13781. var List = cost.ToList();
  13782. if (cost.Key == "A")
  13783. {
  13784. foreach (var ListItem in List)
  13785. {
  13786. if (ListItem.number > 0)
  13787. {
  13788. if (ListItem.code.Contains("TBR"))
  13789. {
  13790. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13791. }
  13792. else
  13793. {
  13794. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13795. }
  13796. TotalPrice += (ListItem.number * ListItem.price);
  13797. }
  13798. }
  13799. }
  13800. else
  13801. {
  13802. itemStr = itemStr.Insert(0, "A段\r\n");
  13803. itemStr += "B段\r\n";
  13804. foreach (var ListItem in List)
  13805. {
  13806. if (ListItem.number > 0)
  13807. {
  13808. if (ListItem.code.Contains("TBR"))
  13809. {
  13810. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13811. }
  13812. else
  13813. {
  13814. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13815. }
  13816. TotalPrice += (ListItem.number * ListItem.price);
  13817. }
  13818. }
  13819. }
  13820. }
  13821. #region 替换Word模板书签内容
  13822. Dictionary<string, string> marks = new Dictionary<string, string>();
  13823. marks.Add("To", di.ClientUnit);//付款方
  13824. marks.Add("ToTel", di.TellPhone);//付款方电话
  13825. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13826. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13827. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13828. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13829. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13830. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13831. marks.Add("PayItemContent", itemStr);//详细信息
  13832. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13833. #endregion
  13834. ////注
  13835. //if (doc.Range.Bookmarks["Attention"] != null)
  13836. //{
  13837. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13838. // mark.Text = frList[0].Attention;
  13839. //}
  13840. foreach (var item in marks.Keys)
  13841. {
  13842. if (doc.Range.Bookmarks[item] != null)
  13843. {
  13844. Bookmark mark = doc.Range.Bookmarks[item];
  13845. mark.Text = marks[item];
  13846. }
  13847. }
  13848. byte[] bytes = null;
  13849. using (MemoryStream stream = new MemoryStream())
  13850. {
  13851. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13852. bytes = stream.ToArray();
  13853. }
  13854. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  13855. return Ok(JsonView(true, "", new
  13856. {
  13857. Data = bytes,
  13858. strFileName,
  13859. }));
  13860. }
  13861. else
  13862. {
  13863. return Ok(JsonView(false, "团组信息不存在!"));
  13864. }
  13865. }
  13866. /// <summary>
  13867. /// 导出团组成本
  13868. /// </summary>
  13869. /// <param name="dto"></param>
  13870. /// <returns></returns>
  13871. [HttpPost]
  13872. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13873. {
  13874. var jw = JsonView(false);
  13875. if (dto.Diid == 0)
  13876. {
  13877. return Ok(JsonView(false, "请传递团组id"));
  13878. }
  13879. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13880. if (deleInfo.Code != 0)
  13881. {
  13882. return Ok(JsonView(false, "团组信息查询失败!"));
  13883. }
  13884. var di = deleInfo.Data as DelegationInfoWebView;
  13885. if (di == null)
  13886. {
  13887. return Ok(JsonView(false, "团组信息查询失败!"));
  13888. }
  13889. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13890. WorkbookDesigner designer = new WorkbookDesigner();
  13891. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13892. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13893. for (int i = 0; i < List_GC.Count; i++)
  13894. {
  13895. GroupCost_Excel gc = new GroupCost_Excel();
  13896. gc.Id = List_GC[i].Id;
  13897. gc.Diid = List_GC[i].Diid.ToString();
  13898. gc.DAY = List_GC[i].DAY;
  13899. string week = "";
  13900. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13901. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13902. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13903. gc.ITIN = List_GC[i].ITIN;
  13904. gc.CarType = List_GC[i].CarType;
  13905. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13906. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13907. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13908. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13909. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13910. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13911. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13912. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13913. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13914. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13915. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13916. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13917. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13918. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13919. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13920. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13921. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13922. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13923. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13924. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13925. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13926. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13927. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13928. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13929. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13930. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13931. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13932. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13933. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13934. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13935. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13936. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13937. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13938. List_GC1.Add(gc);
  13939. }
  13940. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13941. dt.TableName = "TB";
  13942. //报表标题等不用dt的值
  13943. designer.SetDataSource("TeamName", dto.title.TeamName);
  13944. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13945. designer.SetDataSource("Tax", dto.title.Tax);
  13946. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13947. designer.SetDataSource("Currency", dto.title.Currency);
  13948. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13949. designer.SetDataSource("Rate", dto.title.Rate);
  13950. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13951. var Aparams = hotels.Find(x => x.Type == "Default");
  13952. if (Aparams == null)
  13953. {
  13954. return Ok(jw);
  13955. }
  13956. //酒店数量
  13957. var txtSGRNumber = Aparams.SGR.ToString();
  13958. var txtTBRNumber = Aparams.TBR.ToString();
  13959. var txtJSESNumber = Aparams.JSES.ToString();
  13960. var txtSUITENumbe = Aparams.SUITE.ToString();
  13961. if (dto.costType == "B")
  13962. {
  13963. Aparams = hotels.Find(x => x.Type == "A");
  13964. var Bparams = hotels.Find(x => x.Type == "B");
  13965. if (Aparams == null || Bparams == null)
  13966. {
  13967. return Ok(jw);
  13968. }
  13969. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13970. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13971. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13972. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13973. }
  13974. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13975. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13976. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13977. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13978. var ws = designer.Workbook.Worksheets[0];
  13979. int Row = List_GC.Count;
  13980. int startIndex = 11;
  13981. int HideRows = 0;
  13982. List<int> hideRowsList = new List<int>();
  13983. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13984. #region A段left数据
  13985. var left = dto.leftInfo.Find(x => x.Type == "A");
  13986. if (left == null)
  13987. {
  13988. return Ok(jw);
  13989. }
  13990. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  13991. if (leftBindData != null)
  13992. {
  13993. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  13994. designer.SetDataSource("VisaRS", leftBindData.rs);
  13995. designer.SetDataSource("VisaXS", leftBindData.xs);
  13996. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13997. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13998. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13999. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14000. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14001. }
  14002. else
  14003. {
  14004. hideRowsList.Add(Row + startIndex + HideRows);
  14005. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14006. }
  14007. HideRows += 2;
  14008. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14009. if (leftBindData != null)
  14010. {
  14011. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14012. designer.SetDataSource("BXRS", leftBindData.rs);
  14013. designer.SetDataSource("BXXS", leftBindData.xs);
  14014. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14015. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14016. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14017. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14018. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14019. }
  14020. else
  14021. {
  14022. hideRowsList.Add(Row + startIndex + HideRows);
  14023. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14024. }
  14025. HideRows += 2;
  14026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14027. if (leftBindData != null)
  14028. {
  14029. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14030. designer.SetDataSource("HSRS", leftBindData.rs);
  14031. designer.SetDataSource("HSXS", leftBindData.xs);
  14032. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14033. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14034. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14035. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14036. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14037. }
  14038. else
  14039. {
  14040. hideRowsList.Add(Row + startIndex + HideRows);
  14041. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14042. }
  14043. HideRows += 2;
  14044. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14045. if (leftBindData != null)
  14046. {
  14047. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14048. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14049. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14050. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14051. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14052. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14053. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14054. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14055. }
  14056. else
  14057. {
  14058. hideRowsList.Add(Row + startIndex + HideRows);
  14059. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14060. }
  14061. HideRows += 2;
  14062. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14063. if (leftBindData != null)
  14064. {
  14065. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14066. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14067. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14068. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14069. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14070. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14071. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14072. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14073. }
  14074. else
  14075. {
  14076. hideRowsList.Add(Row + startIndex + HideRows);
  14077. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14078. }
  14079. HideRows += 2;
  14080. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14081. if (leftBindData != null)
  14082. {
  14083. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14084. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14085. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14086. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14087. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14088. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14089. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14090. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14091. }
  14092. else
  14093. {
  14094. hideRowsList.Add(Row + startIndex + HideRows);
  14095. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14096. }
  14097. HideRows += 2;
  14098. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14099. if (leftBindData != null)
  14100. {
  14101. ////TBR
  14102. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14103. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14104. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14105. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14106. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14107. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14108. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14109. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14110. }
  14111. else
  14112. {
  14113. hideRowsList.Add(Row + startIndex + HideRows);
  14114. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14115. }
  14116. HideRows += 2;
  14117. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14118. if (leftBindData != null)
  14119. {
  14120. ////SGR
  14121. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14122. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14123. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14124. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14125. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14126. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14127. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14128. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14129. }
  14130. else
  14131. {
  14132. hideRowsList.Add(Row + startIndex + HideRows);
  14133. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14134. }
  14135. HideRows += 2;
  14136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14137. if (leftBindData != null)
  14138. {
  14139. ////JS/ES
  14140. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14141. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14142. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14143. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14144. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14145. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14146. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14147. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14148. }
  14149. else
  14150. {
  14151. hideRowsList.Add(Row + startIndex + HideRows);
  14152. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14153. }
  14154. HideRows += 2;
  14155. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14156. if (leftBindData != null)
  14157. {
  14158. ////SUITE
  14159. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14160. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14161. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14162. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14163. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14164. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14165. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14166. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14167. }
  14168. else
  14169. {
  14170. hideRowsList.Add(Row + startIndex + HideRows);
  14171. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14172. }
  14173. HideRows += 2;
  14174. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14175. if (leftBindData != null)
  14176. {
  14177. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14178. designer.SetDataSource("DJRS", leftBindData.rs);
  14179. designer.SetDataSource("DJXS", leftBindData.xs);
  14180. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14181. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14182. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14183. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14184. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14185. }
  14186. else
  14187. {
  14188. hideRowsList.Add(Row + startIndex + HideRows);
  14189. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14190. }
  14191. HideRows += 2;
  14192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14193. if (leftBindData != null)
  14194. {
  14195. designer.SetDataSource("HCPCB", leftBindData.cb);
  14196. designer.SetDataSource("HCPRS", leftBindData.rs);
  14197. designer.SetDataSource("HCPXS", leftBindData.xs);
  14198. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14199. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14200. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14201. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14202. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14203. }
  14204. else
  14205. {
  14206. hideRowsList.Add(Row + startIndex + HideRows);
  14207. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14208. }
  14209. HideRows += 2;
  14210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14211. if (leftBindData != null)
  14212. {
  14213. designer.SetDataSource("CPCB", leftBindData.cb);
  14214. designer.SetDataSource("CPRS", leftBindData.rs);
  14215. designer.SetDataSource("CPXS", leftBindData.xs);
  14216. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14217. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14218. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14219. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14220. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14221. }
  14222. else
  14223. {
  14224. hideRowsList.Add(Row + startIndex + HideRows);
  14225. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14226. }
  14227. HideRows += 2;
  14228. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14229. if (leftBindData != null)
  14230. {
  14231. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14232. designer.SetDataSource("GWRS", leftBindData.rs);
  14233. designer.SetDataSource("GWXS", leftBindData.xs);
  14234. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14235. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14236. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14237. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14238. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14239. }
  14240. else
  14241. {
  14242. hideRowsList.Add(Row + startIndex + HideRows);
  14243. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14244. }
  14245. HideRows += 2;
  14246. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14247. if (leftBindData != null)
  14248. {
  14249. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14250. designer.SetDataSource("LYJRS", leftBindData.rs);
  14251. designer.SetDataSource("LYJXS", leftBindData.xs);
  14252. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14253. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14254. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14255. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14256. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14257. }
  14258. else
  14259. {
  14260. hideRowsList.Add(Row + startIndex + HideRows);
  14261. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14262. }
  14263. #endregion
  14264. #region A段Right信息
  14265. var right = dto.rightInfo.Find(x => x.Type == "A");
  14266. if (right == null)
  14267. {
  14268. return Ok(jw);
  14269. }
  14270. HideRows += 4;
  14271. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14272. if (rightBindData != null)
  14273. {
  14274. //经济舱 + 双人间 TBR
  14275. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14276. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14277. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14278. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14279. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14280. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14281. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14282. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14283. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14284. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14285. }
  14286. else
  14287. {
  14288. hideRowsList.Add(Row + startIndex + HideRows);
  14289. }
  14290. HideRows += 2;
  14291. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14292. if (rightBindData != null)
  14293. {
  14294. //经济舱 + 单人间 SGR
  14295. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14296. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14297. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14298. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14299. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14300. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14301. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14302. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14303. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14304. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14305. }
  14306. else
  14307. {
  14308. hideRowsList.Add(Row + startIndex + HideRows);
  14309. }
  14310. HideRows += 2;
  14311. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14312. if (rightBindData != null)
  14313. {
  14314. //公务舱 + 单人间 SGR
  14315. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14316. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14317. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14318. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14319. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14320. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14321. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14322. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14323. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14324. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14325. }
  14326. else
  14327. {
  14328. hideRowsList.Add(Row + startIndex + HideRows);
  14329. }
  14330. HideRows += 2;
  14331. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14332. if (rightBindData != null)
  14333. {
  14334. //公务舱 + 小套房 JSES
  14335. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14336. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14337. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14338. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14339. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14340. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14341. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14342. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14343. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14344. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14345. }
  14346. else
  14347. {
  14348. hideRowsList.Add(Row + startIndex + HideRows);
  14349. }
  14350. HideRows += 2;
  14351. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14352. if (rightBindData != null)
  14353. {
  14354. //公务舱 + 小套房 JSES
  14355. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14356. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14357. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14358. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14359. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14360. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14361. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14362. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14363. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14364. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14365. }
  14366. else
  14367. {
  14368. hideRowsList.Add(Row + startIndex + HideRows);
  14369. }
  14370. HideRows += 2;
  14371. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14372. if (rightBindData != null)
  14373. {
  14374. //经济舱 + 大套房
  14375. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14376. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14377. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14378. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14379. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14380. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14381. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14382. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14383. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14384. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14385. }
  14386. else
  14387. {
  14388. hideRowsList.Add(Row + startIndex + HideRows);
  14389. }
  14390. HideRows += 2;
  14391. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14392. if (rightBindData != null)
  14393. {
  14394. //头等舱 + 小套房 JSES
  14395. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14396. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14397. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14398. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14399. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14400. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14401. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14402. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14403. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14404. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14405. }
  14406. else
  14407. {
  14408. hideRowsList.Add(Row + startIndex + HideRows);
  14409. }
  14410. HideRows += 2;
  14411. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14412. if (rightBindData != null)
  14413. {
  14414. //头等舱 + 大套房
  14415. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14416. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14417. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14418. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14419. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14420. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14421. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14422. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14423. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14424. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14425. }
  14426. else
  14427. {
  14428. hideRowsList.Add(Row + startIndex + HideRows);
  14429. }
  14430. #endregion
  14431. #region B段标题清空
  14432. designer.SetDataSource("CostBDRCB", "");
  14433. designer.SetDataSource("CostBRS", "");
  14434. designer.SetDataSource("CostBXS", "");
  14435. designer.SetDataSource("CostBZCB", "");
  14436. designer.SetDataSource("CostBDRBJ", "");
  14437. designer.SetDataSource("CostBZBJ", "");
  14438. designer.SetDataSource("CostBDRLR", "");
  14439. designer.SetDataSource("CostBZLR", "");
  14440. designer.SetDataSource("CostBDRCBOM", "");
  14441. designer.SetDataSource("CostBRSOM", "");
  14442. designer.SetDataSource("CostBZCBOM", "");
  14443. designer.SetDataSource("CostBDRBJOM", "");
  14444. designer.SetDataSource("CostBZBJOM", "");
  14445. designer.SetDataSource("CostBDRLROM", "");
  14446. designer.SetDataSource("CostBZLROM", "");
  14447. #endregion
  14448. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14449. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14450. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14451. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14452. designer.SetDataSource("DJName", "地接(CNY)");
  14453. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14454. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14455. designer.SetDataSource("GWName", "公务(CNY)");
  14456. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14457. designer.SetDataSource("LYJName", "零用金(CNY)");
  14458. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14459. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14460. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14461. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14462. designer.SetDataSource("BXName", "保险(CNY)");
  14463. designer.SetDataSource("VisaName", "签证(CNY)");
  14464. #region B段基本数据
  14465. if (dto.costType == "B")
  14466. {
  14467. left = dto.leftInfo.Find(x => x.Type == "B");
  14468. if (left == null)
  14469. {
  14470. return Ok(jw);
  14471. }
  14472. #region B段left数据
  14473. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14474. if (leftBindData != null)
  14475. {
  14476. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14477. designer.SetDataSource("BHSRS", leftBindData.rs);
  14478. designer.SetDataSource("BHSXS", leftBindData.xs);
  14479. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14480. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14481. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14482. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14483. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14484. }
  14485. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14486. if (leftBindData != null)
  14487. {
  14488. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14489. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14490. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14491. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14492. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14493. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14494. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14495. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14496. }
  14497. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14498. if (leftBindData != null)
  14499. {
  14500. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14501. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14502. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14503. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14504. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14505. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14506. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14507. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14508. }
  14509. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14510. if (leftBindData != null)
  14511. {
  14512. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14513. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14514. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14515. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14516. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14517. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14518. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14519. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14520. }
  14521. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14522. if (leftBindData != null)
  14523. {
  14524. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14525. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14526. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14527. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14528. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14529. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14530. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14531. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14532. }
  14533. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14534. if (leftBindData != null)
  14535. {
  14536. designer.SetDataSource("BCPCB", leftBindData.cb);
  14537. designer.SetDataSource("BCPRS", leftBindData.rs);
  14538. designer.SetDataSource("BCPXS", leftBindData.xs);
  14539. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14540. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14541. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14542. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14543. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14544. }
  14545. //TBR
  14546. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14547. if (leftBindData != null)
  14548. {
  14549. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14550. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14551. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14552. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14553. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14554. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14555. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14556. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14557. }
  14558. //SGR
  14559. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14560. if (leftBindData != null)
  14561. {
  14562. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14563. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14564. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14565. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14566. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14567. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14568. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14569. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14570. }
  14571. //JS/ES
  14572. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14573. if (leftBindData != null)
  14574. {
  14575. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14576. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14577. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14578. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14579. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14580. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14581. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14582. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14583. }
  14584. //SUITE
  14585. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14586. if (leftBindData != null)
  14587. {
  14588. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14589. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14590. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14591. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14592. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14593. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14594. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14595. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14596. }
  14597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14598. if (leftBindData != null)
  14599. {
  14600. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14601. designer.SetDataSource("BDJRS", leftBindData.rs);
  14602. designer.SetDataSource("BDJXS", leftBindData.xs);
  14603. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14604. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14605. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14606. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14607. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14608. }
  14609. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14610. if (leftBindData != null)
  14611. {
  14612. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14613. designer.SetDataSource("BGWRS", leftBindData.rs);
  14614. designer.SetDataSource("BGWXS", leftBindData.xs);
  14615. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14616. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14617. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14618. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14619. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14620. }
  14621. #region 优化方案
  14622. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14623. //excelBind.Add("零用金", new {
  14624. //cb="",
  14625. //rs="",
  14626. //xs ="",
  14627. //zcb = "",
  14628. //});
  14629. #endregion
  14630. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14631. if (leftBindData != null)
  14632. {
  14633. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14634. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14635. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14636. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14637. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14638. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14639. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14640. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14641. }
  14642. #endregion
  14643. #region B段Right信息
  14644. right = dto.rightInfo.Find(x => x.Type == "B");
  14645. if (right == null)
  14646. {
  14647. return Ok(jw);
  14648. }
  14649. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14650. if (rightBindData != null)
  14651. {
  14652. //经济舱 + 双人间 TBR
  14653. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14654. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14655. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14656. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14657. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14658. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14659. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14660. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14661. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14662. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14663. }
  14664. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14665. if (rightBindData != null)
  14666. {
  14667. //经济舱 + 单人间 SGR
  14668. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14669. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14670. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14671. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14672. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14673. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14674. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14675. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14676. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14677. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14678. }
  14679. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14680. if (rightBindData != null)
  14681. {
  14682. //公务舱 + 单人间 SGR
  14683. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14684. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14685. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14686. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14687. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14688. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14689. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14690. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14691. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14692. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14693. }
  14694. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14695. if (rightBindData != null)
  14696. {
  14697. //公务舱 + 小套房 JSES
  14698. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14699. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14700. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14701. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14702. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14703. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14704. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14705. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14706. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14707. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14708. }
  14709. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14710. if (rightBindData != null)
  14711. {
  14712. //公务舱 + 小套房 JSES
  14713. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14714. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14715. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14716. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14717. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14718. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14719. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14720. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14721. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14722. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14723. }
  14724. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14725. if (rightBindData != null)
  14726. {
  14727. //经济舱 + 大套房
  14728. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14729. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14730. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14731. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14732. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14733. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14734. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14735. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14736. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14737. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14738. }
  14739. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14740. if (rightBindData != null)
  14741. {
  14742. //头等舱 + 小套房 JSES
  14743. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14744. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14745. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14746. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14747. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14748. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14749. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14750. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14751. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14752. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14753. }
  14754. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14755. if (rightBindData != null)
  14756. {
  14757. //头等舱 + 大套房
  14758. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  14759. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14760. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14761. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14762. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14763. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14764. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14765. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14766. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14767. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14768. }
  14769. #endregion
  14770. #region 标题
  14771. designer.SetDataSource("CostBDRCB", "单人成本");
  14772. designer.SetDataSource("CostBRS", "人数");
  14773. designer.SetDataSource("CostBXS", "系数");
  14774. designer.SetDataSource("CostBZCB", "总成本");
  14775. designer.SetDataSource("CostBDRBJ", "单人报价");
  14776. designer.SetDataSource("CostBZBJ", "总报价");
  14777. designer.SetDataSource("CostBDRLR", "单人利润");
  14778. designer.SetDataSource("CostBZLR", "总利润");
  14779. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14780. designer.SetDataSource("CostBRSOM", "人数");
  14781. designer.SetDataSource("CostBZCBOM", "总成本");
  14782. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14783. designer.SetDataSource("CostBZBJOM", "总报价");
  14784. designer.SetDataSource("CostBDRLROM", "单人利润");
  14785. designer.SetDataSource("CostBZLROM", "总利润");
  14786. #endregion
  14787. }
  14788. #endregion
  14789. designer.SetDataSource("TzZCB2", TzZCB2);
  14790. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14791. designer.SetDataSource("TzZLR2", TzZLR2);
  14792. string[] dataSourceKeys = new string[]
  14793. {
  14794. "VF",
  14795. "TGS",
  14796. "TGOF",
  14797. "TGM",
  14798. "TGA",
  14799. "TGTF",
  14800. "TGEF",
  14801. "CFM",
  14802. "CFOF",
  14803. "B",
  14804. "L",
  14805. "D",
  14806. "TBR",
  14807. "SGR",
  14808. "JSES",
  14809. "Suite",
  14810. "TV",
  14811. "1L",
  14812. "IF",
  14813. "EF",
  14814. "BRF",
  14815. "TE",
  14816. "TGT",
  14817. "DRVT",
  14818. "PC",
  14819. "TLF",
  14820. "ECT"
  14821. };
  14822. foreach (var item in dataSourceKeys)
  14823. {
  14824. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14825. if (find != null)
  14826. {
  14827. designer.SetDataSource(item, find.text);
  14828. }
  14829. else
  14830. {
  14831. designer.SetDataSource(item, 0);
  14832. }
  14833. }
  14834. designer.SetDataSource(dt);
  14835. //根据数据源处理生成报表内容
  14836. designer.Process();
  14837. designer.Workbook.Worksheets[0].Name = "清单";
  14838. Worksheet sheet = designer.Workbook.Worksheets[0];
  14839. foreach (var Rowindex in hideRowsList)
  14840. {
  14841. ws.Cells.HideRows(Rowindex, 2);
  14842. }
  14843. byte[] bytes = null;
  14844. string strFileName = di.TeamName + "-团组-成本.xls";
  14845. using (MemoryStream stream = new MemoryStream())
  14846. {
  14847. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  14848. bytes = stream.ToArray();
  14849. }
  14850. return Ok(JsonView(true, "", new
  14851. {
  14852. Data = bytes,
  14853. strFileName,
  14854. }));
  14855. }
  14856. /// <summary>
  14857. /// 导出客户报表
  14858. /// </summary>
  14859. /// <returns></returns>
  14860. [HttpPost]
  14861. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14862. {
  14863. var jw = JsonView(false);
  14864. if (dto.Diid == 0)
  14865. {
  14866. return Ok(JsonView(false, "请传递团组id"));
  14867. }
  14868. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14869. if (deleInfo.Code != 0)
  14870. {
  14871. return Ok(JsonView(false, "团组信息查询失败!"));
  14872. }
  14873. var di = deleInfo.Data as DelegationInfoWebView;
  14874. if (di == null)
  14875. {
  14876. return Ok(JsonView(false, "团组信息查询失败!"));
  14877. }
  14878. //文件名
  14879. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14880. //获取模板
  14881. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14882. //载入模板
  14883. Document doc = new Document(tmppath);
  14884. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14885. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14886. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14887. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14888. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14889. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14890. if (AParameter == null)
  14891. {
  14892. return Ok(JsonView(false, "系数不存在!"));
  14893. }
  14894. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14895. , TzAirDesc, TzZCost;
  14896. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14897. = TzAirDesc = TzZCost = string.Empty;
  14898. TzNumber = AParameter.CostTypenumber.ToString();
  14899. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14900. CarGuides1 = dto.CarGuides1;
  14901. Meal = dto.Meal;
  14902. SubsidizedMeals = dto.SubsidizedMeals;
  14903. NightRepair = dto.NightRepair;
  14904. AttractionsTickets = dto.AttractionsTickets;
  14905. MiscellaneousFees = dto.MiscellaneousFees;
  14906. ATip = dto.ATip;
  14907. TzHotelDesc = "";
  14908. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14909. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14910. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14911. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14912. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14913. TzAirDesc = "";
  14914. TzZCost = dto.TzZCost;
  14915. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14916. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14917. var index = 1;
  14918. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14919. foreach (var item in TzHotelDescArr)
  14920. {
  14921. if (AinfoArr != null)
  14922. {
  14923. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14924. if (Ainfo != null)
  14925. {
  14926. if (int.Parse(Ainfo.rs) <= 0)
  14927. {
  14928. continue;
  14929. }
  14930. var hotelText = string.Empty;
  14931. switch (item)
  14932. {
  14933. case "SGR":
  14934. hotelText = "单人间";
  14935. break;
  14936. case "JSES":
  14937. hotelText = "小套房";
  14938. break;
  14939. case "SUITE":
  14940. hotelText = "套房";
  14941. break;
  14942. case "TBR":
  14943. hotelText = "双人间";
  14944. break;
  14945. }
  14946. if (item != "TBR")
  14947. {
  14948. 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";
  14949. }
  14950. else
  14951. {
  14952. 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";
  14953. }
  14954. index++;
  14955. }
  14956. }
  14957. }
  14958. index = 1;
  14959. foreach (var item in TzAirDescArr)
  14960. {
  14961. if (AinfoArr != null)
  14962. {
  14963. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14964. if (Ainfo != null)
  14965. {
  14966. if (int.Parse(Ainfo.rs) <= 0)
  14967. {
  14968. continue;
  14969. }
  14970. 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";
  14971. index++;
  14972. }
  14973. }
  14974. }
  14975. if (dto.costType == "B")
  14976. {
  14977. if (BParameter == null)
  14978. {
  14979. return Ok(JsonView(false, "B段系数不存在!"));
  14980. }
  14981. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14982. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14983. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14984. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14985. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  14986. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  14987. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  14988. foreach (var item in TzHotelDescArr)
  14989. {
  14990. if (AinfoArr != null)
  14991. {
  14992. TzHotelDesc += "B段信息 \r\n";
  14993. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14994. if (Ainfo != null)
  14995. {
  14996. if (int.Parse(Ainfo.rs) <= 0)
  14997. {
  14998. continue;
  14999. }
  15000. var hotelText = string.Empty;
  15001. switch (item)
  15002. {
  15003. case "SGR":
  15004. hotelText = "单人间";
  15005. break;
  15006. case "JSES":
  15007. hotelText = "小套房";
  15008. break;
  15009. case "SUITE":
  15010. hotelText = "套房";
  15011. break;
  15012. case "TBR":
  15013. hotelText = "双人间";
  15014. break;
  15015. }
  15016. if (item != "TBR")
  15017. {
  15018. 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";
  15019. }
  15020. else
  15021. {
  15022. 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";
  15023. }
  15024. index++;
  15025. }
  15026. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15027. }
  15028. }
  15029. index = 1;
  15030. foreach (var item in TzAirDescArr)
  15031. {
  15032. if (AinfoArr != null)
  15033. {
  15034. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15035. if (Ainfo != null)
  15036. {
  15037. if (int.Parse(Ainfo.rs) <= 0)
  15038. {
  15039. continue;
  15040. }
  15041. 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";
  15042. index++;
  15043. }
  15044. }
  15045. }
  15046. }
  15047. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15048. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15049. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15050. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15051. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15052. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15053. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15054. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15055. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15056. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15057. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15058. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15059. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15060. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15061. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15062. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15063. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15064. DickeyValue.Add("TzZCost", TzZCost);
  15065. foreach (var key in DickeyValue.Keys)
  15066. {
  15067. if (doc.Range.Bookmarks[key] != null)
  15068. {
  15069. Bookmark mark = doc.Range.Bookmarks[key];
  15070. mark.Text = DickeyValue[key];
  15071. }
  15072. }
  15073. byte[] bytes = null;
  15074. string strFileName = di.TeamName + "-客户报价.doc";
  15075. using (MemoryStream stream = new MemoryStream())
  15076. {
  15077. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15078. bytes = stream.ToArray();
  15079. }
  15080. return Ok(JsonView(true, "", new
  15081. {
  15082. Data = bytes,
  15083. strFileName,
  15084. }));
  15085. }
  15086. /// <summary>
  15087. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15088. /// </summary>
  15089. /// <param name="dto"></param>
  15090. /// <returns></returns>
  15091. [HttpPost]
  15092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15093. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15094. {
  15095. try
  15096. {
  15097. #region 参数验证
  15098. if (dto.DiId < 0)
  15099. {
  15100. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15101. }
  15102. List<int> cTableIds = new List<int>() {
  15103. 76 ,//酒店预订
  15104. 77 ,//行程
  15105. 79 ,//车/导游地接
  15106. 80 ,//签证
  15107. 81 ,//邀请/公务活
  15108. 82 ,//团组客户保险
  15109. 85 ,//机票预订
  15110. 98 ,//其他款项
  15111. 285 ,//收款退还
  15112. 751 ,//酒店早餐
  15113. 1015 // 超支费用
  15114. };
  15115. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15116. {
  15117. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15118. }
  15119. #endregion
  15120. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15121. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15122. if (_GroupCostParameters.Count <= 0)
  15123. {
  15124. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15125. }
  15126. if (_GroupCostParameters[0].IsShare == 0)
  15127. {
  15128. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15129. }
  15130. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15131. //处理date为空问题
  15132. if (_GroupCosts.Count > 0)
  15133. {
  15134. for (int i = 0; i < _GroupCosts.Count; i++)
  15135. {
  15136. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15137. {
  15138. if (i > 0)
  15139. {
  15140. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15141. }
  15142. }
  15143. }
  15144. }
  15145. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15146. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15147. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15148. string currCode = "";
  15149. #region currCode 验证
  15150. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15151. if (isInt)
  15152. {
  15153. var currData = currDatas.Find(it => it.Id == intCurrency);
  15154. if (currData != null)
  15155. {
  15156. currCode = currData.Name;
  15157. }
  15158. }
  15159. else
  15160. {
  15161. currCode = _GroupCostParameters[0].Currency.Trim();
  15162. }
  15163. #endregion
  15164. //op,酒店单段模式存储
  15165. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15166. {
  15167. CurrencyCode = currCode,
  15168. Rate = _GroupCostParameters[0].Rate,
  15169. CostType = _GroupCostParameters[0].CostType,
  15170. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15171. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15172. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15173. };
  15174. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15175. if (_GroupCostParameters.Count == 2)
  15176. {
  15177. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15178. }
  15179. foreach (var item in _GroupCostParameters)
  15180. {
  15181. decimal _rate = 1;
  15182. decimal _rate1 = item.Rate;
  15183. decimal _scale = 1;
  15184. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15185. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15186. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15187. //if (userInfo != null)
  15188. //{
  15189. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15190. // {
  15191. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15192. // {
  15193. // _scale = 1.00M;
  15194. // }
  15195. // }
  15196. //}
  15197. #endregion
  15198. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15199. {
  15200. CurrencyCode = currCode,
  15201. Rate = _rate1,
  15202. CostType = item.CostType,
  15203. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15204. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15205. CostTypeNumber = item.CostTypenumber
  15206. };
  15207. if (_GroupCostParameters.Count > 1)
  15208. {
  15209. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15210. }
  15211. else
  15212. {
  15213. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15214. }
  15215. if (dto.CTable == 79)//
  15216. {
  15217. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15218. modulePromptInfo.TotalCost = item.DJCB;
  15219. }
  15220. List<string> costTypes = new List<string>() { "A", "B" };
  15221. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15222. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15223. if (_GroupCostsDuplicates.Count() == 1)
  15224. {
  15225. _GroupCostsTypeData = _GroupCosts;
  15226. }
  15227. else
  15228. {
  15229. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15230. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15231. }
  15232. /*
  15233. * 76 酒店预订
  15234. * 77 行程
  15235. * 79 车/导游地接
  15236. * 80 签证
  15237. * 81 邀请/公务活动
  15238. * 82 团组客户保险
  15239. * 85 机票预订
  15240. * 98 其他款项
  15241. * 285 收款退还
  15242. * 751 酒店早餐
  15243. * 1015 超支费用
  15244. */
  15245. switch (dto.CTable)
  15246. {
  15247. case 76: // 酒店预订
  15248. _ModuleSubPromptInfo.AddRange(
  15249. _GroupCostsTypeData.Select(it => new
  15250. {
  15251. it.DAY,
  15252. it.Date,
  15253. it.ACCON,
  15254. it.ITIN,
  15255. it.SGR,
  15256. it.TBR,
  15257. it.JS_ES,
  15258. it.Suite
  15259. })
  15260. );
  15261. break;
  15262. case 79: // 车/导游地接
  15263. _ModuleSubPromptInfo.AddRange(
  15264. _GroupCostsTypeData.Select(it => new
  15265. {
  15266. Date = it.Date, //日期
  15267. CarFee = it.CarCost * _rate * _scale, //车费用
  15268. CarType = it.CarType, //车型
  15269. DriverFee = it.CFS * _rate * _scale, //司机工资
  15270. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15271. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15272. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15273. GuideFee = it.TGS * _rate * _scale, //导游费用
  15274. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15275. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15276. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15277. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15278. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15279. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15280. Breakfast = it.B * _rate * _scale, //早餐费
  15281. Lunch = it.L * _rate * _scale, //午餐费
  15282. Dinner = it.D * _rate * _scale, //晚餐费
  15283. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15284. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15285. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15286. TicketFee = it.EF * _rate * _scale, //门票费
  15287. TicketRemark = it.EFR, //门票费描述
  15288. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15289. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15290. SpentCash = it.PC * _rate * _scale, //零用金
  15291. LeadersFee = it.TLF * _rate * _scale, //领队费
  15292. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15293. })
  15294. );
  15295. break;
  15296. case 85: // 机票
  15297. List<dynamic> datas = new List<dynamic>();
  15298. datas.Add(
  15299. new
  15300. {
  15301. AirType = "经济舱",
  15302. AirNum = item.JJCRS,
  15303. AirDRCB = item.JJCCB,
  15304. AirZCB = (item.JJCRS * item.JJCCB)
  15305. }
  15306. );
  15307. datas.Add(
  15308. new
  15309. {
  15310. AirType = "公务舱",
  15311. AirNum = item.GWCRS,
  15312. AirDRCB = item.GWCCB,
  15313. AirZCB = (item.GWCRS * item.GWCCB)
  15314. }
  15315. );
  15316. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15317. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15318. modulePromptInfo.Data = new
  15319. {
  15320. airFeeData = datas,
  15321. airInitData = initDatas
  15322. };
  15323. _ModulePromptInfos.Add(modulePromptInfo);
  15324. break;
  15325. default:
  15326. break;
  15327. }
  15328. }
  15329. if (dto.CTable != 85)
  15330. {
  15331. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15332. _ModulePromptInfos.Add(_ModulePromptInfo);
  15333. }
  15334. _view.ModulePromptInfos = _ModulePromptInfos;
  15335. return Ok(JsonView(true, "操作成功!", _view));
  15336. }
  15337. catch (Exception ex)
  15338. {
  15339. return Ok(JsonView(false, ex.Message));
  15340. }
  15341. }
  15342. /// <summary>
  15343. /// 根据黑屏代码重新生成行程
  15344. /// </summary>
  15345. /// <param name="dto"></param>
  15346. /// <returns></returns>
  15347. [HttpPost]
  15348. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15349. {
  15350. var jw = JsonView(false,"Error");
  15351. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15352. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15353. .Select(x=> new
  15354. {
  15355. x.Id,
  15356. x.Title
  15357. })
  15358. .ToList();
  15359. if (Create.Any())
  15360. {
  15361. jw.Msg = "获取成功!";
  15362. jw.Code = 200;
  15363. jw.Data = new
  15364. {
  15365. BlackCodeListSelect = Create,
  15366. blackCodeIsTrue = true
  15367. };
  15368. }
  15369. else
  15370. {
  15371. jw.Code = 400;
  15372. jw.Data = new
  15373. {
  15374. BlackCodeListSelect = Create,
  15375. blackCodeIsTrue = false,
  15376. };
  15377. }
  15378. return Ok(jw);
  15379. }
  15380. /// <summary>
  15381. /// 根据黑屏代码Id重新生成行程
  15382. /// </summary>
  15383. /// <param name="dto"></param>
  15384. /// <returns></returns>
  15385. [HttpPost]
  15386. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15387. {
  15388. var jw = JsonView(false, "Error");
  15389. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15390. if (result.Code == 0)
  15391. {
  15392. jw.Msg = "获取成功!";
  15393. jw.Code = 200;
  15394. jw.Data = new
  15395. {
  15396. groupCost = result.Data,
  15397. blackCodeIsTrue = true
  15398. };
  15399. }
  15400. else
  15401. {
  15402. jw.Code = 400;
  15403. jw.Data = new
  15404. {
  15405. groupCost = result.Data,
  15406. blackCodeIsTrue = false,
  15407. };
  15408. }
  15409. return Ok(jw);
  15410. }
  15411. /// <summary>
  15412. /// 成本获取OP历史车费用
  15413. /// </summary>
  15414. /// <param name="dto"></param>
  15415. /// <returns></returns>
  15416. [HttpPost]
  15417. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15418. {
  15419. var jw = JsonView(false);
  15420. try
  15421. {
  15422. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15423. //获取现有所有车的数据
  15424. if (!dto.Param.IsNullOrWhiteSpace())
  15425. {
  15426. string sql = $@"
  15427. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15428. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15429. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15430. 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
  15431. AND gctggr.ServiceEndTime is not NULL
  15432. ORDER by gctggrc.id DESC
  15433. ";
  15434. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15435. var numeberResult = await Task.Run(() =>
  15436. {
  15437. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15438. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15439. return numberArr;
  15440. });
  15441. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15442. foreach (var item in numeberResult)
  15443. {
  15444. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15445. {
  15446. Country = "数据异常!",
  15447. City = string.Empty,
  15448. };
  15449. item.Area = find.Country + " " + find.City;
  15450. }
  15451. dbResult.AddRange(numeberResult);
  15452. if (dto.Param.Contains("、"))
  15453. {
  15454. var sp = dto.Param.Split("、");
  15455. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15456. .Where(x =>
  15457. {
  15458. return System.Array.Exists(sp, e =>
  15459. {
  15460. bool where = false;
  15461. if (x.Area != null)
  15462. {
  15463. where = x.Area.Contains(e);
  15464. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15465. {
  15466. return false;
  15467. }
  15468. }
  15469. if (x.PriceName != null && !where)
  15470. {
  15471. where = x.PriceName.Contains(e);
  15472. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15473. {
  15474. return false;
  15475. }
  15476. }
  15477. return where;
  15478. });
  15479. }).ToList();
  15480. }
  15481. else
  15482. {
  15483. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15484. .Where(x =>
  15485. {
  15486. bool where = false;
  15487. if (x.Area != null)
  15488. {
  15489. where = x.Area.Contains(dto.Param);
  15490. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15491. {
  15492. return false;
  15493. }
  15494. }
  15495. if (x.PriceName != null && !where)
  15496. {
  15497. where = x.PriceName.Contains(dto.Param);
  15498. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15499. {
  15500. return false;
  15501. }
  15502. }
  15503. return where;
  15504. }
  15505. )
  15506. .ToList();
  15507. }
  15508. }
  15509. var view = dbResult.Select(x =>
  15510. {
  15511. decimal dp = 0.00M;
  15512. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15513. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15514. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15515. {
  15516. if (startB && endB)
  15517. {
  15518. var timesp = endD.Subtract(startD);
  15519. if ((timesp.Days + 1) != 0)
  15520. {
  15521. dp = x.Price / (timesp.Days + 1);
  15522. }
  15523. }
  15524. }
  15525. else
  15526. {
  15527. dp = x.Price;
  15528. }
  15529. return new
  15530. {
  15531. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15532. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15533. x.Area,
  15534. x.id,
  15535. price = x.Price.ToString("F2"),
  15536. x.PriceName,
  15537. x.PriceContent,
  15538. x.TeamName,
  15539. x.DatePrice,
  15540. dayPrice = dp.ToString("F2"),
  15541. };
  15542. }).OrderByDescending(x => x.id).ToList();
  15543. jw = JsonView(true, "获取成功!", view);
  15544. }
  15545. catch (Exception e)
  15546. {
  15547. jw = JsonView(false, e.Message);
  15548. }
  15549. return Ok(jw);
  15550. }
  15551. [HttpPost]
  15552. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15553. {
  15554. var jw = JsonView(true);
  15555. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15556. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15557. {
  15558. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15559. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15560. WHEN COUNT(*) >= 0 THEN 'True'
  15561. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15562. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15563. ")
  15564. .ToList();
  15565. }
  15566. else
  15567. {
  15568. string likeKey = string.Empty;
  15569. foreach (var item in dto.Keyword)
  15570. {
  15571. likeKey += "%" + item;
  15572. }
  15573. likeKey += "%";
  15574. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15575. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15576. WHEN COUNT(*) >= 0 THEN 'True'
  15577. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15578. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15579. ")
  15580. .ToList();
  15581. }
  15582. if (matches.Any())
  15583. {
  15584. jw.Data = matches;
  15585. }
  15586. else
  15587. {
  15588. jw.Code = 201;
  15589. jw.Msg = "empty list";
  15590. jw.Data = new List<string>(1);
  15591. }
  15592. return Ok(jw);
  15593. }
  15594. #endregion
  15595. #region 酒店预订 新 雷怡 2023-12-28 17:45
  15596. /// <summary>
  15597. /// 酒店预订
  15598. /// 酒店费用列表 根据团组Id查询
  15599. /// </summary>
  15600. /// <param name="_dto"></param>
  15601. /// <returns></returns>
  15602. [HttpPost]
  15603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15604. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  15605. {
  15606. #region 参数验证
  15607. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15608. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15609. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15610. #region 团组操作权限验证 76 酒店预定模块
  15611. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15612. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15613. #endregion
  15614. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15615. #region 页面操作权限验证
  15616. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15617. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15618. #endregion
  15619. #endregion
  15620. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  15621. }
  15622. /// <summary>
  15623. /// 酒店预订
  15624. /// 基础数据
  15625. /// </summary>
  15626. /// <param name="_dto"></param>
  15627. /// <returns></returns>
  15628. [HttpPost]
  15629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15630. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  15631. {
  15632. #region 参数验证
  15633. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15634. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15635. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15636. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15637. #region 页面操作权限验证
  15638. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15639. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15640. #endregion
  15641. #region 团组操作权限验证 76 酒店预定模块
  15642. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15643. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15644. #endregion
  15645. #endregion
  15646. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  15647. }
  15648. /// <summary>
  15649. /// 酒店预订
  15650. /// 创建 入住卷号码
  15651. /// </summary>
  15652. /// <param name="_dto"></param>
  15653. /// <returns></returns>
  15654. [HttpPost]
  15655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15656. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  15657. {
  15658. #region 参数验证
  15659. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15660. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15661. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15662. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15663. #region 页面操作权限验证
  15664. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15665. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15666. #endregion
  15667. #region 团组操作权限验证 76 酒店预定模块
  15668. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15669. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15670. #endregion
  15671. #endregion
  15672. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  15673. if (data.Code != 0)
  15674. {
  15675. return Ok(JsonView(false, data.Msg));
  15676. }
  15677. return Ok(JsonView(true, data.Msg, data.Data));
  15678. }
  15679. /// <summary>
  15680. /// 酒店预订
  15681. /// 详情
  15682. /// </summary>
  15683. /// <param name="_dto"></param>
  15684. /// <returns></returns>
  15685. [HttpPost]
  15686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15687. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  15688. {
  15689. #region 参数验证
  15690. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  15691. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15692. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  15693. #region 团组操作权限验证 76 酒店预定模块
  15694. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15695. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15696. #endregion
  15697. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15698. #region 页面操作权限验证
  15699. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15700. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15701. #endregion
  15702. #endregion
  15703. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  15704. }
  15705. /// <summary>
  15706. /// 酒店预订
  15707. /// Add Or Edit
  15708. /// </summary>
  15709. /// <param name="_dto"></param>
  15710. /// <returns></returns>
  15711. [HttpPost]
  15712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15713. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  15714. {
  15715. #region 参数验证
  15716. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15717. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15718. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15719. #region 团组操作权限验证 76 酒店预定模块
  15720. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15721. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15722. #endregion
  15723. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15724. #region 页面操作权限验证
  15725. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15726. if (_dto.Id == 0) // Add
  15727. {
  15728. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  15729. }
  15730. else if (_dto.Id > 1) // Edit
  15731. {
  15732. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  15733. }
  15734. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  15735. #endregion
  15736. #endregion
  15737. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  15738. if (_view.Code != 200)
  15739. {
  15740. return Ok(_view);
  15741. }
  15742. #region 成本无酒店价格数据进入超支
  15743. _sqlSugar.BeginTran();
  15744. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  15745. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  15746. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  15747. for (int i = 0; i < groupCost.Count; i++)
  15748. {
  15749. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  15750. {
  15751. groupCost[i].Date = groupCost[i - 1].Date;
  15752. }
  15753. }
  15754. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  15755. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  15756. List<Fin_GroupExtraCostDto_OP>();
  15757. if (start_Bool && end_Bool)
  15758. {
  15759. while (start_Time < end_Time)
  15760. {
  15761. foreach (var item in groupCost_Grp)
  15762. {
  15763. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  15764. {
  15765. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  15766. {
  15767. extraCostList.Add(new
  15768. Fin_GroupExtraCostDto_OP
  15769. {
  15770. Area = _dto.AreaId,
  15771. coefficient = 1.5M,
  15772. createUser = _dto.UserId,
  15773. currency = _dto.CardPriceCurrency,
  15774. diId = _dto.DiId,
  15775. ManagerConfirm = 0,
  15776. SupervisorConfirm = 0,
  15777. SYsupervisorConfirm = 0,
  15778. editType = 1,
  15779. PortType = 1,
  15780. price = _dto.CardPrice,
  15781. PriceCount = 1,
  15782. priceType = 1027,
  15783. priceDetailType = 1044,
  15784. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  15785. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  15786. });
  15787. }
  15788. }
  15789. }
  15790. start_Time = start_Time.AddDays(1);
  15791. }
  15792. }
  15793. if (extraCostList.Any())
  15794. {
  15795. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  15796. }
  15797. _sqlSugar.CommitTran();
  15798. #endregion
  15799. #region 应用推送
  15800. try
  15801. {
  15802. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15803. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15804. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15805. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15806. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15807. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15808. var diId = _dto.DiId;
  15809. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15810. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15811. #region 操作记录
  15812. var opInfo = new Crm_TableOperationRecord()
  15813. {
  15814. TableName = "Grp_HotelReservations",
  15815. PortType = _dto.PortType,
  15816. DataId = hotelId,
  15817. CreateUserId = _dto.UserId
  15818. };
  15819. //var opStatus = OperationEnum.NoOperation;
  15820. if (_dto.Id < 1) //添加操作
  15821. {
  15822. opInfo.OperationItem = OperationEnum.Add;
  15823. }
  15824. else if (_dto.Id > 0)
  15825. {
  15826. opInfo.OperationItem = OperationEnum.Edit;
  15827. }
  15828. string opRemark = string.Empty;
  15829. if (ccpInfo != null)
  15830. {
  15831. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  15832. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  15833. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  15834. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  15835. }
  15836. opInfo.Remark = opRemark;
  15837. await _tableorRep.AddAsync(opInfo);
  15838. #endregion
  15839. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  15840. //2024-10-21 新增LZ UID
  15841. var userIds = new List<int>() { 21 };
  15842. string title = $"费用审核";
  15843. string content = "";
  15844. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15845. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15846. try
  15847. {
  15848. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15849. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  15850. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  15851. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  15852. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  15853. }
  15854. catch (Exception ex)
  15855. {
  15856. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  15857. }
  15858. }
  15859. catch (Exception ex)
  15860. {
  15861. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  15862. }
  15863. try
  15864. {
  15865. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15866. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15867. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15868. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15869. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15870. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15871. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15872. //自动审核
  15873. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  15874. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  15875. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  15876. //2024-10-21 新增LZ UID
  15877. var userIds = new List<int>() { 21 };
  15878. string title = $"系统通知";
  15879. var diId = _dto.DiId;
  15880. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15881. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15882. string content = "";
  15883. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15884. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15885. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15886. }
  15887. catch (Exception ex)
  15888. {
  15889. }
  15890. #endregion
  15891. return Ok(_view);
  15892. }
  15893. /// <summary>
  15894. /// 酒店自动审核测试
  15895. /// Add Or Edit
  15896. /// </summary>
  15897. /// <param name="diid"></param>
  15898. /// <param name="dataId"></param>
  15899. /// <returns></returns>
  15900. [HttpPost]
  15901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15902. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  15903. {
  15904. #region 应用推送
  15905. try
  15906. {
  15907. //自动审核
  15908. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  15909. }
  15910. catch (Exception ex)
  15911. {
  15912. return Ok(JsonView(false, "操作失败"));
  15913. }
  15914. #endregion
  15915. return Ok(JsonView(false, "操作成功"));
  15916. }
  15917. /// <summary>
  15918. /// 酒店预订
  15919. /// Del
  15920. /// </summary>
  15921. /// <param name="_dto"></param>
  15922. /// <returns></returns>
  15923. [HttpPost]
  15924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15925. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  15926. {
  15927. #region 参数验证
  15928. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15929. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15930. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15931. #region 团组操作权限验证 76 酒店预定模块
  15932. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15933. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15934. #endregion
  15935. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15936. #region 页面操作权限验证
  15937. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15938. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  15939. #endregion
  15940. #endregion
  15941. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15942. #region 操作记录
  15943. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15944. {
  15945. TableName = "Grp_HotelReservations",
  15946. PortType = _dto.PortType,
  15947. OperationItem = OperationEnum.Del,
  15948. DataId = _dto.Id,
  15949. CreateUserId = _dto.UserId
  15950. });
  15951. #endregion
  15952. return Ok(data);
  15953. }
  15954. /// <summary>
  15955. /// 酒店预订
  15956. /// 生成VOUCHER
  15957. /// 2024.05.06 之前版本
  15958. /// </summary>
  15959. /// <param name="_dto"></param>
  15960. /// <returns></returns>
  15961. [HttpPost]
  15962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15963. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15964. {
  15965. try
  15966. {
  15967. #region 参数验证
  15968. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15969. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15970. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15971. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15972. #region 团组操作权限验证 76 酒店预定模块
  15973. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15974. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15975. #endregion
  15976. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15977. #region 页面操作权限验证
  15978. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15979. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15980. #endregion
  15981. #endregion
  15982. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15983. //判断数据是否完整
  15984. if (hr != null)
  15985. {
  15986. if (!string.IsNullOrEmpty(hr.DetermineNo))
  15987. {
  15988. string strFileName = "HotelStatement/";
  15989. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15990. if (dele != null)
  15991. strFileName += dele.TourCode;
  15992. //载入模板
  15993. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  15994. Document doc = new Document(sss);
  15995. DocumentBuilder builder = new DocumentBuilder(doc);
  15996. #region 替换Word模板书签内容
  15997. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  15998. //入住卷预定号码
  15999. if (doc.Range.Bookmarks["VNO"] != null)
  16000. {
  16001. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16002. mark.Text = hr.CheckNumber;
  16003. }
  16004. //酒店时间
  16005. if (doc.Range.Bookmarks["Date"] != null)
  16006. {
  16007. Bookmark mark = doc.Range.Bookmarks["Date"];
  16008. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16009. }
  16010. //团号
  16011. if (doc.Range.Bookmarks["TNo"] != null)
  16012. {
  16013. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16014. mark.Text = dele.TourCode;
  16015. }
  16016. //预定号码
  16017. if (doc.Range.Bookmarks["BookingId"] != null)
  16018. {
  16019. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16020. mark.Text = hr.ReservationsNo;
  16021. }
  16022. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16023. {
  16024. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16025. mark.Text = hr.DetermineNo;
  16026. }
  16027. //酒店城市
  16028. if (doc.Range.Bookmarks["City"] != null)
  16029. {
  16030. Bookmark mark = doc.Range.Bookmarks["City"];
  16031. mark.Text = hr.City;
  16032. }
  16033. //酒店名称
  16034. if (doc.Range.Bookmarks["HName"] != null)
  16035. {
  16036. Bookmark mark = doc.Range.Bookmarks["HName"];
  16037. mark.Text = hr.HotelName;
  16038. }
  16039. //酒店地址
  16040. if (doc.Range.Bookmarks["Address"] != null)
  16041. {
  16042. Bookmark mark = doc.Range.Bookmarks["Address"];
  16043. mark.Text = hr.HotelAddress;
  16044. }
  16045. //酒店电话
  16046. if (doc.Range.Bookmarks["Tel"] != null)
  16047. {
  16048. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16049. mark.Text = hr.HotelTel;
  16050. }
  16051. //酒店传真
  16052. if (doc.Range.Bookmarks["Fax"] != null)
  16053. {
  16054. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16055. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16056. {
  16057. mark.Text = hr.HotelFax;
  16058. }
  16059. }
  16060. //入住时间
  16061. if (doc.Range.Bookmarks["CIn"] != null)
  16062. {
  16063. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16064. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16065. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16066. }
  16067. //退房时间
  16068. if (doc.Range.Bookmarks["COut"] != null)
  16069. {
  16070. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16071. Bookmark mark = doc.Range.Bookmarks["COut"];
  16072. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16073. }
  16074. //客户名称
  16075. if (doc.Range.Bookmarks["GName"] != null)
  16076. {
  16077. string guestName = "";
  16078. string[] clients = new string[] { };
  16079. if (hr.GuestName.Contains(","))
  16080. {
  16081. clients = hr.GuestName.Split(",");
  16082. }
  16083. else
  16084. {
  16085. clients = new string[] { hr.GuestName };
  16086. }
  16087. List<int> clientIds_int = new List<int>();
  16088. if (clients.Length > 0)
  16089. {
  16090. foreach (var item in clients)
  16091. {
  16092. if (item.IsNumeric())
  16093. {
  16094. clientIds_int.Add(int.Parse(item));
  16095. }
  16096. }
  16097. }
  16098. if (clientIds_int.Count > 0)
  16099. {
  16100. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16101. foreach (var client in _clientDatas)
  16102. {
  16103. //男
  16104. if (client.Sex == 0) guestName += $"Mr.";
  16105. //女
  16106. else if (client.Sex == 1) guestName += $"Ms.";
  16107. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16108. {
  16109. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16110. }
  16111. //guestName += $"{client.Pinyin},";
  16112. }
  16113. if (guestName.Length > 0)
  16114. {
  16115. guestName = guestName.Substring(0, guestName.Length - 1);
  16116. }
  16117. }
  16118. else
  16119. {
  16120. guestName = hr.GuestName;
  16121. }
  16122. Bookmark mark = doc.Range.Bookmarks["GName"];
  16123. mark.Text = guestName;
  16124. }
  16125. //房间介绍
  16126. if (doc.Range.Bookmarks["ROOM"] != null)
  16127. {
  16128. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16129. mark.Text = hr.RoomExplanation;
  16130. }
  16131. //报价描述
  16132. if (doc.Range.Bookmarks["NOTE"] != null)
  16133. {
  16134. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16135. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16136. if (ss != null)
  16137. mark.Text = ss.Name;
  16138. }
  16139. //入住时间
  16140. if (doc.Range.Bookmarks["CheckIn"] != null)
  16141. {
  16142. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16143. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16144. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16145. }
  16146. //退房时间
  16147. if (doc.Range.Bookmarks["CheckOut"] != null)
  16148. {
  16149. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16150. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16151. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16152. }
  16153. //日期
  16154. if (doc.Range.Bookmarks["DT"] != null)
  16155. {
  16156. Bookmark mark = doc.Range.Bookmarks["DT"];
  16157. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16158. }
  16159. //名称
  16160. if (doc.Range.Bookmarks["VName"] != null)
  16161. {
  16162. Bookmark mark = doc.Range.Bookmarks["VName"];
  16163. mark.Text = hr.HotelName;
  16164. }
  16165. //号码
  16166. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  16167. {
  16168. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  16169. mark.Text = hr.CheckNumber;
  16170. }
  16171. #endregion
  16172. strFileName += "VOUCHER.doc";
  16173. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16174. doc.Save(fileDir);
  16175. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16176. return Ok(JsonView(true, "操作成功!", Url));
  16177. }
  16178. else
  16179. {
  16180. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  16181. }
  16182. }
  16183. else
  16184. {
  16185. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  16186. }
  16187. }
  16188. catch (Exception ex)
  16189. {
  16190. return Ok(JsonView(false, ex.Message));
  16191. }
  16192. }
  16193. /// <summary>
  16194. /// 酒店预订
  16195. /// 生成VOUCHER
  16196. /// 2024.05.06 之后版本
  16197. /// </summary>
  16198. /// <param name="_dto"></param>
  16199. /// <returns></returns>
  16200. [HttpPost]
  16201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16202. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  16203. {
  16204. #region 参数验证
  16205. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16206. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16207. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16208. #region 团组操作权限验证 76 酒店预定模块
  16209. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16210. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16211. #endregion
  16212. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16213. #region 页面操作权限验证
  16214. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16215. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16216. #endregion
  16217. #endregion
  16218. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  16219. //判断数据是否完整
  16220. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16221. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16222. string strFileName = "HotelStatement/";
  16223. string guestNames = ""; //格式Mr.xxx Ms.xxx
  16224. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  16225. #region 数据处理
  16226. List<int> guestIds = new List<int>();
  16227. //int index = 0;
  16228. foreach (var item in hrDtas)
  16229. {
  16230. if (item.GuestName.Contains(","))
  16231. {
  16232. string[] guestIdArr = item.GuestName.Split(',');
  16233. foreach (var guestIdStr in guestIdArr)
  16234. {
  16235. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  16236. if (guestBool)
  16237. {
  16238. guestIds.Add(guestId);
  16239. }
  16240. }
  16241. }
  16242. else guestNames += item.GuestName;
  16243. var voucherInfo = new HotelVoucherInfoView()
  16244. {
  16245. HotelName = item.HotelName,
  16246. CheckInDate = item.CheckInDate,
  16247. CheckOutDate = item.CheckOutDate,
  16248. ConfirmationNumber = item.DetermineNo.Trim(),
  16249. RoomType = item.RoomExplanation
  16250. };
  16251. vouchers.Add(voucherInfo);
  16252. }
  16253. if (guestIds.Count > 0)
  16254. {
  16255. guestIds = guestIds.Distinct().ToList();
  16256. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  16257. if (guestDatas.Count > 0)
  16258. {
  16259. guestNames = "";
  16260. foreach (var guest in guestDatas)
  16261. {
  16262. string guestName = "";
  16263. if (guest.Sex == 0) guestName += @"MR.";
  16264. else if (guest.Sex == 1) guestName += @"MS.";
  16265. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16266. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16267. guestNames += @$"{guestName.Trim()}、";
  16268. }
  16269. if (guestNames.Length > 0)
  16270. {
  16271. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16272. }
  16273. }
  16274. }
  16275. #endregion
  16276. //载入模板
  16277. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  16278. Document doc = new Document(sss);
  16279. DocumentBuilder builder = new DocumentBuilder(doc);
  16280. if (doc.Range.Bookmarks["GuestName"] != null)
  16281. {
  16282. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  16283. mark.Text = guestNames;
  16284. }
  16285. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16286. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  16287. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  16288. for (int i = 1; i <= vouchers.Count; i++)
  16289. {
  16290. HotelVoucherInfoView hviv = vouchers[i - 1];
  16291. builder.MoveToCell(0, i, 0, 0);
  16292. builder.Write(hviv.HotelName);
  16293. builder.MoveToCell(0, i, 1, 0);
  16294. builder.Write(hviv.CheckInDate);
  16295. builder.MoveToCell(0, i, 2, 0);
  16296. builder.Write(hviv.CheckOutDate);
  16297. builder.MoveToCell(0, i, 3, 0);
  16298. builder.Write(hviv.RoomType);
  16299. builder.MoveToCell(0, i, 4, 0);
  16300. builder.Write(hviv.ConfirmationNumber);
  16301. }
  16302. //删除多余行
  16303. int currRowIndex = vouchers.Count + 1;
  16304. int delRows = 21 - currRowIndex;
  16305. if (delRows > 0)
  16306. {
  16307. for (int i = 0; i < delRows; i++)
  16308. {
  16309. table.Rows.RemoveAt(currRowIndex);
  16310. //cultivateRowIndex++;
  16311. }
  16312. }
  16313. strFileName += "VOUCHER.docx";
  16314. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16315. doc.Save(fileDir);
  16316. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16317. return Ok(JsonView(true, "操作成功!", Url));
  16318. }
  16319. /// <summary>
  16320. /// 酒店预订
  16321. /// 生成VOUCHER 批量生成
  16322. /// New
  16323. /// </summary>
  16324. /// <param name="_dto"></param>
  16325. /// <returns></returns>
  16326. [HttpPost]
  16327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16328. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  16329. {
  16330. #region 参数验证
  16331. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16332. if (_dto.PageId < 1) _dto.PageId = 28;
  16333. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16334. #region 团组操作权限验证 76 酒店预定模块
  16335. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16336. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16337. #endregion
  16338. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16339. #region 页面操作权限验证
  16340. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16341. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16342. #endregion
  16343. #endregion
  16344. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  16345. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  16346. .OrderBy(x => x.CheckInDate)
  16347. .ToListAsync();
  16348. //判断数据是否完整
  16349. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16350. string strFileName = "HotelStatement/";
  16351. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16352. if (dele != null)
  16353. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  16354. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  16355. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  16356. .Where(it => it.IsDel == 0)
  16357. .ToListAsync();
  16358. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  16359. for (int i = 0; i < hrDtas.Count; i++)
  16360. {
  16361. string guestNames = string.Empty;
  16362. List<int> guestIds = new List<int>();
  16363. var item = hrDtas[i];
  16364. //处理客户姓名
  16365. if (item.GuestName.Contains(","))
  16366. {
  16367. string[] guestIdArr = item.GuestName.Split(',');
  16368. foreach (var guestIdStr in guestIdArr)
  16369. if (int.TryParse(guestIdStr, out int guestId))
  16370. guestIds.Add(guestId);
  16371. }
  16372. else
  16373. {
  16374. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  16375. if (guestIdBool)
  16376. {
  16377. guestIds.Add(guestId);
  16378. }
  16379. //NaN
  16380. if (item.GuestName.Contains("NaN"))
  16381. {
  16382. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  16383. }
  16384. }
  16385. if (guestIds.Count > 0)
  16386. {
  16387. guestIds = guestIds.Distinct().ToList();
  16388. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  16389. if (guestDatas1.Count > 0)
  16390. {
  16391. guestNames = "";
  16392. foreach (var guest in guestDatas1)
  16393. {
  16394. string guestName = "";
  16395. if (guest.Sex == 0) guestName += @"MR.";
  16396. else if (guest.Sex == 1) guestName += @"MS.";
  16397. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16398. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16399. guestNames += @$"{guestName.Trim()}、";
  16400. }
  16401. if (guestNames.Length > 0)
  16402. {
  16403. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16404. }
  16405. }
  16406. }
  16407. //if (!string.IsNullOrEmpty(guestNames))
  16408. //{
  16409. hrDtas[i].GuestName = guestNames;
  16410. //}
  16411. }
  16412. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  16413. Document doc = new Document();
  16414. DocumentBuilder builder = new DocumentBuilder(doc);
  16415. try
  16416. {
  16417. builder.MoveToDocumentStart();
  16418. foreach (var item in hrDtas)
  16419. {
  16420. //标题
  16421. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16422. builder.ParagraphFormat.LineSpacing = 1;
  16423. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16424. builder.ParagraphFormat.Style.Font.Size = 9;
  16425. builder.ParagraphFormat.Style.Font.Bold = true;
  16426. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16427. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  16428. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16429. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16430. builder.ParagraphFormat.LineSpacing = 1;
  16431. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16432. builder.ParagraphFormat.Style.Font.Size = 9;
  16433. builder.ParagraphFormat.Style.Font.Bold = true;
  16434. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  16435. builder.StartTable();
  16436. // 设置边框颜色
  16437. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  16438. //设置边框样式
  16439. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  16440. //表格
  16441. #region 第一行
  16442. builder.InsertCell();
  16443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16444. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16445. //builder.CellFormat.AllowAutoFit = false;
  16446. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16447. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16448. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16449. builder.CellFormat.WrapText = true; //自动换行
  16450. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16451. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  16452. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16453. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16454. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16455. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16456. builder.Write("TOUR NO:");
  16457. builder.InsertCell();
  16458. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16459. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16460. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16461. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16462. builder.ParagraphFormat.Style.Font.Bold = false;
  16463. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16464. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16465. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16466. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16467. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16468. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16469. builder.Write($"{dele?.TourCode ?? "-"}");
  16470. builder.InsertCell();
  16471. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16472. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16473. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16474. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16475. builder.ParagraphFormat.Style.Font.Bold = false;
  16476. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16477. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16478. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16479. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16480. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16481. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16482. builder.Write($"CITY:");
  16483. builder.InsertCell();
  16484. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16485. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16486. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16487. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16488. builder.ParagraphFormat.Style.Font.Bold = false;
  16489. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16490. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16491. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16492. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16493. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16494. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16495. builder.Write($"{item.City}");
  16496. builder.EndRow();
  16497. #endregion
  16498. #region 第二行
  16499. builder.InsertCell();
  16500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16501. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16502. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16503. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16504. builder.ParagraphFormat.Style.Font.Bold = false;
  16505. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16506. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16507. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16508. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16509. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16510. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16511. builder.Write("CONFIRMATION NO:");
  16512. builder.InsertCell();
  16513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16514. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16515. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16516. builder.ParagraphFormat.Style.Font.Bold = false;
  16517. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16518. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16519. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16520. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16521. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16522. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16523. builder.CellFormat.VerticalMerge = CellMerge.None;
  16524. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16525. builder.Write($"{item.DetermineNo}");
  16526. builder.InsertCell();
  16527. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16528. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16529. builder.InsertCell();
  16530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16531. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16532. builder.EndRow();
  16533. #endregion
  16534. #region 第三行
  16535. builder.InsertCell();
  16536. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16537. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16538. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16539. builder.ParagraphFormat.Style.Font.Bold = false;
  16540. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16541. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16542. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16543. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16544. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16545. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16546. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16547. builder.Write($"HOTEL NAME:");
  16548. builder.InsertCell();
  16549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16550. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16551. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16552. builder.ParagraphFormat.Style.Font.Bold = false;
  16553. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16554. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16555. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16556. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16557. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16558. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16559. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16560. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16561. builder.Write($"{item.HotelName}");
  16562. builder.InsertCell();
  16563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16564. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16565. builder.InsertCell();
  16566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16567. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16568. builder.EndRow();
  16569. #endregion
  16570. #region 第四行
  16571. builder.InsertCell();
  16572. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16573. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16574. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16575. builder.ParagraphFormat.Style.Font.Bold = false;
  16576. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16577. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16578. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16579. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16580. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16581. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16582. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16583. builder.Write($"HOTEL ADDRESS:");
  16584. builder.InsertCell();
  16585. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16586. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16587. builder.ParagraphFormat.Style.Font.Size = 8;
  16588. builder.ParagraphFormat.Style.Font.Bold = false;
  16589. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16590. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16591. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16592. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16593. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16594. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16595. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16596. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16597. builder.Write($"{item.HotelAddress}");
  16598. builder.InsertCell();
  16599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16600. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16601. builder.InsertCell();
  16602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16603. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16604. builder.EndRow();
  16605. #endregion
  16606. #region 第五行
  16607. builder.InsertCell();
  16608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16611. builder.ParagraphFormat.Style.Font.Bold = false;
  16612. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16619. builder.Write("TEL:");
  16620. builder.InsertCell();
  16621. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16622. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16623. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16624. builder.ParagraphFormat.Style.Font.Bold = false;
  16625. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16626. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16627. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16628. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16629. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16630. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16631. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16632. builder.Write($"{item.HotelTel}");
  16633. builder.InsertCell();
  16634. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16635. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16636. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16637. builder.ParagraphFormat.Style.Font.Bold = false;
  16638. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16639. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16640. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16641. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16642. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16643. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16644. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16645. builder.Write($"FAX:");
  16646. builder.InsertCell();
  16647. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16648. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16649. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16650. builder.ParagraphFormat.Style.Font.Bold = false;
  16651. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16652. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16653. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16654. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16655. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16656. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16657. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16658. builder.Write($"{item.HotelFax}");
  16659. builder.EndRow();
  16660. #endregion
  16661. #region 第六行
  16662. builder.InsertCell();
  16663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16664. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16665. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16666. builder.ParagraphFormat.Style.Font.Bold = false;
  16667. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16668. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16669. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16670. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16671. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16672. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16673. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16674. builder.Write("CHECK IN:");
  16675. builder.InsertCell();
  16676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16677. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16678. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16679. builder.ParagraphFormat.Style.Font.Bold = false;
  16680. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16687. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  16688. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16689. builder.Write($"{checkInStr}");
  16690. builder.InsertCell();
  16691. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16692. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16693. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16694. builder.ParagraphFormat.Style.Font.Bold = false;
  16695. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16696. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16697. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16698. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16699. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16700. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16701. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16702. builder.Write($"CHECK OUT:");
  16703. builder.InsertCell();
  16704. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16705. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16706. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16707. builder.ParagraphFormat.Style.Font.Bold = false;
  16708. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16709. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16710. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16711. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16712. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16713. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16714. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16715. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  16716. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  16717. builder.Write($"{checkOutStr}");
  16718. builder.EndRow();
  16719. #endregion
  16720. #region 第七行
  16721. builder.InsertCell();
  16722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16723. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16724. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16725. builder.ParagraphFormat.Style.Font.Bold = false;
  16726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16733. builder.Write($"GUEST NAME:");
  16734. builder.InsertCell();
  16735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16737. builder.ParagraphFormat.Style.Font.Size = 8;
  16738. builder.ParagraphFormat.Style.Font.Bold = false;
  16739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16746. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16747. builder.Write($"{item.GuestName}");
  16748. builder.InsertCell();
  16749. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16750. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16751. builder.InsertCell();
  16752. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16753. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16754. builder.EndRow();
  16755. #endregion
  16756. #region 第八行
  16757. builder.InsertCell();
  16758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16759. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16760. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16761. builder.ParagraphFormat.Style.Font.Bold = false;
  16762. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16763. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16764. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16765. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16766. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16767. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16768. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16769. builder.Write($"ROOM TYPE:");
  16770. builder.InsertCell();
  16771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16772. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16773. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16774. builder.ParagraphFormat.Style.Font.Bold = false;
  16775. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16776. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16777. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16778. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16779. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16780. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16781. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16782. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16783. builder.Write($"{item.RoomExplanation}");
  16784. builder.InsertCell();
  16785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16786. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16787. builder.InsertCell();
  16788. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16789. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16790. builder.EndRow();
  16791. #endregion
  16792. #region 第九行
  16793. builder.InsertCell();
  16794. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16795. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16796. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16797. builder.ParagraphFormat.Style.Font.Bold = false;
  16798. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16799. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16801. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16802. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16803. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16804. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16805. builder.Write($"NOTE:");
  16806. builder.InsertCell();
  16807. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16808. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16809. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16810. builder.ParagraphFormat.Style.Font.Bold = false;
  16811. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16812. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16813. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16814. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16815. 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.");
  16816. builder.InsertCell();
  16817. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16818. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16819. builder.InsertCell();
  16820. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16821. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16822. builder.EndRow();
  16823. #endregion
  16824. builder.EndTable();
  16825. //换行
  16826. builder.Writeln("");
  16827. builder.Writeln("");
  16828. }
  16829. #region 获取文档中的所有表格 设置文字自适应
  16830. // 获取文档中的所有表格。
  16831. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  16832. {
  16833. // 遍历表格中的所有行。
  16834. foreach (Aspose.Words.Tables.Row row in table.Rows)
  16835. {
  16836. foreach (Cell cell in row.Cells)
  16837. {
  16838. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  16839. cellFormat.Width = 0;
  16840. }
  16841. }
  16842. }
  16843. #endregion
  16844. #region 设置页眉
  16845. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  16846. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  16847. if (System.IO.File.Exists(voucherHeaderPath))
  16848. {
  16849. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  16850. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  16851. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  16852. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  16853. // 调整图片位置
  16854. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  16855. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  16856. shape.Top = 50; // 将图片距离页眉上边缘的距离
  16857. shape.Left = 0; // 将图片距离页面左边缘的距离
  16858. shape.Width = 81; // 设置图片宽度
  16859. shape.Height = 36; // 设置图片高度
  16860. }
  16861. //靠右
  16862. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16863. //// 设置页脚上下边距
  16864. //builder.PageSetup.HeaderDistance = 42;
  16865. // 添加页眉线
  16866. Aspose.Words.Border borderHeader = null;
  16867. try
  16868. {
  16869. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  16870. }
  16871. catch (Exception e)
  16872. {
  16873. // TODO Auto-generated catch block
  16874. //e.printStackTrace();
  16875. }
  16876. borderHeader.Shadow = true;
  16877. borderHeader.DistanceFromText = 2;
  16878. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  16879. #endregion
  16880. }
  16881. catch (Exception ex)
  16882. {
  16883. }
  16884. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16885. doc.Save(fileDir);
  16886. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16887. return Ok(JsonView(true, "操作成功!", Url));
  16888. }
  16889. /// <summary>
  16890. /// 酒店预订
  16891. /// 生成 预定成本 Excel
  16892. /// </summary>
  16893. /// <param name="_dto"></param>
  16894. /// <returns></returns>
  16895. [HttpPost]
  16896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16897. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  16898. {
  16899. #region 参数验证
  16900. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  16901. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  16902. if (!vadalitorRes.IsValid)
  16903. {
  16904. var errors = new StringBuilder();
  16905. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  16906. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  16907. }
  16908. #region 团组操作权限验证 76 酒店预定模块
  16909. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16910. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16911. #endregion
  16912. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16913. #region 页面操作权限验证
  16914. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16915. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16916. #endregion
  16917. #endregion
  16918. decimal _rate = 1.00M;
  16919. string _currency = string.Empty;
  16920. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  16921. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16922. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  16923. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16924. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  16925. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  16926. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  16927. if (_GroupCostParameter == null)
  16928. {
  16929. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  16930. bool isIntType = int.TryParse(_currency, out int currId);
  16931. if (isIntType)
  16932. {
  16933. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16934. }
  16935. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16936. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16937. if (currInfo == null)
  16938. {
  16939. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16940. }
  16941. else _rate = currInfo.Rate;
  16942. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16943. {
  16944. _rate = _GroupCostParameter.Rate;
  16945. }
  16946. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16947. //string strFileName = "HotelStatement/";
  16948. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16949. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16950. var rateDatas = new List<dynamic>();
  16951. #region 数据处理
  16952. foreach (var item in hrDtas)
  16953. {
  16954. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16955. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16956. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16957. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16958. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16959. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16960. {
  16961. continue;
  16962. }
  16963. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16964. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16965. string singleRoomFeeStr = string.Empty,
  16966. doubleRoomFeeStr = string.Empty,
  16967. suiteRoomFeeStr = string.Empty,
  16968. otherRoomFeeStr = string.Empty,
  16969. payMoneyStr = string.Empty,
  16970. cardPriceStr = string.Empty;
  16971. if (roomCurr.Equals("CNY"))
  16972. {
  16973. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16974. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16975. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16976. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16977. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16978. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16979. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16980. }
  16981. else
  16982. {
  16983. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16984. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16985. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16986. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16987. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16988. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16989. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16990. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16991. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16992. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16993. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  16994. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  16995. if (ccpPaymentCurrency.Equals("CNY"))
  16996. {
  16997. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  16998. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16999. }
  17000. else
  17001. {
  17002. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17003. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17004. }
  17005. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17006. if (hotelcardPriceCurrency.Equals("CNY"))
  17007. {
  17008. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17009. }
  17010. else
  17011. {
  17012. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17013. }
  17014. }
  17015. string breakfastPriceStr = string.Empty,
  17016. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17017. governmentRentStr = string.Empty,
  17018. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17019. cityTaxStr = string.Empty,
  17020. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17021. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17022. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17023. {
  17024. if (breakfastCurrency1.Equals("CNY"))
  17025. {
  17026. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17027. }
  17028. else
  17029. {
  17030. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17031. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17032. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17033. }
  17034. }
  17035. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17036. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17037. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17038. {
  17039. if (governmentRentCurrency.Equals("CNY"))
  17040. {
  17041. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17042. }
  17043. else
  17044. {
  17045. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17046. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17047. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17048. }
  17049. }
  17050. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17051. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17052. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17053. {
  17054. if (cityTaxStrCurrency1.Equals("CNY"))
  17055. {
  17056. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17057. }
  17058. else
  17059. {
  17060. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17061. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17062. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17063. }
  17064. }
  17065. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17066. int payDId = roomInfo?.PayDId ?? 0;
  17067. pcfds.Add(new HotelReservations_PCFD_View()
  17068. {
  17069. City = item.City,
  17070. HotelName = item.HotelName,
  17071. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17072. // SingleRoomCount = item.SingleRoomCount,
  17073. SingleRoomPrice = singleRoomFeeStr,
  17074. // DoubleRoomCount = item.DoubleRoomCount,
  17075. DoubleRoomPrice = doubleRoomFeeStr,
  17076. //SuiteRoomCount = item.SuiteRoomCount,
  17077. SuiteRoomPrice = suiteRoomFeeStr,
  17078. OtherRoomPrice = otherRoomFeeStr,
  17079. //OtherRoomCount = item.OtherRoomCount,
  17080. BreakfastPrice = breakfastPriceStr,
  17081. GovernmentRent = governmentRentStr,
  17082. CityTax = cityTaxStr,
  17083. RoomExplanation = item.RoomExplanation,
  17084. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17085. PayTime = roomInfo?.ConsumptionDate,
  17086. BankNo = roomInfo?.BankNo,
  17087. PayMoney = payMoneyStr,
  17088. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17089. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17090. CardPrice = cardPriceStr,
  17091. Remark = ccpInfo.Remark
  17092. });
  17093. }
  17094. #endregion
  17095. //载入模板
  17096. WorkbookDesigner designer = new WorkbookDesigner();
  17097. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17098. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17099. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17100. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17101. var rateDatas1 = rateDatas.Distinct();
  17102. var rateStr = string.Empty;
  17103. foreach (var item in rateDatas1)
  17104. {
  17105. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17106. }
  17107. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17108. designer.SetDataSource("Opertor", userInfo.CnName);
  17109. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17110. dt.TableName = "ViewMyHotelReservations";
  17111. designer.SetDataSource(dt);
  17112. designer.Process();
  17113. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17114. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17115. designer.Workbook.Save(serverPath);
  17116. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17117. #region 删除指定行
  17118. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17119. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17120. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17121. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17122. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17123. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17124. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17125. cssIndex = dt.Columns["CityTax"].Ordinal,
  17126. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17127. remarkIndex = dt.Columns["Remark"].Ordinal;
  17128. //删除指定列
  17129. foreach (DataRow item in dt.Rows)
  17130. {
  17131. string singleStr = item["SingleRoomPrice"].ToString();
  17132. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17133. if (containsDigitButNotZero1) singleDel = false;
  17134. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17135. string doubleStr = item["DoubleRoomPrice"].ToString();
  17136. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17137. if (containsDigitButNotZero2) doubleDel = false;
  17138. string suiteStr = item["SuiteRoomPrice"].ToString();
  17139. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17140. if (containsDigitButNotZero3) suiteDel = false;
  17141. string otherStr = item["OtherRoomPrice"].ToString();
  17142. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17143. if (containsDigitButNotZero4) otherDel = false;
  17144. string zcStr = item["BreakfastPrice"].ToString();
  17145. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17146. if (containsDigitButNotZero5) zcDel = false;
  17147. string dsStr = item["GovernmentRent"].ToString();
  17148. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17149. if (containsDigitButNotZero6) dsDel = false;
  17150. string cssStr = item["CityTax"].ToString();
  17151. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17152. if (containsDigitButNotZero7) cssDel = false;
  17153. string cpStr = item["ConsumptionPatterns"].ToString();
  17154. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17155. string remarkStr = item["Remark"].ToString();
  17156. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17157. }
  17158. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17159. DeleteColumn(serverPath, cpIndex, cpDel);
  17160. DeleteColumn(serverPath, dsIndex, dsDel);
  17161. DeleteColumn(serverPath, cssIndex, cssDel);
  17162. DeleteColumn(serverPath, zcIndex, zcDel);
  17163. DeleteColumn(serverPath, otherIndex, otherDel);
  17164. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17165. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17166. DeleteColumn(serverPath, singleIndex, singleDel);
  17167. #endregion
  17168. //只保留第一个表格
  17169. DeleteSheet(serverPath);
  17170. return Ok(JsonView(true, "操作成功", url = rst));
  17171. }
  17172. else
  17173. {
  17174. _currency = _GroupCostParameter.Currency;
  17175. bool isIntType = int.TryParse(_currency, out int currId);
  17176. if (isIntType)
  17177. {
  17178. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17179. }
  17180. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17181. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17182. if (currInfo == null)
  17183. {
  17184. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17185. }
  17186. if (!_currency.ToUpper().Equals("CNY"))
  17187. {
  17188. _rate = _GroupCostParameter.Rate;
  17189. }
  17190. _rate = currInfo.Rate;
  17191. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17192. //string strFileName = "HotelStatement/";
  17193. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17194. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17195. #region 数据处理
  17196. foreach (var item in hrDtas)
  17197. {
  17198. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17199. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17200. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17201. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17202. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17203. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17204. string singleRoomFeeStr = string.Empty,
  17205. doubleRoomFeeStr = string.Empty,
  17206. suiteRoomFeeStr = string.Empty,
  17207. otherRoomFeeStr = string.Empty,
  17208. payMoneyStr = string.Empty,
  17209. cardPriceStr = string.Empty;
  17210. if (roomCurr.Equals(_currency))
  17211. {
  17212. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  17213. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  17214. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  17215. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  17216. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  17217. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  17218. }
  17219. else
  17220. {
  17221. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17222. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17223. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17224. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17225. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17226. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17227. }
  17228. string breakfastPriceStr = string.Empty,
  17229. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17230. governmentRentStr = string.Empty,
  17231. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17232. cityTaxStrStr = string.Empty,
  17233. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17234. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  17235. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  17236. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  17237. int payDId = roomInfo?.PayDId ?? 0;
  17238. pcfds.Add(new HotelReservations_PCFD_View()
  17239. {
  17240. City = item.City,
  17241. HotelName = item.HotelName,
  17242. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17243. // SingleRoomCount = item.SingleRoomCount,
  17244. SingleRoomPrice = singleRoomFeeStr,
  17245. // DoubleRoomCount = item.DoubleRoomCount,
  17246. DoubleRoomPrice = doubleRoomFeeStr,
  17247. //SuiteRoomCount = item.SuiteRoomCount,
  17248. SuiteRoomPrice = suiteRoomFeeStr,
  17249. OtherRoomPrice = otherRoomFeeStr,
  17250. //OtherRoomCount = item.OtherRoomCount,
  17251. BreakfastPrice = breakfastPriceStr,
  17252. GovernmentRent = governmentRentStr,
  17253. CityTax = cityTaxStrStr,
  17254. RoomExplanation = item.RoomExplanation,
  17255. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17256. PayTime = roomInfo?.ConsumptionDate,
  17257. BankNo = roomInfo?.BankNo,
  17258. PayMoney = payMoneyStr,
  17259. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17260. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17261. CardPrice = cardPriceStr,
  17262. Remark = ccpInfo.Remark
  17263. });
  17264. }
  17265. #endregion
  17266. //载入模板
  17267. WorkbookDesigner designer = new WorkbookDesigner();
  17268. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17269. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17270. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17271. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17272. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  17273. designer.SetDataSource("Opertor", userInfo.CnName);
  17274. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17275. dt.TableName = "ViewMyHotelReservations";
  17276. designer.SetDataSource(dt);
  17277. designer.Process();
  17278. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17279. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17280. designer.Workbook.Save(serverPath);
  17281. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17282. #region 删除指定行
  17283. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17284. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17285. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17286. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17287. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17288. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17289. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17290. cssIndex = dt.Columns["CityTax"].Ordinal,
  17291. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17292. remarkIndex = dt.Columns["Remark"].Ordinal;
  17293. //删除指定列
  17294. foreach (DataRow item in dt.Rows)
  17295. {
  17296. string singleStr = item["SingleRoomPrice"].ToString();
  17297. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17298. if (containsDigitButNotZero1) singleDel = false;
  17299. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17300. string doubleStr = item["DoubleRoomPrice"].ToString();
  17301. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17302. if (containsDigitButNotZero2) doubleDel = false;
  17303. string suiteStr = item["SuiteRoomPrice"].ToString();
  17304. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17305. if (containsDigitButNotZero3) suiteDel = false;
  17306. string otherStr = item["OtherRoomPrice"].ToString();
  17307. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17308. if (containsDigitButNotZero4) otherDel = false;
  17309. string zcStr = item["BreakfastPrice"].ToString();
  17310. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17311. if (containsDigitButNotZero5) zcDel = false;
  17312. string dsStr = item["GovernmentRent"].ToString();
  17313. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17314. if (containsDigitButNotZero6) dsDel = false;
  17315. string cssStr = item["CityTax"].ToString();
  17316. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17317. if (containsDigitButNotZero7) cssDel = false;
  17318. string cpStr = item["ConsumptionPatterns"].ToString();
  17319. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17320. string remarkStr = item["Remark"].ToString();
  17321. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17322. }
  17323. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17324. DeleteColumn(serverPath, cpIndex, cpDel);
  17325. DeleteColumn(serverPath, dsIndex, dsDel);
  17326. DeleteColumn(serverPath, cssIndex, cssDel);
  17327. DeleteColumn(serverPath, zcIndex, zcDel);
  17328. DeleteColumn(serverPath, otherIndex, otherDel);
  17329. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17330. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17331. DeleteColumn(serverPath, singleIndex, singleDel);
  17332. #endregion
  17333. //只保留第一个表格
  17334. DeleteSheet(serverPath);
  17335. return Ok(JsonView(true, "操作成功", url = rst));
  17336. }
  17337. //return Ok(JsonView(false));
  17338. }
  17339. /// <summary>
  17340. /// 删除指定列
  17341. /// </summary>
  17342. /// <param name="file"></param>
  17343. /// <param name="columnIndex"></param>
  17344. /// <param name="isDel"></param>
  17345. private void DeleteColumn(string file, int columnIndex, bool isDel)
  17346. {
  17347. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17348. //wb.Save(file);
  17349. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  17350. if (sheet1 != null)
  17351. {
  17352. if (isDel)
  17353. {
  17354. Cells cells = sheet1.Cells;
  17355. cells.DeleteColumn(columnIndex);
  17356. }
  17357. }
  17358. wb.Save(file);
  17359. }
  17360. /// <summary>
  17361. /// 删除sheet
  17362. /// </summary>
  17363. /// <param name="file"></param>
  17364. /// <param name="sheetName"></param>
  17365. private void DeleteSheet(string file, string sheetName = "")
  17366. {
  17367. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17368. //wb.Save(file);
  17369. List<string> sheets = new List<string>();
  17370. foreach (var item in wb.Worksheets)
  17371. {
  17372. sheets.Add(item.Name);
  17373. }
  17374. if (sheets.Count > 0)
  17375. {
  17376. sheets.RemoveAt(0);//不删除第一个sheet
  17377. foreach (var item in sheets)
  17378. {
  17379. wb.Worksheets.RemoveAt(item);
  17380. }
  17381. }
  17382. wb.Save(file);
  17383. }
  17384. /// <summary>
  17385. /// 酒店预订
  17386. /// 确认单
  17387. /// </summary>
  17388. /// <param name="_dto"></param>
  17389. /// <returns></returns>
  17390. [HttpPost]
  17391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17392. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  17393. {
  17394. try
  17395. {
  17396. #region 参数验证
  17397. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17398. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17399. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17400. #region 团组操作权限验证 76 酒店预定模块
  17401. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17402. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17403. #endregion
  17404. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17405. #region 页面操作权限验证
  17406. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17407. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17408. #endregion
  17409. #endregion
  17410. //团组信息
  17411. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  17412. //酒店数据
  17413. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  17414. if (listhoteldata.Count < 0)
  17415. {
  17416. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  17417. }
  17418. //利datatable存储
  17419. DataTable dt = new DataTable();
  17420. dt.Columns.Add("CheckInDate", typeof(string));
  17421. dt.Columns.Add("City", typeof(string));
  17422. dt.Columns.Add("Hotel", typeof(string));
  17423. dt.Columns.Add("Room", typeof(string));
  17424. for (int i = 0; i < listhoteldata.Count; i++)
  17425. {
  17426. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  17427. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  17428. while (dayStart < dayEnd)
  17429. {
  17430. string temp = "";
  17431. DataRow row = dt.NewRow();
  17432. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  17433. row["City"] = listhoteldata[i].City;
  17434. row["Hotel"] = listhoteldata[i].HotelName;
  17435. if (listhoteldata[i].SingleRoomCount > 0)
  17436. {
  17437. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  17438. }
  17439. if (listhoteldata[i].DoubleRoomCount > 0)
  17440. {
  17441. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  17442. }
  17443. if (listhoteldata[i].SuiteRoomCount > 0)
  17444. {
  17445. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  17446. }
  17447. if (listhoteldata[i].OtherRoomCount > 0)
  17448. {
  17449. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  17450. }
  17451. row["Room"] = temp;
  17452. dt.Rows.Add(row);
  17453. dayStart = dayStart.AddDays(1);
  17454. }
  17455. }
  17456. Dictionary<string, string> dic = new Dictionary<string, string>();
  17457. dic.Add("Dele", di.TeamName);
  17458. dic.Add("City", di.VisitCountry);
  17459. //模板路径
  17460. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  17461. //载入模板
  17462. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  17463. DocumentBuilder builder = new DocumentBuilder(doc);
  17464. foreach (var key in dic.Keys)
  17465. {
  17466. builder.MoveToBookmark(key);
  17467. builder.Write(dic[key]);
  17468. }
  17469. //获取word里所有表格
  17470. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17471. //获取所填表格的序数
  17472. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17473. var rowStart = tableOne.Rows[0]; //获取第1行
  17474. //循环赋值
  17475. for (int i = 0; i < dt.Rows.Count; i++)
  17476. {
  17477. builder.MoveToCell(0, i + 1, 0, 0);
  17478. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  17479. builder.MoveToCell(0, i + 1, 1, 0);
  17480. builder.Write(dt.Rows[i]["City"].ToString());
  17481. builder.MoveToCell(0, i + 1, 2, 0);
  17482. builder.Write(dt.Rows[i]["Hotel"].ToString());
  17483. builder.MoveToCell(0, i + 1, 3, 0);
  17484. builder.Write(dt.Rows[i]["Room"].ToString());
  17485. }
  17486. //删除多余行
  17487. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  17488. {
  17489. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  17490. }
  17491. string strFileName = di.TeamName + "酒店确认单.doc";
  17492. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  17493. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  17494. return Ok(JsonView(true, "成功", url));
  17495. }
  17496. catch (Exception ex)
  17497. {
  17498. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  17499. }
  17500. }
  17501. #endregion
  17502. #region 团组状态
  17503. /// <summary>
  17504. /// 团组状态列表 Page
  17505. /// </summary>
  17506. /// <param name="dto">团组列表请求dto</param>
  17507. /// <returns></returns>
  17508. [HttpPost]
  17509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17510. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  17511. {
  17512. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17513. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  17514. {
  17515. string sqlWhere = string.Empty;
  17516. if (dto.IsSure == 0) //未完成
  17517. {
  17518. sqlWhere += string.Format(@" And IsSure = 0");
  17519. }
  17520. else if (dto.IsSure == 1) //已完成
  17521. {
  17522. sqlWhere += string.Format(@" And IsSure = 1");
  17523. }
  17524. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  17525. {
  17526. string tj = dto.SearchCriteria;
  17527. 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}%')",
  17528. tj, tj, tj, tj, tj);
  17529. }
  17530. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  17531. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  17532. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  17533. From (
  17534. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  17535. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  17536. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  17537. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  17538. From Grp_DelegationInfo gdi
  17539. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  17540. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  17541. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  17542. Where gdi.IsDel = 0 {0}
  17543. ) temp ", sqlWhere);
  17544. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  17545. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  17546. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  17547. }
  17548. else
  17549. {
  17550. return Ok(JsonView(false, "查询失败"));
  17551. }
  17552. }
  17553. /// <summary>
  17554. /// 团组状态
  17555. /// 设置操作完成
  17556. /// </summary>
  17557. /// <param name="dto">团组列表请求dto</param>
  17558. /// <returns></returns>
  17559. [HttpPost]
  17560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17561. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  17562. {
  17563. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17564. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  17565. {
  17566. Id = dto.Id,
  17567. IsSure = 1
  17568. };
  17569. var result = await _sqlSugar.Updateable(_DelegationInfo)
  17570. .UpdateColumns(it => new { it.IsSure })
  17571. .WhereColumns(it => new { it.Id })
  17572. .ExecuteCommandAsync();
  17573. if (result > 0)
  17574. {
  17575. return Ok(JsonView(true, "操作完成!"));
  17576. }
  17577. return Ok(JsonView(false, "操作失败!"));
  17578. }
  17579. #endregion
  17580. #region 保险费用录入
  17581. /// <summary>
  17582. /// 根据团组Id查询保险费用列表
  17583. /// </summary>
  17584. /// <param name="dto"></param>
  17585. /// <returns></returns>
  17586. [HttpPost]
  17587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17588. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  17589. {
  17590. Result groupData = await _customersRep.CustomersByDiId(dto);
  17591. if (groupData.Code != 0)
  17592. {
  17593. return Ok(JsonView(false, groupData.Msg));
  17594. }
  17595. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17596. }
  17597. /// <summary>
  17598. /// 根据保险费用Id查询保险费用详细
  17599. /// </summary>
  17600. /// <param name="dto"></param>
  17601. /// <returns></returns>
  17602. [HttpPost]
  17603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17604. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  17605. {
  17606. try
  17607. {
  17608. Result groupData = await _customersRep.CustomersById(dto);
  17609. if (groupData.Code != 0)
  17610. {
  17611. return Ok(JsonView(false, groupData.Msg));
  17612. }
  17613. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17614. }
  17615. catch (Exception ex)
  17616. {
  17617. return Ok(JsonView(false, ex.Message));
  17618. }
  17619. }
  17620. /// <summary>
  17621. /// 保险费用录入页面初始化绑定
  17622. /// </summary>
  17623. /// <param name="dto"></param>
  17624. /// <returns></returns>
  17625. [HttpPost]
  17626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17627. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  17628. {
  17629. try
  17630. {
  17631. Result groupData = await _customersRep.CustomersInitialize(dto);
  17632. if (groupData.Code != 0)
  17633. {
  17634. return Ok(JsonView(false, groupData.Msg));
  17635. }
  17636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17637. }
  17638. catch (Exception ex)
  17639. {
  17640. return Ok(JsonView(false, ex.Message));
  17641. }
  17642. }
  17643. /// <summary>
  17644. /// 保险费用操作(Status:1.新增,2.修改)
  17645. /// </summary>
  17646. /// <param name="dto"></param>
  17647. /// <returns></returns>
  17648. [HttpPost]
  17649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17650. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  17651. {
  17652. Result groupData = await _customersRep.OpCustomers(dto);
  17653. if (groupData.Code != 0)
  17654. {
  17655. return Ok(JsonView(false, groupData.Msg));
  17656. }
  17657. #region 应用推送
  17658. try
  17659. {
  17660. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  17661. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  17662. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  17663. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17664. //自动审核
  17665. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  17666. //2024-10-21 新增LZ UID
  17667. var userIds = new List<int>() { 21 };
  17668. string title = $"系统通知";
  17669. var diId = dto.DiId;
  17670. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17671. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17672. string content = "";
  17673. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17674. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17675. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17676. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  17677. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  17678. }
  17679. catch (Exception ex)
  17680. {
  17681. }
  17682. #endregion
  17683. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17684. }
  17685. /// <summary>
  17686. /// 保险文件上传
  17687. /// </summary>
  17688. /// <param name="file"></param>
  17689. /// <returns></returns>
  17690. [HttpPost]
  17691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17692. public async Task<IActionResult> UploadCus(IFormFile file)
  17693. {
  17694. try
  17695. {
  17696. if (file != null)
  17697. {
  17698. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17699. //文件名称
  17700. string projectFileName = file.FileName;
  17701. //上传的文件的路径
  17702. string filePath = "";
  17703. if (!Directory.Exists(fileDir))
  17704. {
  17705. Directory.CreateDirectory(fileDir);
  17706. }
  17707. //上传的文件的路径
  17708. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  17709. using (FileStream fs = System.IO.File.Create(filePath))
  17710. {
  17711. file.CopyTo(fs);
  17712. fs.Flush();
  17713. }
  17714. return Ok(JsonView(true, "上传成功!", projectFileName));
  17715. }
  17716. else
  17717. {
  17718. return Ok(JsonView(false, "上传失败!"));
  17719. }
  17720. }
  17721. catch (Exception ex)
  17722. {
  17723. return Ok(JsonView(false, "程序错误!"));
  17724. throw;
  17725. }
  17726. }
  17727. /// <summary>
  17728. /// 保险删除指定文件
  17729. /// </summary>
  17730. /// <param name="dto"></param>
  17731. /// <returns></returns>
  17732. [HttpPost]
  17733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17734. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  17735. {
  17736. try
  17737. {
  17738. string filePath = "";
  17739. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17740. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  17741. //int id = 0;
  17742. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  17743. // 删除该文件
  17744. try
  17745. {
  17746. System.IO.File.Delete(filePath);
  17747. 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()
  17748. {
  17749. Attachment = "",
  17750. }).ExecuteCommandAsync();
  17751. if (result != 0)
  17752. {
  17753. return Ok(JsonView(true, "成功!"));
  17754. }
  17755. else
  17756. {
  17757. return Ok(JsonView(false, "失败!"));
  17758. }
  17759. }
  17760. catch (Exception)
  17761. {
  17762. 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()
  17763. {
  17764. Attachment = "",
  17765. }).ExecuteCommandAsync();
  17766. if (result != 0)
  17767. {
  17768. return Ok(JsonView(true, "成功!"));
  17769. }
  17770. else
  17771. {
  17772. return Ok(JsonView(false, "失败!"));
  17773. }
  17774. }
  17775. }
  17776. catch (Exception ex)
  17777. {
  17778. return Ok(JsonView(false, "程序错误!"));
  17779. throw;
  17780. }
  17781. }
  17782. /// <summary>
  17783. /// 保险费用操作(删除)
  17784. /// </summary>
  17785. /// <param name="dto"></param>
  17786. /// <returns></returns>
  17787. [HttpPost]
  17788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17789. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  17790. {
  17791. try
  17792. {
  17793. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  17794. if (!res)
  17795. {
  17796. return Ok(JsonView(false, "删除失败"));
  17797. }
  17798. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  17799. {
  17800. IsDel = 1,
  17801. DeleteUserId = dto.DeleteUserId,
  17802. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  17803. }).ExecuteCommandAsync();
  17804. return Ok(JsonView(true, "删除成功!"));
  17805. }
  17806. catch (Exception ex)
  17807. {
  17808. return Ok(JsonView(false, "程序错误!"));
  17809. throw;
  17810. }
  17811. }
  17812. #endregion
  17813. #region 接团客户名单 PageId 104
  17814. /// <summary>
  17815. /// 接团客户名单
  17816. /// 迁移数据(慎用!)
  17817. /// </summary>
  17818. /// <returns></returns>
  17819. [HttpPost]
  17820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17821. public async Task<IActionResult> PostTourClientListChange()
  17822. {
  17823. try
  17824. {
  17825. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  17826. //var groupClinetData1
  17827. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  17828. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  17829. int updateCount = 0;
  17830. if (oldOAClientList.Count > 0)
  17831. {
  17832. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  17833. _sqlSugar.BeginTran();
  17834. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  17835. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  17836. foreach (var item in oldOAClientList)
  17837. {
  17838. int comId = 0;
  17839. string format = "yyyy-MM-dd HH:mm:ss";
  17840. string data11 = "1990-01-01 00:00";
  17841. var data1 = IsValidDate(item.OPdate, format);
  17842. if (data1) data11 = item.OPdate;
  17843. //客户公司验证
  17844. if (!string.IsNullOrEmpty(item.Company))
  17845. {
  17846. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  17847. if (clientComInfo == null) // add
  17848. {
  17849. var addInfo = new Crm_CustomerCompany()
  17850. {
  17851. CompanyAbbreviation = "",
  17852. CompanyFullName = item.Company,
  17853. Address = "",
  17854. PostCodes = "",
  17855. LastedOpUserId = item.OPer,
  17856. LastedOpDt = Convert.ToDateTime(data11),
  17857. CreateUserId = item.OPer,
  17858. CreateTime = Convert.ToDateTime(data11),
  17859. IsDel = 0
  17860. };
  17861. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  17862. if (comId1 > 0) comId = comId1;
  17863. }
  17864. else comId = clientComInfo.Id;
  17865. }
  17866. //客户人员验证
  17867. int clientId = 0;
  17868. string name = item.LastName + item.Name;
  17869. if (!string.IsNullOrEmpty(name))
  17870. {
  17871. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  17872. if (clientInfo == null)
  17873. {
  17874. DateTime? dateTime = null;
  17875. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  17876. if (isDt) dateTime = birthDayDt;
  17877. var addInfo1 = new Crm_DeleClient()
  17878. {
  17879. CrmCompanyId = comId,
  17880. DiId = -1,
  17881. LastName = item.LastName,
  17882. FirstName = item.Name,
  17883. OldName = "",
  17884. Pinyin = item.Pinyin,
  17885. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  17886. Marriage = 0,
  17887. Phone = item.Phone,
  17888. Job = item.Job,
  17889. BirthDay = dateTime
  17890. };
  17891. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  17892. if (clientId1 > 0) clientId = clientId1;
  17893. }
  17894. else clientId = clientInfo.Id;
  17895. }
  17896. if (clientId < 1)
  17897. {
  17898. continue;
  17899. }
  17900. int airType = 0;
  17901. if (item.AirType == "超经舱") airType = 459;
  17902. else if (item.AirType == "公务舱") airType = 458;
  17903. else if (item.AirType == "经济舱") airType = 460;
  17904. else if (item.AirType == "其他") airType = 565;
  17905. else if (item.AirType == "头等舱") airType = 457;
  17906. var _TourClientListEntity = new Grp_TourClientList()
  17907. {
  17908. DiId = item.Diid,
  17909. ClientId = clientId,
  17910. CreateUserId = item.OPer,
  17911. CreateTime = Convert.ToDateTime(data11),
  17912. Remark = item.Remark,
  17913. IsDel = item.Isdel,
  17914. ShippingSpaceTypeId = airType,
  17915. ShippingSpaceSpecialNeeds = item.AirRemark,
  17916. HotelSpecialNeeds = item.RoomType
  17917. };
  17918. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  17919. if (_TourClientList > 0)
  17920. {
  17921. updateCount++;
  17922. }
  17923. }
  17924. _sqlSugar.CommitTran();
  17925. }
  17926. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  17927. }
  17928. catch (Exception ex)
  17929. {
  17930. _sqlSugar.RollbackTran();
  17931. return Ok(JsonView(false, ex.Message));
  17932. }
  17933. //return Ok(JsonView(true));
  17934. }
  17935. private bool IsValidDate(string dateString, string format)
  17936. {
  17937. DateTime dateValue;
  17938. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  17939. return valid;
  17940. }
  17941. /// <summary>
  17942. /// 接团客户名单
  17943. /// 根据团组Id查询List
  17944. /// </summary>
  17945. /// <param name="_dto"></param>
  17946. /// <returns></returns>
  17947. [HttpPost]
  17948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17949. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17950. {
  17951. #region 参数验证
  17952. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17953. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17954. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17955. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17956. #region 页面操作权限验证
  17957. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17958. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17959. #endregion
  17960. #endregion
  17961. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17962. if (viewData.Code != 0)
  17963. {
  17964. return Ok(JsonView(false, viewData.Msg));
  17965. }
  17966. return Ok(JsonView(viewData.Data));
  17967. }
  17968. /// <summary>
  17969. /// 接团客户名单
  17970. /// 基础数据 Init
  17971. /// </summary>
  17972. /// <param name="_dto"></param>
  17973. /// <returns></returns>
  17974. [HttpPost]
  17975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17976. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17977. {
  17978. #region 参数验证
  17979. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17980. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17981. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17982. #region 页面操作权限验证
  17983. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17984. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17985. #endregion
  17986. #endregion
  17987. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  17988. }
  17989. /// <summary>
  17990. /// 接团客户名单
  17991. /// 根据 Id查询 Details
  17992. /// </summary>
  17993. /// <param name="_dto"></param>
  17994. /// <returns></returns>
  17995. [HttpPost]
  17996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17997. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  17998. {
  17999. #region 参数验证
  18000. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18001. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18002. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18003. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18004. #region 页面操作权限验证
  18005. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18006. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18007. #endregion
  18008. #endregion
  18009. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18010. if (viewData.Code != 0)
  18011. {
  18012. return Ok(JsonView(false, viewData.Msg));
  18013. }
  18014. return Ok(JsonView(viewData.Data));
  18015. }
  18016. /// <summary>
  18017. /// 接团客户名单
  18018. /// Add Or Edit
  18019. /// </summary>
  18020. /// <param name="_dto"></param>
  18021. /// <returns></returns>
  18022. [HttpPost]
  18023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18024. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18025. {
  18026. #region 参数验证
  18027. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18028. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18029. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18030. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18031. #region 页面操作权限验证
  18032. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18033. if (_dto.Id == 0) //添加
  18034. {
  18035. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18036. }
  18037. else if (_dto.Id >= 0) //修改
  18038. {
  18039. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18040. }
  18041. #endregion
  18042. #endregion
  18043. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18044. if (viewData.Code != 0)
  18045. {
  18046. return Ok(JsonView(false, viewData.Msg));
  18047. }
  18048. return Ok(JsonView(true));
  18049. }
  18050. /// <summary>
  18051. /// 接团客户名单
  18052. /// json字符串 AddMultiple(添加多个)
  18053. /// </summary>
  18054. /// <param name="_dto"></param>
  18055. /// <returns></returns>
  18056. [HttpPost]
  18057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18058. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18059. {
  18060. #region 参数验证
  18061. string jsonLabel = _dto.JsonLabel;
  18062. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18063. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18064. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18065. #region 页面操作权限验证
  18066. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18067. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18068. #endregion
  18069. #endregion
  18070. var request = new TourClientListAddMultipleDto();
  18071. request.DiId = _dto.DiId;
  18072. request.UserId = _dto.UserId;
  18073. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18074. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18075. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18076. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18077. var infos = new List<TourClientListInfo>();
  18078. foreach (var data in datas)
  18079. {
  18080. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18081. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18082. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18083. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18084. {
  18085. continue;
  18086. }
  18087. infos.Add(new TourClientListInfo()
  18088. {
  18089. IsAccompany = 1,
  18090. LastName = lastName,
  18091. FirstName = firstName,
  18092. Pinyin = lastNameEn + @"/" + firstNameEn,
  18093. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18094. CompanyFullName = data.CompanyFullName,
  18095. Job = data.Job
  18096. });
  18097. }
  18098. if (infos.Any())
  18099. {
  18100. var viewData = await _tourClientListRep._AddMultiple(request);
  18101. if (viewData.Code != 0)
  18102. {
  18103. return Ok(JsonView(false, viewData.Msg));
  18104. }
  18105. return Ok(JsonView(true));
  18106. }
  18107. return Ok(JsonView(false));
  18108. }
  18109. /// <summary>
  18110. /// 接团客户名单
  18111. /// AddMultiple(添加多个)
  18112. /// </summary>
  18113. /// <param name="_dto"></param>
  18114. /// <returns></returns>
  18115. [HttpPost]
  18116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18117. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18118. {
  18119. #region 参数验证
  18120. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18121. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18123. #region 页面操作权限验证
  18124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18125. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18126. #endregion
  18127. #endregion
  18128. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18129. if (viewData.Code != 0)
  18130. {
  18131. return Ok(JsonView(false, viewData.Msg));
  18132. }
  18133. return Ok(JsonView(true));
  18134. }
  18135. /// <summary>
  18136. /// 接团客户名单
  18137. /// Del
  18138. /// </summary>
  18139. /// <param name="_dto"></param>
  18140. /// <returns></returns>
  18141. [HttpPost]
  18142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18143. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18144. {
  18145. #region 参数验证
  18146. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18147. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18148. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18149. #region 页面操作权限验证
  18150. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18151. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18152. #endregion
  18153. #endregion
  18154. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  18155. if (viewData.Code != 0)
  18156. {
  18157. return Ok(JsonView(false, viewData.Msg));
  18158. }
  18159. return Ok(JsonView(true));
  18160. }
  18161. /// <summary>
  18162. /// 接团客户名单
  18163. /// 文件下载 客户名单
  18164. /// </summary>
  18165. /// <param name="_dto"></param>
  18166. /// <returns></returns>
  18167. [HttpPost]
  18168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18169. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  18170. {
  18171. #region 参数验证
  18172. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18173. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18174. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  18175. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18176. #region 页面操作权限验证
  18177. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18178. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18179. #endregion
  18180. #endregion
  18181. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  18182. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  18183. From Grp_TourClientList tcl
  18184. Left Join
  18185. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  18186. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  18187. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  18188. From Crm_DeleClient dc
  18189. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  18190. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  18191. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  18192. Where dc.IsDel = 0) temp
  18193. On temp.DcId =tcl.ClientId
  18194. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  18195. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  18196. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  18197. //载入模板
  18198. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  18199. if (_dto.Language == 1)
  18200. {
  18201. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  18202. }
  18203. //载入模板
  18204. var doc = new Document(tempPath);
  18205. DocumentBuilder builder = new DocumentBuilder(doc);
  18206. //获取word里所有表格
  18207. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18208. //获取所填表格的序数
  18209. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18210. var rowStart = tableOne.Rows[0]; //获取第1行
  18211. if (_dto.Language == 0)
  18212. {
  18213. //循环赋值
  18214. for (int i = 0; i < DcList.Count; i++)
  18215. {
  18216. EncryptionProcessor.DecryptProperties(DcList[i]);
  18217. builder.MoveToCell(0, i + 1, 0, 0);
  18218. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  18219. builder.MoveToCell(0, i + 1, 1, 0);
  18220. int sex = DcList[i].Sex;
  18221. string sexStr = string.Empty;
  18222. if (sex == 0) sexStr = "男";
  18223. else if (sex == 1) sexStr = "女";
  18224. else sexStr = "未设置";
  18225. builder.Write(sexStr);
  18226. builder.MoveToCell(0, i + 1, 2, 0);
  18227. string birthDay = DcList[i].BirthDay;
  18228. string birthDayStr = string.Empty;
  18229. if (!string.IsNullOrEmpty(birthDay))
  18230. {
  18231. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  18232. }
  18233. builder.Write(birthDayStr);
  18234. builder.MoveToCell(0, i + 1, 3, 0);
  18235. string company = "";
  18236. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18237. {
  18238. company = DcList[i].CompanyFullName.ToString();
  18239. }
  18240. builder.Write(company);
  18241. builder.MoveToCell(0, i + 1, 4, 0);
  18242. builder.Write(DcList[i].Job);
  18243. }
  18244. }
  18245. else if (_dto.Language == 1)
  18246. {
  18247. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  18248. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  18249. List<string> transArrayStr = new List<string>();
  18250. string transStrRes1 = "";
  18251. for (int i = 0; i < DcList.Count; i++)
  18252. {
  18253. var dc = DcList[i];
  18254. EncryptionProcessor.DecryptProperties(dc);
  18255. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  18256. if (dc.Job.Equals("暂无")) dc.Job = "-";
  18257. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  18258. if (DcList.Count - 1 == i) transStrRes1 += str1;
  18259. else transStrRes1 += $"{str1}|";
  18260. }
  18261. //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";
  18262. string transStrRes = "";
  18263. if (transStrRes1.Length > 0)
  18264. {
  18265. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  18266. }
  18267. //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
  18268. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  18269. //List<string> transArray = new List<string> { };
  18270. List<TranslateInfo> transArray = new List<TranslateInfo>();
  18271. if (transStrRes.Contains("|"))
  18272. {
  18273. string[] transArray1 = transStrRes.Split('|');
  18274. if (transArray1.Length > 0)
  18275. {
  18276. foreach (var item in transArray1)
  18277. {
  18278. if (item.Contains("&"))
  18279. {
  18280. string[] transArray2 = item.Split('&');
  18281. int index = 0;
  18282. string companyName = "", job = "";
  18283. if (transArray2.Length > 0)
  18284. {
  18285. bool success = int.TryParse(transArray2[0].Trim(), out index);
  18286. if (1 < transArray2.Length) companyName = transArray2[1];
  18287. if (2 < transArray2.Length) job = transArray2[2];
  18288. }
  18289. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  18290. }
  18291. }
  18292. }
  18293. }
  18294. //循环赋值
  18295. for (int i = 0; i < DcList.Count; i++)
  18296. {
  18297. string PYName = "";
  18298. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  18299. {
  18300. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  18301. string PY_First = DcList[i].Pinyin.Split('/')[1];
  18302. PYName = PY_First + " " + PY_Last;
  18303. }
  18304. else
  18305. {
  18306. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  18307. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  18308. PYName = PY_First + " " + PY_Last;
  18309. }
  18310. builder.MoveToCell(0, i + 1, 0, 0);
  18311. builder.Write(PYName);
  18312. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  18313. builder.MoveToCell(0, i + 1, 1, 0);
  18314. builder.Write(sex);
  18315. DateTime birthDt;
  18316. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  18317. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  18318. builder.MoveToCell(0, i + 1, 2, 0);
  18319. builder.Write(birthday);
  18320. string company = string.Empty, job = string.Empty;
  18321. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  18322. if (dcTransInfo != null)
  18323. {
  18324. company = dcTransInfo.CompanyName;
  18325. job = dcTransInfo.Job;
  18326. }
  18327. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18328. {
  18329. //查询对照表
  18330. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  18331. if (tempCec != null)
  18332. {
  18333. company = tempCec.enName;
  18334. }
  18335. //翻译
  18336. else
  18337. {
  18338. }
  18339. }
  18340. builder.MoveToCell(0, i + 1, 3, 0);
  18341. builder.Write(company);
  18342. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  18343. {
  18344. //查询对照表
  18345. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  18346. if (tempPec != null)
  18347. {
  18348. job = tempPec.enName;
  18349. }
  18350. //翻译
  18351. else
  18352. {
  18353. }
  18354. }
  18355. builder.MoveToCell(0, i + 1, 4, 0);
  18356. builder.Write(job);
  18357. }
  18358. }
  18359. //删除多余行
  18360. while (tableOne.Rows.Count > DcList.Count + 1)
  18361. {
  18362. tableOne.Rows.RemoveAt(DcList.Count + 1);
  18363. }
  18364. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  18365. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  18366. doc.Save(fileDir);
  18367. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  18368. return Ok(JsonView(true, "操作成功!", Url));
  18369. }
  18370. private class TranslateInfo
  18371. {
  18372. public int Index { get; set; }
  18373. public string CompanyName { get; set; }
  18374. public string Job { get; set; }
  18375. }
  18376. #endregion
  18377. #region 团组倒推表
  18378. /// <summary>
  18379. /// 倒推表基础数据
  18380. /// Init
  18381. /// </summary>
  18382. /// <returns></returns>
  18383. [HttpPost]
  18384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18385. public async Task<IActionResult> PostInvertedListInit()
  18386. {
  18387. var viewData = await _invertedListRep._Init();
  18388. if (viewData.Code != 0)
  18389. {
  18390. return Ok(JsonView(false, viewData.Msg));
  18391. }
  18392. return Ok(JsonView(viewData.Data));
  18393. }
  18394. /// <summary>
  18395. /// 倒推表
  18396. /// Info
  18397. /// </summary>
  18398. /// <param name="dto"></param>
  18399. /// <returns></returns>
  18400. [HttpPost]
  18401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18402. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  18403. {
  18404. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  18405. if (viewData.Code != 0)
  18406. {
  18407. return Ok(JsonView(false, viewData.Msg));
  18408. }
  18409. return Ok(JsonView(viewData.Data));
  18410. }
  18411. /// <summary>
  18412. /// 倒推表
  18413. /// Create
  18414. /// </summary>
  18415. /// <param name="dto"></param>
  18416. /// <returns></returns>
  18417. [HttpPost]
  18418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18419. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  18420. {
  18421. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  18422. if (viewData.Code != 0)
  18423. {
  18424. return Ok(JsonView(false, viewData.Msg));
  18425. }
  18426. return Ok(JsonView(viewData.Data));
  18427. }
  18428. /// <summary>
  18429. /// 倒推表
  18430. /// Update
  18431. /// </summary>
  18432. /// <param name="dto"></param>
  18433. /// <returns></returns>
  18434. [HttpPost]
  18435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18436. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  18437. {
  18438. var viewData = await _invertedListRep._Update(dto);
  18439. if (viewData.Code != 0)
  18440. {
  18441. return Ok(JsonView(false, viewData.Msg));
  18442. }
  18443. return Ok(JsonView(viewData.Data));
  18444. }
  18445. /// <summary>
  18446. /// 倒推表
  18447. /// File Download
  18448. /// </summary>
  18449. /// <param name="dto"></param>
  18450. /// <returns></returns>
  18451. [HttpPost]
  18452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18453. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  18454. {
  18455. var info2 = await _invertedListRep._Info(1, dto.DiId);
  18456. if (info2.Code != 0)
  18457. {
  18458. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  18459. }
  18460. var info1 = info2.Data as InvertedListInfoView;
  18461. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  18462. string teamName = "";
  18463. if (info != null) teamName = info.TeamName;
  18464. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  18465. var doc = new Document();
  18466. var builder = new DocumentBuilder(doc);
  18467. #region old insert
  18468. ////载入模板
  18469. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  18470. //Document doc = new Document(tempPath);
  18471. //DocumentBuilder builder = new DocumentBuilder(doc);
  18472. //利用键值对存放数据
  18473. //Dictionary<string, string> dic = new Dictionary<string, string>();
  18474. //dic.Add("TeamName", teamName);
  18475. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  18476. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  18477. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  18478. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  18479. //dic.Add("SQRemark", info1.ApprovalRemark);
  18480. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  18481. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  18482. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  18483. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  18484. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  18485. //dic.Add("QZRemark", info1.VisaInformationRemark);
  18486. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  18487. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  18488. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  18489. //dic.Add("CQRemark", info1.IssueVisaRemark);
  18490. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  18491. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  18492. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  18493. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  18494. //#region 填充word模板书签内容
  18495. //foreach (var key in dic.Keys)
  18496. //{
  18497. // builder.MoveToBookmark(key);
  18498. // builder.Write(dic[key]);
  18499. //}
  18500. //#endregion
  18501. #endregion
  18502. #region New Insert
  18503. string titleFont = $"仿宋",
  18504. contentFont = $"仿宋";
  18505. var fontColor = Color.FromArgb(64, 64, 64);
  18506. //设置标题 团组名称
  18507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18508. builder.Font.Name = titleFont;
  18509. builder.Font.Color = fontColor;
  18510. builder.Font.Size = 12;
  18511. builder.Font.Bold = true;
  18512. builder.Writeln(teamName);
  18513. //设置副标题 团组出访时间
  18514. builder.Font.Size = 12;
  18515. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  18516. builder.Writeln();
  18517. var backgroundColor = Color.FromArgb(199, 199, 199);
  18518. var table = builder.StartTable();
  18519. builder.InsertCell();
  18520. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  18521. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  18522. builder.CellFormat.Borders.LineWidth = 1;
  18523. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  18524. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  18525. builder.RowFormat.Height = 40;
  18526. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18527. builder.Font.Name = contentFont;
  18528. builder.Font.Size = 12;
  18529. builder.Font.Bold = true;
  18530. builder.Font.Color = fontColor;
  18531. builder.Write("时间");
  18532. builder.InsertCell();
  18533. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  18534. builder.Write("流程");
  18535. builder.InsertCell();
  18536. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  18537. builder.Write("说明");
  18538. builder.EndRow();
  18539. //报批资料准备
  18540. if (info1.IsSelectedAirportd)
  18541. {
  18542. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  18543. }
  18544. //报批/提供送签资料
  18545. if (info1.IsSelectedApprovalData)
  18546. {
  18547. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  18548. }
  18549. //出批件护照办理
  18550. if (info1.IsSelectedIssueApproval)
  18551. {
  18552. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  18553. }
  18554. //签证资料准备
  18555. if (info1.IsSelectedVisaInfo)
  18556. {
  18557. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  18558. }
  18559. //送签
  18560. if (info1.IsSelectedSendVisa)
  18561. {
  18562. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  18563. }
  18564. //出签
  18565. if (info1.IsSelectedIssueVisa)
  18566. {
  18567. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  18568. }
  18569. //机票
  18570. if (info1.IsSelectedAirTicket)
  18571. {
  18572. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  18573. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  18574. }
  18575. //酒店
  18576. if (info1.IsSelectedHotel)
  18577. {
  18578. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  18579. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  18580. }
  18581. //开行前会
  18582. if (info1.IsSelectedPreTripMeeting)
  18583. {
  18584. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  18585. }
  18586. //送机
  18587. if (info1.IsSelectedAirportdDropOff)
  18588. {
  18589. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  18590. }
  18591. builder.EndTable();
  18592. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  18593. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  18594. for (int i = 0; i < table.Rows.Count; i++)
  18595. {
  18596. var row = table.Rows[i];
  18597. //设置宽度
  18598. row.Cells[0].CellFormat.Width = 20.00;
  18599. row.Cells[1].CellFormat.Width = 30.00;
  18600. row.Cells[2].CellFormat.Width = 50.00;
  18601. if (i != 0)
  18602. {
  18603. //边框设置
  18604. InvertedListFileDownloadSetBorders(row.Cells, 0);
  18605. InvertedListFileDownloadSetBorders(row.Cells, 1);
  18606. InvertedListFileDownloadSetBorders(row.Cells, 2);
  18607. }
  18608. }
  18609. #region 页脚插入图片
  18610. // 创建页脚
  18611. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  18612. doc.FirstSection.HeadersFooters.Add(footer);
  18613. Paragraph para = new Paragraph(doc);
  18614. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  18615. footer.AppendChild(para);
  18616. builder.MoveTo(para);
  18617. string imagePath = "./Images/FMGJ_Log.png";
  18618. builder.InsertImage(imagePath);
  18619. #endregion
  18620. #endregion
  18621. var fileDir = AppSettingsHelper.Get("WordBasePath");
  18622. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  18623. string filePath = fileDir + $@"InvertedList/{fileName}";
  18624. doc.Save(filePath);
  18625. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  18626. return Ok(JsonView(true, "操作成功!", Url));
  18627. }
  18628. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  18629. {
  18630. var fontColor = Color.FromArgb(64, 64, 64);
  18631. builder.InsertCell();
  18632. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  18633. builder.RowFormat.Height = 40;
  18634. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18635. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18636. builder.Font.Name = fontName;
  18637. builder.Font.Size = 8;
  18638. builder.Font.Bold = true;
  18639. builder.Font.Color = fontColor;
  18640. builder.Write(dateTime);
  18641. builder.InsertCell();
  18642. builder.Font.Size = 9;
  18643. builder.Font.Bold = true;
  18644. builder.Font.Color = fontColor;
  18645. builder.Write(content);
  18646. builder.InsertCell();
  18647. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18648. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18649. builder.Font.Size = 9;
  18650. builder.Font.Bold = false;
  18651. builder.Font.Color = fontColor;
  18652. builder.Write(reamrk);
  18653. builder.EndRow();
  18654. }
  18655. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  18656. {
  18657. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  18658. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  18659. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  18660. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  18661. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  18662. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  18663. }
  18664. #endregion
  18665. #region 会务倒推表
  18666. /// <summary>
  18667. /// 会务倒推表
  18668. /// Init
  18669. /// </summary>
  18670. /// <returns></returns>
  18671. [HttpPost]
  18672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18673. public async Task<IActionResult> InforRetrogressTableInit()
  18674. {
  18675. var groupData = await _groupRepository.PostShareGroupInfos(1);
  18676. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  18677. return Ok(JsonView(false, groupData.Msg));
  18678. }
  18679. /// <summary>
  18680. /// 会务倒推表
  18681. /// ExcelDownload
  18682. /// </summary>
  18683. /// <param name="dto"></param>
  18684. /// <returns></returns>
  18685. [HttpPost]
  18686. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  18687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18688. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  18689. {
  18690. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  18691. var validatorRes = await validator.ValidateAsync(dto);
  18692. if (!validatorRes.IsValid)
  18693. {
  18694. StringBuilder sb = new StringBuilder();
  18695. foreach (var item in validatorRes.Errors)
  18696. {
  18697. sb.AppendLine(item.ErrorMessage);
  18698. }
  18699. return Ok(JsonView(false, sb.ToString()));
  18700. }
  18701. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  18702. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  18703. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  18704. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  18705. #region Excel
  18706. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  18707. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  18708. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  18709. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  18710. var fileNamePrefix = string.Empty;
  18711. if (days >= 30)
  18712. {
  18713. tempPath += $"会务工作倒推进度表(30天).xlsx";
  18714. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  18715. }
  18716. else if (days < 30 && days > 7)
  18717. {
  18718. tempPath += $"会务工作倒推进度表(15天).xlsx";
  18719. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  18720. }
  18721. else if (days <= 7)
  18722. {
  18723. tempPath += $"会务工作倒推进度表(7天).xlsx";
  18724. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  18725. }
  18726. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  18727. fileName = CommonFun.ValidFileName(fileName);
  18728. //载入模板
  18729. WorkbookDesigner designer = new WorkbookDesigner();
  18730. designer.Workbook = new Workbook(tempPath);
  18731. designer.Process();
  18732. if (!Directory.Exists(savePath))
  18733. {
  18734. Directory.CreateDirectory(savePath);
  18735. }
  18736. string serverPath = $"{savePath}{fileName}";
  18737. designer.Workbook.Save(serverPath);
  18738. string rst = $"{servicePath}{ftpPath}{fileName}";
  18739. #endregion
  18740. return Ok(JsonView(new { url = rst }));
  18741. }
  18742. #endregion
  18743. #region 三公签证费用(签证费、代办费)
  18744. /// <summary>
  18745. /// 三公签证费用(签证费、代办费)
  18746. /// List
  18747. /// </summary>
  18748. /// <returns></returns>
  18749. [HttpPost]
  18750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18751. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  18752. {
  18753. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  18754. if (_view.Code != 0)
  18755. {
  18756. return Ok(JsonView(false, _view.Msg));
  18757. }
  18758. return Ok(JsonView(true, "操作成功!", _view.Data));
  18759. }
  18760. /// <summary>
  18761. /// 三公签证费用(签证费、代办费)
  18762. /// Add Or Update
  18763. /// </summary>
  18764. /// <returns></returns>
  18765. [HttpPost]
  18766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18767. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  18768. {
  18769. var _view = await _visaFeeInfoRep._Update(_dto);
  18770. if (_view.Code != 0)
  18771. {
  18772. return Ok(JsonView(false, _view.Msg));
  18773. }
  18774. return Ok(JsonView(true, _view.Msg));
  18775. }
  18776. #endregion
  18777. #region 酒店询价
  18778. /// <summary>
  18779. /// 酒店询价
  18780. /// Init
  18781. /// </summary>
  18782. /// <returns></returns>
  18783. [HttpPost]
  18784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18785. public async Task<IActionResult> PostHotelInquiryInit()
  18786. {
  18787. var res = await _hotelInquiryRep._Init();
  18788. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18789. return Ok(JsonView(true, res.Msg, res.Data));
  18790. }
  18791. /// <summary>
  18792. /// 酒店询价
  18793. /// page Item
  18794. /// </summary>
  18795. /// <param name="_dto"></param>
  18796. /// <returns></returns>
  18797. [HttpPost]
  18798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18799. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  18800. {
  18801. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  18802. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18803. var view = res.Data as PageDataViewBase;
  18804. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  18805. }
  18806. /// <summary>
  18807. /// 酒店询价
  18808. /// info
  18809. /// </summary>
  18810. /// <param name="_dto"></param>
  18811. /// <returns></returns>
  18812. [HttpPost]
  18813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18814. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  18815. {
  18816. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  18817. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18818. return Ok(JsonView(true, res.Msg, res.Data));
  18819. }
  18820. /// <summary>
  18821. /// 酒店询价
  18822. /// Add Or Edit
  18823. /// </summary>
  18824. /// <param name="_dto"></param>
  18825. /// <returns></returns>
  18826. [HttpPost]
  18827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18828. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  18829. {
  18830. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  18831. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18832. return Ok(JsonView(true, res.Msg, res.Data));
  18833. }
  18834. /// <summary>
  18835. /// 酒店询价
  18836. /// Del
  18837. /// </summary>
  18838. /// <param name="_dto"></param>
  18839. /// <returns></returns>
  18840. [HttpPost]
  18841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18842. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  18843. {
  18844. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  18845. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18846. return Ok(JsonView(true, res.Msg, res.Data));
  18847. }
  18848. #endregion
  18849. #region 下载匹配op行程单
  18850. /// <summary>
  18851. /// 匹配op行程单
  18852. /// Init
  18853. /// </summary>
  18854. /// <param name="dto">团组列表请求dto</param>
  18855. /// <returns></returns>
  18856. [HttpPost]
  18857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18858. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  18859. {
  18860. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18861. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18862. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  18863. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  18864. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  18865. .Where(it => it.IsDel == 0)
  18866. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  18867. .OrderByDescending(it => it.VisitStartDate)
  18868. .ToList();
  18869. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  18870. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18871. var diids = groupInfos.Select(it => it.Id).ToList();
  18872. List<string> countrys = new List<string>();
  18873. foreach (var item in country)
  18874. {
  18875. var data = _groupRepository.FormartTeamName(item);
  18876. var dataArray = _groupRepository.GroupSplitCountry(data);
  18877. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18878. }
  18879. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  18880. List<string> areaArray = new List<string>(); //GetGroupCityLine
  18881. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  18882. foreach (var item in areaItem)
  18883. {
  18884. string areaStr = item.Value;
  18885. if (!string.IsNullOrEmpty(areaStr))
  18886. {
  18887. string[] str1 = areaStr.Split("-");
  18888. if (str1.Length > 0)
  18889. {
  18890. areaArray.AddRange(str1);
  18891. }
  18892. }
  18893. }
  18894. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  18895. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  18896. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  18897. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  18898. .ToList();
  18899. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  18900. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  18901. .Where(it => countriesIds.Contains(it.Id))
  18902. .Select(it => new { it.Id, Name = it.Name_CN })
  18903. .ToList();
  18904. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  18905. .Select(it => it.TeamName).ToList();
  18906. stopwatch.Stop();
  18907. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  18908. }
  18909. ///// <summary>
  18910. ///// 匹配op行程单
  18911. ///// Init 查询区域数据
  18912. ///// </summary>
  18913. ///// <param name="dto">团组列表请求dto</param>
  18914. ///// <returns></returns>
  18915. //[HttpPost]
  18916. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18917. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  18918. //{
  18919. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18920. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  18921. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  18922. // if (string.IsNullOrEmpty(countriesDataStr))
  18923. // {
  18924. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  18925. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  18926. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  18927. // }
  18928. // else
  18929. // {
  18930. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  18931. // }
  18932. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  18933. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  18934. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  18935. // List<dynamic> childList = new List<dynamic>();
  18936. // int parentId = dto.CountriesId;
  18937. // if (provinceData.Count > 1)
  18938. // {
  18939. // foreach (var item1 in provinceData)
  18940. // {
  18941. // List<dynamic> childList1 = new List<dynamic>();
  18942. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  18943. // foreach (var item2 in citiesData1)
  18944. // {
  18945. // List<dynamic> childList2 = new List<dynamic>();
  18946. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18947. // foreach (var item3 in countiesData1)
  18948. // {
  18949. // childList2.Add(new
  18950. // {
  18951. // id = item3.Id,
  18952. // parentId = item2.Id,
  18953. // level = "district",
  18954. // name = item3.Name_CN,
  18955. // });
  18956. // }
  18957. // childList1.Add(new
  18958. // {
  18959. // id = item2.Id,
  18960. // parentId = item1.Id,
  18961. // level = "city",
  18962. // name = item2.Name_CN,
  18963. // childList = childList2
  18964. // });
  18965. // }
  18966. // childList.Add(new
  18967. // {
  18968. // id = item1.Id,
  18969. // parentId = parentId,
  18970. // level = "province",
  18971. // name = item1.Name_CN,
  18972. // childList = childList1
  18973. // });
  18974. // }
  18975. // //城市
  18976. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18977. // foreach (var item2 in citiesData2)
  18978. // {
  18979. // List<dynamic> childList22 = new List<dynamic>();
  18980. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18981. // foreach (var item3 in countiesData1)
  18982. // {
  18983. // childList22.Add(new
  18984. // {
  18985. // id = item3.Id,
  18986. // parentId = item2.Id,
  18987. // level = "district",
  18988. // name = item3.Name_CN,
  18989. // });
  18990. // }
  18991. // childList.Add(new
  18992. // {
  18993. // id = item2.Id,
  18994. // parentId = parentId,
  18995. // level = "city",
  18996. // name = item2.Name_CN,
  18997. // childList = childList22
  18998. // });
  18999. // }
  19000. // }
  19001. // else
  19002. // {
  19003. // foreach (var item2 in citiesData)
  19004. // {
  19005. // string cname = item2.Name_CN;
  19006. // List<dynamic> childList1 = new List<dynamic>();
  19007. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19008. // foreach (var item3 in countiesData1)
  19009. // {
  19010. // childList1.Add(new
  19011. // {
  19012. // Id = item3.Id,
  19013. // parentId = item2.Id,
  19014. // level = "district",
  19015. // name = item3.Name_CN
  19016. // });
  19017. // }
  19018. // childList.Add(new
  19019. // {
  19020. // id = item2.Id,
  19021. // parentId = parentId,
  19022. // level = "city",
  19023. // name = item2.Name_CN,
  19024. // childList = childList1
  19025. // });
  19026. // }
  19027. // }
  19028. // stopwatch.Stop();
  19029. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  19030. //}
  19031. /// <summary>
  19032. /// 匹配op行程单
  19033. /// 接团信息列表 Page
  19034. /// </summary>
  19035. /// <param name="dto">团组列表请求dto</param>
  19036. /// <returns></returns>
  19037. [HttpPost]
  19038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19039. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  19040. {
  19041. var swatch = new Stopwatch();
  19042. swatch.Start();
  19043. #region 参数验证
  19044. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19045. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19046. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19047. #region 页面操作权限验证
  19048. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19049. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  19050. #endregion
  19051. #endregion
  19052. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19053. {
  19054. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  19055. //string sqlWhere = "";
  19056. if (!string.IsNullOrEmpty(dto.Country))
  19057. {
  19058. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  19059. }
  19060. if (!string.IsNullOrEmpty(dto.Area))
  19061. {
  19062. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  19063. }
  19064. if (!string.IsNullOrEmpty(dto.TeamName))
  19065. {
  19066. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  19067. }
  19068. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  19069. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  19070. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  19071. swatch.Stop();
  19072. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  19073. }
  19074. else
  19075. {
  19076. return Ok(JsonView(false, "查询失败"));
  19077. }
  19078. }
  19079. /// <summary>
  19080. /// 匹配op行程单
  19081. /// 行程单下载
  19082. /// </summary>
  19083. /// <param name="dto">团组列表请求dto</param>
  19084. /// <returns></returns>
  19085. [HttpPost]
  19086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19087. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  19088. {
  19089. #region 参数验证
  19090. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19091. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19092. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19093. #region 页面操作权限验证
  19094. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19095. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  19096. #endregion
  19097. #endregion
  19098. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19099. {
  19100. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  19101. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  19102. }
  19103. else
  19104. {
  19105. return Ok(JsonView(false, "下载失败!"));
  19106. }
  19107. }
  19108. #endregion
  19109. #region 国家信息 数据 注释
  19110. //[HttpPost]
  19111. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  19112. //{
  19113. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  19114. // foreach (var item in dto)
  19115. // {
  19116. // infos.Add(new Grp_GroupsTaskAssignment()
  19117. // {
  19118. // DIId = item,
  19119. // CTId = 82,
  19120. // UId = 248,
  19121. // IsEnable = 1,
  19122. // CreateUserId = 233,
  19123. // CreateTime = DateTime.Now,
  19124. // IsDel = 0
  19125. // });
  19126. // infos.Add(new Grp_GroupsTaskAssignment()
  19127. // {
  19128. // DIId = item,
  19129. // CTId = 82,
  19130. // UId = 286,
  19131. // IsEnable = 1,
  19132. // CreateUserId = 233,
  19133. // CreateTime = DateTime.Now,
  19134. // IsDel = 0
  19135. // });
  19136. // }
  19137. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  19138. // return Ok("操作成功");
  19139. //}
  19140. //public class paramJsonDto
  19141. //{
  19142. // public List<CountriesInfo> str { get; set; }
  19143. //}
  19144. //[HttpPost]
  19145. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  19146. //{
  19147. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  19148. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  19149. // List<Sys_Cities> cities = new List<Sys_Cities>();
  19150. // List<Sys_Cities> districts = new List<Sys_Cities>();
  19151. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19152. // _sqlSugar.BeginTran();
  19153. // int countitiesIndex = 0;
  19154. // foreach (var item in dto.str)
  19155. // {
  19156. // dynamic data = item.c;
  19157. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  19158. // if (data != null)
  19159. // {
  19160. // countitiesIndex++;
  19161. // foreach (var item1 in data)
  19162. // {
  19163. // string cnname = item1.cn;
  19164. // string enname = item1.en;
  19165. // Sys_Cities provinceInfo = new Sys_Cities()
  19166. // {
  19167. // CountriesId = countriesId,
  19168. // Name_CN = cnname,
  19169. // Name_EN = enname,
  19170. // ParentId = 0,
  19171. // IsCapital = 1,
  19172. // CreateUserId = 208,
  19173. // CreateTime = DateTime.Now,
  19174. // IsDel = 0
  19175. // };
  19176. // if (item1.lv == "province") //省份
  19177. // {
  19178. // provinceInfo.Level = 1;
  19179. // int provinceId = 0;
  19180. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  19181. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  19182. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19183. // var data1 = item1.c;
  19184. // foreach (var item2 in data1)
  19185. // {
  19186. // if (item2.lv == "city")
  19187. // {
  19188. // string citycnname = item2.cn;
  19189. // string cityenname = item2.en;
  19190. // Sys_Cities cityInfo = new Sys_Cities()
  19191. // {
  19192. // CountriesId = countriesId,
  19193. // ParentId = provinceId,
  19194. // Level = 2,
  19195. // Name_CN = citycnname,
  19196. // Name_EN = cityenname,
  19197. // IsCapital = 1,
  19198. // CreateUserId = 208,
  19199. // CreateTime = DateTime.Now,
  19200. // IsDel = 0
  19201. // };
  19202. // if (item2.c != null)
  19203. // {
  19204. // int cityId = 0;
  19205. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  19206. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19207. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  19208. // foreach (var item3 in item2.c)
  19209. // {
  19210. // if (item3.lv == "district")
  19211. // {
  19212. // var districtInfo = new Sys_Cities()
  19213. // {
  19214. // CountriesId = countriesId,
  19215. // Name_CN = item3.cn,
  19216. // Name_EN = item3.en,
  19217. // Level = 3,
  19218. // ParentId = cityId,
  19219. // IsCapital = 1,
  19220. // CreateUserId = 208,
  19221. // CreateTime = DateTime.Now,
  19222. // IsDel = 0
  19223. // };
  19224. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19225. // //{
  19226. // districts.Add(districtInfo);
  19227. // //}
  19228. // }
  19229. // }
  19230. // }
  19231. // else
  19232. // {
  19233. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  19234. // //{
  19235. // cities.Add(cityInfo);
  19236. // //}
  19237. // }
  19238. // }
  19239. // }
  19240. // }
  19241. // else if (item1.lv == "city")//城市
  19242. // {
  19243. // provinceInfo.Level = 2;
  19244. // if (item1.c != null)
  19245. // {
  19246. // int cityId = 0;
  19247. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  19248. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19249. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19250. // foreach (var item3 in item1.c)
  19251. // {
  19252. // if (item3.lv == "district")
  19253. // {
  19254. // var districtInfo = new Sys_Cities()
  19255. // {
  19256. // CountriesId = countriesId,
  19257. // Name_CN = item3.cn,
  19258. // Name_EN = item3.en,
  19259. // Level = 3,
  19260. // ParentId = cityId,
  19261. // IsCapital = 1,
  19262. // CreateUserId = 208,
  19263. // CreateTime = DateTime.Now,
  19264. // IsDel = 0
  19265. // };
  19266. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19267. // //{
  19268. // districts.Add(districtInfo);
  19269. // //}
  19270. // }
  19271. // }
  19272. // }
  19273. // else
  19274. // {
  19275. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  19276. // //{
  19277. // cities.Add(provinceInfo);
  19278. // //}
  19279. // }
  19280. // }
  19281. // }
  19282. // }
  19283. // }
  19284. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  19285. // cities = cities.Distinct().ToList();
  19286. // districts = districts.Distinct().ToList();
  19287. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  19288. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  19289. // cities.AddRange(districts);
  19290. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  19291. // //_sqlSugar.RollbackTran();
  19292. // _sqlSugar.CommitTran();
  19293. // return Ok(JsonView(false, "操作成功!"));
  19294. //}
  19295. //[HttpPost]
  19296. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  19297. //{
  19298. // List<CountitiesInfo> infos = dto.MyProperty;
  19299. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  19300. // _sqlSugar.BeginTran();
  19301. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19302. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  19303. // foreach (var item in infos)
  19304. // {
  19305. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  19306. // if (countryInfo != null)
  19307. // {
  19308. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  19309. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  19310. // if (cityInfo1 != null)
  19311. // {
  19312. // cityInfo1.IsCapital = 0;
  19313. // cityInfos.Add(cityInfo1);
  19314. // }
  19315. // }
  19316. // }
  19317. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  19318. // .UpdateColumns(it => it.IsCapital)
  19319. // .WhereColumns(it => it.Id)
  19320. // .ExecuteCommand();
  19321. // //_sqlSugar.RollbackTran();
  19322. // _sqlSugar.CommitTran();
  19323. // return Ok(JsonView(false, "操作成功!"));
  19324. //}
  19325. //public class CounrtiesDto
  19326. //{
  19327. // public List<CountitiesInfo> MyProperty { get; set; }
  19328. //}
  19329. //public class CountitiesInfo
  19330. //{
  19331. // /// <summary>
  19332. // /// 圣约翰
  19333. // /// </summary>
  19334. // public string capital_name_chinese { get; set; }
  19335. // /// <summary>
  19336. // ///
  19337. // /// </summary>
  19338. // public string capital_name { get; set; }
  19339. // /// <summary>
  19340. // ///
  19341. // /// </summary>
  19342. // public string country_type { get; set; }
  19343. // /// <summary>
  19344. // /// 安提瓜和巴布达
  19345. // /// </summary>
  19346. // public string country_name_chinese { get; set; }
  19347. // /// <summary>
  19348. // /// 安提瓜和巴布达
  19349. // /// </summary>
  19350. // public string country_name_chinese_short { get; set; }
  19351. // /// <summary>
  19352. // /// 安提瓜和巴布达
  19353. // /// </summary>
  19354. // public string country_name_chinese_UN { get; set; }
  19355. // /// <summary>
  19356. // ///
  19357. // /// </summary>
  19358. // public string country_name_english_abbreviation { get; set; }
  19359. // /// <summary>
  19360. // ///
  19361. // /// </summary>
  19362. // public string country_name_english_formal { get; set; }
  19363. // /// <summary>
  19364. // ///
  19365. // /// </summary>
  19366. // public string country_name_english_UN { get; set; }
  19367. // /// <summary>
  19368. // ///
  19369. // /// </summary>
  19370. // public string continent_name { get; set; }
  19371. // /// <summary>
  19372. // ///
  19373. // /// </summary>
  19374. // public string subregion_name { get; set; }
  19375. // /// <summary>
  19376. // ///
  19377. // /// </summary>
  19378. // public string country_code2 { get; set; }
  19379. // /// <summary>
  19380. // ///
  19381. // /// </summary>
  19382. // public string country_code3 { get; set; }
  19383. // /// <summary>
  19384. // ///
  19385. // /// </summary>
  19386. // public string phone_code { get; set; }
  19387. //}
  19388. //public class CountriesInfo : BasicInfo
  19389. //{
  19390. // public List<CitiesInfo> c { get; set; }
  19391. //}
  19392. //public class CitiesInfo : BasicInfo
  19393. //{
  19394. // public List<AreaInfo> c { get; set; }
  19395. //}
  19396. //public class AreaInfo : BasicInfo
  19397. //{
  19398. // public List<AreaInfo> c { get; set; }
  19399. //}
  19400. //public class BasicInfo
  19401. //{
  19402. // public string code { get; set; }
  19403. // public string cn { get; set; }
  19404. // public string lv { get; set; }
  19405. // public string en { get; set; }
  19406. //}
  19407. #endregion
  19408. #region 查看邀请方
  19409. /// <summary>
  19410. /// 查看邀请方
  19411. /// 邀请方信息 Init
  19412. /// </summary>
  19413. /// <param name="dto"></param>
  19414. /// <returns></returns>
  19415. [HttpPost]
  19416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19417. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  19418. {
  19419. string sqlWhere = string.Empty;
  19420. if (!string.IsNullOrEmpty(dto.Search))
  19421. {
  19422. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  19423. }
  19424. string sql = string.Format($@"Select
  19425. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  19426. Id,
  19427. UnitName
  19428. From Res_InvitationOfficialActivityData
  19429. Where IsDel = 0
  19430. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  19431. RefAsync<int> total = 0;
  19432. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19433. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  19434. }
  19435. /// <summary>
  19436. /// 查看邀请方
  19437. /// 国家信息 Init
  19438. /// </summary>
  19439. /// <param name="dto"></param>
  19440. /// <returns></returns>
  19441. [HttpPost]
  19442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19443. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  19444. {
  19445. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  19446. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19447. var diids = groupInfos.Select(it => it.Id).ToList();
  19448. List<string> countrys = new List<string>();
  19449. foreach (var item in country)
  19450. {
  19451. var data = _groupRepository.FormartTeamName(item);
  19452. var dataArray = _groupRepository.GroupSplitCountry(data);
  19453. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19454. }
  19455. countrys = countrys.Distinct().ToList();
  19456. for (int i = 0; i < countrys.Count; i++)
  19457. {
  19458. string item = countrys[i];
  19459. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  19460. {
  19461. countrys.Remove(item);
  19462. i--;
  19463. }
  19464. }
  19465. RefAsync<int> total = 0;
  19466. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  19467. .Where(it => countrys.Contains(it.Name_CN))
  19468. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19469. .Select(it => new { id = it.Id, name = it.Name_CN })
  19470. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19471. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19472. }
  19473. /// <summary>
  19474. /// 查看邀请方
  19475. /// 城市信息 Init
  19476. /// </summary>
  19477. /// <param name="dto"></param>
  19478. /// <returns></returns>
  19479. [HttpPost]
  19480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19481. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  19482. {
  19483. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  19484. RefAsync<int> total = 0;
  19485. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  19486. .Where(it => it.CountriesId == dto.CountiesId)
  19487. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19488. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  19489. .Select(it => new { id = it.Id, name = it.Name_CN })
  19490. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19491. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19492. }
  19493. /// <summary>
  19494. /// 查看邀请方
  19495. /// 团组名称 Init
  19496. /// </summary>
  19497. /// <param name="dto"></param>
  19498. /// <returns></returns>
  19499. [HttpPost]
  19500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19501. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  19502. {
  19503. var watch = new Stopwatch();
  19504. watch.Start();
  19505. RefAsync<int> total = 0;
  19506. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  19507. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  19508. .Where((oa, di) => oa.IsDel == 0)
  19509. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  19510. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  19511. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  19512. .Distinct()
  19513. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19514. watch.Stop();
  19515. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  19516. }
  19517. /// <summary>
  19518. /// 查看邀请方
  19519. /// 团组 & 邀请方信息
  19520. /// </summary>
  19521. /// <param name="dto"></param>
  19522. /// <returns></returns>
  19523. [HttpPost]
  19524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19525. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  19526. {
  19527. var watch = new Stopwatch();
  19528. watch.Start();
  19529. RefAsync<int> total = 0;
  19530. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  19531. .AS("Grp_DelegationInfo")
  19532. .Includes(x => x.InvitingInfos)
  19533. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  19534. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  19535. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  19536. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  19537. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  19538. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  19539. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19540. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  19541. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  19542. infos.ForEach(x =>
  19543. {
  19544. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  19545. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  19546. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  19547. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  19548. });
  19549. watch.Stop();
  19550. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  19551. }
  19552. #endregion
  19553. #region 报批行程
  19554. /// <summary>
  19555. /// 报批行程初始化
  19556. /// </summary>
  19557. /// <param name="dto"></param>
  19558. /// <returns></returns>
  19559. [HttpPost]
  19560. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  19561. {
  19562. const int chiNumber = 5;
  19563. var jw = JsonView(false);
  19564. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  19565. var group = groupList.First();
  19566. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  19567. group = groupList.First(x => x.Id == diid);
  19568. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19569. .Where(x => x.DiId == diid && x.IsDel == 0)
  19570. .ToArray();
  19571. var count = 1;
  19572. foreach (var item in blackCodeList)
  19573. {
  19574. if (string.IsNullOrWhiteSpace(item.Title))
  19575. {
  19576. item.Title = "未设置名称数据" + count;
  19577. }
  19578. count++;
  19579. };
  19580. if (group == null)
  19581. {
  19582. jw.Msg = "暂无团组!";
  19583. return Ok(jw);
  19584. }
  19585. var data = new
  19586. {
  19587. groupList = groupList.Select(x => new
  19588. {
  19589. x.TeamName,
  19590. x.Id
  19591. }),
  19592. content = new ArrayList(),
  19593. groupInfo = new
  19594. {
  19595. group.VisitDays,
  19596. group.TourCode,
  19597. group.VisitPNumber,
  19598. group.TeamName,
  19599. group.Id,
  19600. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  19601. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  19602. },
  19603. blackCodeList = blackCodeList.Select(x => new
  19604. {
  19605. x.Title,
  19606. x.Id
  19607. }),
  19608. FileTempList = new ArrayList()
  19609. {
  19610. new { Index = 1,FileName = "旧模板" },
  19611. new { Index = 2,FileName = "省外办" },
  19612. new { Index = 3,FileName = "市外办" },
  19613. }
  19614. };
  19615. var resultArr = new ArrayList();
  19616. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  19617. #region 默认不生成行程
  19618. //if (content.Count == 0)
  19619. //{
  19620. // var stay = "-";
  19621. // var cityPath = "-";
  19622. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19623. // .Where(x => x.DiId == diid && x.IsDel == 0)
  19624. // .ToList();
  19625. // //添加城市路径以及住宿地
  19626. // //黑屏代码数据
  19627. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  19628. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19629. // {
  19630. // jw = JsonView(true, "黑屏代码有误!", data);
  19631. // return Ok(jw);
  19632. // }
  19633. // data = data with
  19634. // {
  19635. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  19636. // {
  19637. // x.Title,
  19638. // x.Id,
  19639. // }).ToArray())
  19640. // };
  19641. // foreach (DataRow row in dtBlack.Rows)
  19642. // {
  19643. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19644. // {
  19645. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  19646. // return Ok(jw);
  19647. // }
  19648. // }
  19649. // //黑屏代码获取时间区间
  19650. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19651. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19652. // _sqlSugar.BeginTran();
  19653. // for (int i = 0; i < timeArr.Count; i++)
  19654. // {
  19655. // stay = "-";
  19656. // cityPath = "-";
  19657. // DateTime NewData = DateTime.Parse(timeArr[i]);
  19658. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19659. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19660. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19661. // if (tbSelect.Length > 0)
  19662. // {
  19663. // List<string> threeCodeStr = new List<string>();
  19664. // foreach (var item in tbSelect)
  19665. // {
  19666. // var threeCode = item["Three"].ToString() ?? "";
  19667. // if (threeCode.Length == 6)
  19668. // {
  19669. // var start = threeCode.Substring(0, 3);
  19670. // var end = threeCode.Substring(3, 3);
  19671. // if (threeCodeStr.Count == 0)
  19672. // {
  19673. // threeCodeStr.Add(start);
  19674. // threeCodeStr.Add(end);
  19675. // }
  19676. // else
  19677. // {
  19678. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19679. // {
  19680. // threeCodeStr.Add(end);
  19681. // }
  19682. // else
  19683. // {
  19684. // threeCodeStr.Add(start);
  19685. // threeCodeStr.Add(end);
  19686. // }
  19687. // }
  19688. // }
  19689. // }
  19690. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19691. // var last = threeCodeStr.Last();
  19692. // foreach (var item in threeCodeStr)
  19693. // {
  19694. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19695. // if (item.Equals(last))
  19696. // {
  19697. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19698. // }
  19699. // }
  19700. // cityPath = cityPath.Trim('-');
  19701. // }
  19702. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  19703. // appro.Diid = diid ?? -1;
  19704. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19705. // appro.Id = thisId;
  19706. // appro.CreateUserId = dto.UserId;
  19707. // appro.CreateTime = DateTime.Now;
  19708. // content.Add(appro);
  19709. // }
  19710. // _sqlSugar.CommitTran();
  19711. //}
  19712. #endregion
  19713. foreach (var x in content)
  19714. {
  19715. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  19716. if (chiList.Count < chiNumber)
  19717. {
  19718. for (int i = chiList.Count; i < chiNumber; i++)
  19719. {
  19720. chiList.Add(new Grp_ApprovalTravelDetails());
  19721. }
  19722. }
  19723. resultArr.Add(new
  19724. {
  19725. x.Id,
  19726. x.Date,
  19727. x.Diid,
  19728. chiList = chiList.Select(x1 => new
  19729. {
  19730. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19731. x1.Details,
  19732. x1.ParentId,
  19733. x1.Id
  19734. })
  19735. });
  19736. }
  19737. data = data with
  19738. {
  19739. content = resultArr,
  19740. };
  19741. jw = JsonView(true, "获取成功!", data);
  19742. return Ok(jw);
  19743. }
  19744. /// <summary>
  19745. /// 报批行程删除
  19746. /// </summary>
  19747. /// <param name="dto"></param>
  19748. /// <returns></returns>
  19749. [HttpPost]
  19750. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  19751. {
  19752. var jw = JsonView(false);
  19753. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19754. if (group == null)
  19755. {
  19756. jw.Msg = "团组参数有误!";
  19757. return Ok(jw);
  19758. }
  19759. try
  19760. {
  19761. _sqlSugar.BeginTran();
  19762. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  19763. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  19764. {
  19765. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19766. DeleteUserId = dto.uesrId,
  19767. IsDel = 1
  19768. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  19769. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  19770. {
  19771. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19772. DeleteUserId = dto.uesrId,
  19773. IsDel = 1
  19774. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  19775. _sqlSugar.CommitTran();
  19776. jw = JsonView(true, "删除成功");
  19777. }
  19778. catch (Exception ex)
  19779. {
  19780. jw = JsonView(false, ex.Message);
  19781. }
  19782. return Ok(jw);
  19783. }
  19784. /// <summary>
  19785. /// 报批行程保存
  19786. /// </summary>
  19787. /// <param name="dto"></param>
  19788. /// <returns></returns>
  19789. [HttpPost]
  19790. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  19791. {
  19792. var jw = JsonView(false);
  19793. var Find = dto.Arr.Find(x => x.id == 0);
  19794. if (Find != null)
  19795. {
  19796. jw.Msg = "生成的ID为0!";
  19797. return Ok(jw);
  19798. }
  19799. foreach (var item in dto.Arr)
  19800. {
  19801. foreach (var chi in item.chiList)
  19802. {
  19803. if (chi.parentId == 0)
  19804. {
  19805. chi.parentId = item.id;
  19806. }
  19807. }
  19808. }
  19809. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  19810. _sqlSugar.BeginTran();
  19811. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  19812. {
  19813. var parentIds = dto.Arr.Select(x => x.id).ToList();
  19814. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  19815. {
  19816. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19817. DeleteUserId = dto.UserId,
  19818. IsDel = 1
  19819. }).ExecuteCommand();
  19820. }
  19821. try
  19822. {
  19823. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  19824. {
  19825. CreateTime = DateTime.Now,
  19826. CreateUserId = dto.UserId,
  19827. Details = x.details,
  19828. ParentId = x.parentId,
  19829. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19830. Remark = "",
  19831. IsDel = 0
  19832. }).ToList()).ExecuteCommand();
  19833. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  19834. {
  19835. Id = x.id,
  19836. Details = x.details,
  19837. ParentId = x.parentId,
  19838. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19839. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  19840. {
  19841. Details = x.Details,
  19842. ParentId = x.ParentId,
  19843. Time = x.Time
  19844. }).ExecuteCommand();
  19845. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  19846. {
  19847. Id = x.id,
  19848. Date = x.date,
  19849. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  19850. {
  19851. Date = x.Date
  19852. }).ExecuteCommand();
  19853. _sqlSugar.CommitTran();
  19854. jw = JsonView(true, "保存成功!");
  19855. }
  19856. catch (Exception ex)
  19857. {
  19858. _sqlSugar.RollbackTran();
  19859. jw = JsonView(false, "保存失败!" + ex.Message);
  19860. }
  19861. return Ok(jw);
  19862. }
  19863. /// <summary>
  19864. /// 报批行程生成
  19865. /// </summary>
  19866. /// <param name="dto"></param>
  19867. /// <returns></returns>
  19868. [HttpPost]
  19869. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  19870. {
  19871. var jw = JsonView(false);
  19872. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19873. if (group == null)
  19874. {
  19875. jw.Msg = "暂无该团组!";
  19876. return Ok(jw);
  19877. }
  19878. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  19879. //黑屏代码数据
  19880. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  19881. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19882. {
  19883. jw.Msg = "黑屏代码有误!";
  19884. return Ok(jw);
  19885. }
  19886. foreach (DataRow row in dtBlack.Rows)
  19887. {
  19888. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19889. {
  19890. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  19891. return Ok(jw);
  19892. }
  19893. }
  19894. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  19895. var resultArr = new ArrayList();
  19896. //if (officialActivitiesArr.Count == 0)
  19897. //{
  19898. // jw.Msg = "暂无公务出访信息!";
  19899. // return Ok(jw);
  19900. //}
  19901. try
  19902. {
  19903. _sqlSugar.BeginTran();
  19904. DeleteApprovalJourney(new
  19905. Domain.Dtos.Groups.DeleteApprovalJourney
  19906. {
  19907. Diid = dto.Diid,
  19908. uesrId = dto.Userid
  19909. });
  19910. var stay = "-";
  19911. var cityPath = "-";
  19912. var arriveCountry = string.Empty;
  19913. //添加城市路径以及住宿地
  19914. //黑屏代码获取时间区间
  19915. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19916. var empty = "【未收入该三字码!请机票同事录入】";
  19917. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19918. #region 配置公务活动时间
  19919. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  19920. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  19921. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  19922. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  19923. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  19924. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19925. {
  19926. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  19927. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  19928. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19929. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  19930. };
  19931. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19932. {
  19933. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  19934. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  19935. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19936. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  19937. };
  19938. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  19939. {
  19940. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  19941. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  19942. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  19943. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  19944. };
  19945. #endregion
  19946. var nextDayNum = 0;
  19947. for (int i = 0; i < timeArr.Count; i++)
  19948. {
  19949. stay = "-";
  19950. cityPath = "-";
  19951. var chiarr = new List<Grp_ApprovalTravelDetails>();
  19952. DateTime NewData = DateTime.Parse(timeArr[i]);
  19953. //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();
  19954. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19955. if (nextDayNum > 0)
  19956. {
  19957. nextDayNum--;
  19958. }
  19959. if (tbSelect.Length > 0)
  19960. {
  19961. List<string> threeCodeStr = new List<string>();
  19962. bool isTrade = false;
  19963. string trip = string.Empty;
  19964. foreach (var item in tbSelect)
  19965. {
  19966. if (nextDayNum == 0)
  19967. {
  19968. nextDayNum = Convert.ToInt32(item["Sign"]);
  19969. }
  19970. var airStartTime = item["StartTime"].ToString() ?? "0000";
  19971. var airEndTime = item["EndTime"].ToString() ?? "0000";
  19972. var takeOffTime = DateTime.Parse(timeArr[i]);
  19973. var fallToTime = DateTime.Parse(timeArr[i]);
  19974. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  19975. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  19976. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  19977. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  19978. if (nextDayNum > 0)
  19979. {
  19980. fallToTime = fallToTime.AddDays(nextDayNum);
  19981. }
  19982. trip = string.Empty;
  19983. var start = string.Empty;
  19984. var end = string.Empty;
  19985. var threeCode = item["Three"].ToString() ?? "";
  19986. if (threeCode.Length == 6)
  19987. {
  19988. start = threeCode.Substring(0, 3);
  19989. end = threeCode.Substring(3, 3);
  19990. if (threeCodeStr.Count == 0)
  19991. {
  19992. threeCodeStr.Add(start);
  19993. threeCodeStr.Add(end);
  19994. }
  19995. else
  19996. {
  19997. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19998. {
  19999. threeCodeStr.Add(end);
  20000. }
  20001. else
  20002. {
  20003. threeCodeStr.Add(start);
  20004. threeCodeStr.Add(end);
  20005. }
  20006. }
  20007. }
  20008. //处理机票信息
  20009. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20010. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20011. if (start_Object == null)
  20012. {
  20013. start_Object = new Res_ThreeCode()
  20014. {
  20015. AirPort = empty,
  20016. AirPort_En = empty,
  20017. City = empty,
  20018. Country = empty,
  20019. Four = empty,
  20020. Three = empty,
  20021. };
  20022. }
  20023. if (end_Object == null)
  20024. {
  20025. end_Object = new Res_ThreeCode()
  20026. {
  20027. AirPort = empty,
  20028. AirPort_En = empty,
  20029. City = empty,
  20030. Country = empty,
  20031. Four = empty,
  20032. Three = empty,
  20033. };
  20034. }
  20035. //机型判断
  20036. string airModel = item["AirModel"].ToString();
  20037. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  20038. string flightTime = item["FlightTime"].ToString();
  20039. flightTime = ParseBlackTime(flightTime);
  20040. //航班号
  20041. string flightcode = item["Fliagtcode"].ToString();
  20042. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  20043. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  20044. if (aircompany == null)
  20045. {
  20046. aircompany = new Res_AirCompany
  20047. {
  20048. CnName = hsEmpty,
  20049. EnName = hsEmpty,
  20050. ShortCode = hsEmpty,
  20051. };
  20052. }
  20053. //航班前公务安排
  20054. if (tbSelect.First().Equals(item) && i != 0)
  20055. {
  20056. foreach (var takeoff in takeoffTimes)
  20057. {
  20058. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  20059. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  20060. {
  20061. foreach (var addTime in takeoff.Item2)
  20062. {
  20063. chiarr.Add(new Grp_ApprovalTravelDetails
  20064. {
  20065. Time = addTime,
  20066. CreateTime = DateTime.Now,
  20067. CreateUserId = dto.Userid,
  20068. ParentId = 0,
  20069. Details = "公务活动"
  20070. });
  20071. }
  20072. break;
  20073. }
  20074. }
  20075. }
  20076. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  20077. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  20078. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  20079. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  20080. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  20081. if (isTrade)
  20082. {
  20083. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  20084. trip += "(转机不出机场)。";
  20085. }
  20086. //else
  20087. //{
  20088. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  20089. //}
  20090. chiarr.Add(new Grp_ApprovalTravelDetails
  20091. {
  20092. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  20093. CreateTime = DateTime.Now,
  20094. CreateUserId = dto.Userid,
  20095. ParentId = 0,
  20096. Details = trip
  20097. });
  20098. //最后一条到达的时间安排公务
  20099. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  20100. {
  20101. bool isCheckCountry = false;
  20102. if (end_Object.Country != arriveCountry)
  20103. {
  20104. arriveCountry = end_Object.Country;
  20105. isCheckCountry = true;
  20106. }
  20107. if (nextDayNum == 0)
  20108. {
  20109. //需要入境的情况
  20110. if (isCheckCountry)
  20111. {
  20112. foreach (var fallTime in fallTimesCheckCountry)
  20113. {
  20114. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20115. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20116. {
  20117. foreach (var addTime in fallTime.Item2)
  20118. {
  20119. chiarr.Add(new Grp_ApprovalTravelDetails
  20120. {
  20121. Time = addTime,
  20122. CreateTime = DateTime.Now,
  20123. CreateUserId = dto.Userid,
  20124. ParentId = 0,
  20125. Details = "公务活动"
  20126. });
  20127. }
  20128. break;
  20129. }
  20130. }
  20131. }
  20132. else
  20133. {
  20134. foreach (var fallTime in fallTimesNotCheckCountry)
  20135. {
  20136. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20137. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20138. {
  20139. foreach (var addTime in fallTime.Item2)
  20140. {
  20141. chiarr.Add(new Grp_ApprovalTravelDetails
  20142. {
  20143. Time = addTime,
  20144. CreateTime = DateTime.Now,
  20145. CreateUserId = dto.Userid,
  20146. ParentId = 0,
  20147. Details = "公务活动"
  20148. });
  20149. }
  20150. break;
  20151. }
  20152. }
  20153. }
  20154. }
  20155. }
  20156. }
  20157. //添加乘车语句
  20158. //chiarr.Add(new Grp_ApprovalTravelDetails
  20159. //{
  20160. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  20161. // CreateTime = DateTime.Now,
  20162. // CreateUserId = dto.Userid,
  20163. // ParentId = 0,
  20164. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  20165. //});
  20166. //if (i != timeArr.Count - 1)
  20167. //{
  20168. // fallToTime = fallToTime.AddHours(2.5);
  20169. // foreach (var item in Times)
  20170. // {
  20171. // //排列公务时间
  20172. // if (fallToTime.Hour < item.Item1)
  20173. // {
  20174. // chiarr.Add(new Grp_ApprovalTravelDetails
  20175. // {
  20176. // Time = $"{item.Item2} - {item.Item3}",
  20177. // CreateTime = DateTime.Now,
  20178. // CreateUserId = dto.Userid,
  20179. // ParentId = 0,
  20180. // Details = "公务活动"
  20181. // });
  20182. // }
  20183. // }
  20184. //}
  20185. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20186. var last = threeCodeStr.Last();
  20187. foreach (var item in threeCodeStr)
  20188. {
  20189. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20190. if (item.Equals(last))
  20191. {
  20192. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20193. }
  20194. }
  20195. cityPath = cityPath.Trim('-');
  20196. }
  20197. else
  20198. {
  20199. foreach (var item in Times)
  20200. {
  20201. chiarr.Add(new Grp_ApprovalTravelDetails
  20202. {
  20203. Time = $"{item.Item2} - {item.Item3}",
  20204. CreateTime = DateTime.Now,
  20205. CreateUserId = dto.Userid,
  20206. ParentId = 0,
  20207. Details = "公务活动"
  20208. });
  20209. }
  20210. }
  20211. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20212. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20213. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  20214. appro.Diid = dto.Diid;
  20215. appro.CreateUserId = dto.Userid;
  20216. appro.CreateTime = DateTime.Now;
  20217. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20218. appro.Id = thisId;
  20219. //foreach (var item in gwinfo)
  20220. //{
  20221. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  20222. // chi.Details = "拜访" + item.Client;
  20223. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  20224. // {
  20225. // chi.Details += "," + item.ReqSample;
  20226. // }
  20227. // chi.ParentId = thisId;
  20228. // chi.Time = item.Time;
  20229. // chiarr.Add(chi);
  20230. //}
  20231. if (chiarr.Count < 6)
  20232. {
  20233. for (int j = chiarr.Count; j < 6; j++)
  20234. {
  20235. chiarr.Add(new
  20236. Grp_ApprovalTravelDetails());
  20237. }
  20238. }
  20239. resultArr.Add(new
  20240. {
  20241. appro.Id,
  20242. appro.Date,
  20243. appro.Diid,
  20244. chiList = chiarr.Select(x1 => new
  20245. {
  20246. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20247. x1.Details,
  20248. x1.ParentId,
  20249. x1.Id
  20250. })
  20251. });
  20252. }
  20253. _sqlSugar.CommitTran();
  20254. jw = JsonView(true, "生成成功!", resultArr);
  20255. }
  20256. catch (Exception ex)
  20257. {
  20258. jw.Code = 400;
  20259. jw.Msg = "生成失败!" + ex.Message;
  20260. }
  20261. return Ok(jw);
  20262. }
  20263. /// <summary>
  20264. /// 报批行程word导出
  20265. /// </summary>
  20266. /// <param name="dto"></param>
  20267. /// <returns></returns>
  20268. [HttpPost]
  20269. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  20270. {
  20271. var jw = JsonView(false);
  20272. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20273. if (group == null)
  20274. {
  20275. jw.Msg = "暂无该团组!";
  20276. return Ok(jw);
  20277. }
  20278. //模板路径
  20279. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  20280. var fileName = string.Empty;
  20281. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  20282. bool bold = false;
  20283. if (dto.FileIndex == 1)
  20284. {
  20285. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  20286. }
  20287. else if (dto.FileIndex == 2)
  20288. {
  20289. fileName = "省外办-报批.docx";
  20290. bold = false;
  20291. titleFont = "方正黑体简体";
  20292. timeFont = "Times New Roman";
  20293. contentFont = "方正仿宋_GBK";
  20294. }
  20295. else if (dto.FileIndex == 3)
  20296. {
  20297. fileName = "市外办-报批.docx";
  20298. titleFont = "方正黑体简体";
  20299. timeFont = "Times New Roman";
  20300. contentFont = "方正仿宋简体";
  20301. }
  20302. tempPath = tempPath + fileName;
  20303. //载入模板
  20304. Document doc = new Document(tempPath);
  20305. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20306. //获取所填表格的序数
  20307. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20308. Aspose.Words.Tables.Row titleRowClone = null;
  20309. Aspose.Words.Tables.Row CenterRowClone = null;
  20310. int index = 0;
  20311. int indexChi = 0;
  20312. int SetIndex = 0;
  20313. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  20314. //获取数据,放到datatable
  20315. foreach (var item in ApprovalTravelArr)
  20316. {
  20317. if (index > 0)
  20318. {
  20319. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  20320. tableOne.AppendChild(titleRowClone);
  20321. }
  20322. var textTime = item.Date;
  20323. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  20324. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  20325. SetIndex++;
  20326. if (ChiRep.Count > 0)
  20327. {
  20328. foreach (var itemChi in ChiRep)
  20329. {
  20330. var txtTime = itemChi.Time;
  20331. var txtDetail = itemChi.Details;
  20332. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  20333. {
  20334. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  20335. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20336. //indexChi++;
  20337. //SetIndex++;
  20338. break;
  20339. }
  20340. if (indexChi > 0)
  20341. {
  20342. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20343. tableOne.AppendChild(CenterRowClone);
  20344. }
  20345. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  20346. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  20347. indexChi++;
  20348. SetIndex++;
  20349. }
  20350. }
  20351. //else
  20352. //{
  20353. // if (indexChi > 0)
  20354. // {
  20355. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20356. // tableOne.AppendChild(CenterRowClone);
  20357. // }
  20358. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  20359. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20360. // indexChi++;
  20361. // SetIndex++;
  20362. //}
  20363. index++;
  20364. }
  20365. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  20366. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20367. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20368. jw.Code = 200;
  20369. jw.Msg = "";
  20370. return Ok(jw);
  20371. }
  20372. private string ParseBlackTime(string time)
  20373. {
  20374. // 匹配可能只有分钟的情况
  20375. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  20376. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  20377. if (match.Success)
  20378. {
  20379. string hours = match.Groups[1].Value;
  20380. string minutes = match.Groups[2].Value;
  20381. // 如果小时部分为空,则只显示分钟
  20382. if (string.IsNullOrEmpty(hours))
  20383. {
  20384. return $"{minutes}分钟";
  20385. }
  20386. // 如果分钟部分为空,则只显示小时
  20387. else if (string.IsNullOrEmpty(minutes))
  20388. {
  20389. return $"{hours}小时";
  20390. }
  20391. // 否则显示完整格式
  20392. else
  20393. {
  20394. return $"{hours}小时{minutes}分钟";
  20395. }
  20396. }
  20397. else
  20398. {
  20399. return "未知时长";
  20400. }
  20401. }
  20402. private string intToString(int numberVal)
  20403. {
  20404. string numberval = numberVal.ToString();
  20405. Dictionary<char, string> Number = new Dictionary<char, string>();
  20406. Number.Add('1', "一");
  20407. Number.Add('2', "二");
  20408. Number.Add('3', "三");
  20409. Number.Add('4', "四");
  20410. Number.Add('5', "五");
  20411. Number.Add('6', "六");
  20412. Number.Add('7', "七");
  20413. Number.Add('8', "八");
  20414. Number.Add('9', "九");
  20415. string stringNumberVal = string.Empty;
  20416. for (int i = 0; i < numberval.Length; i++)
  20417. {
  20418. if (i == 0)
  20419. {
  20420. stringNumberVal += Number[numberval[i]];
  20421. }
  20422. else if (i >= 1)
  20423. {
  20424. if (numberval[i] == '0')
  20425. {
  20426. stringNumberVal = "十";
  20427. }
  20428. else
  20429. {
  20430. stringNumberVal += "十" + Number[numberval[i]];
  20431. }
  20432. }
  20433. }
  20434. return stringNumberVal;
  20435. }
  20436. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  20437. {
  20438. //获取table中的某个单元格,从0开始
  20439. Cell lshCell = table.Rows[rows].Cells[cells];
  20440. //将单元格中段落移除
  20441. foreach (Paragraph item in lshCell.Paragraphs)
  20442. {
  20443. lshCell.Paragraphs.Remove(item);
  20444. }
  20445. if (val.Contains("\r\n"))
  20446. {
  20447. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  20448. foreach (var item in spArr)
  20449. {
  20450. //新建一个段落
  20451. Paragraph p = new Paragraph(doc);
  20452. var r = new Run(doc, item);
  20453. //设置字体
  20454. if (!string.IsNullOrEmpty(font))
  20455. {
  20456. r.Font.Name = font;
  20457. }
  20458. r.Font.Bold = bold;
  20459. //把设置的值赋给之前新建的段落
  20460. p.AppendChild(r);
  20461. //将此段落加到单元格内
  20462. lshCell.AppendChild(p);
  20463. }
  20464. }
  20465. else
  20466. {
  20467. //新建一个段落
  20468. Paragraph p = new Paragraph(doc);
  20469. var r = new Run(doc, val);
  20470. //设置字体
  20471. if (!string.IsNullOrEmpty(font))
  20472. {
  20473. r.Font.Name = font;
  20474. }
  20475. r.Font.Bold = bold;
  20476. //把设置的值赋给之前新建的段落
  20477. p.AppendChild(r);
  20478. //将此段落加到单元格内
  20479. lshCell.AppendChild(p);
  20480. }
  20481. }
  20482. //[HttpPost]
  20483. //public async Task<IActionResult> ServerHttp(string paramStr)
  20484. //{
  20485. // paramStr = paramStr.TrimEnd('\'');
  20486. // paramStr = paramStr.TrimStart('\'');
  20487. // JsonView jw = JsonView(false);
  20488. // JObject param = JObject.Parse(paramStr);
  20489. // if (!param.ContainsKey("url"))
  20490. // {
  20491. // jw.Msg = "url null";
  20492. // return Ok(jw);
  20493. // }
  20494. // string url = param["url"]!.ToString();
  20495. // var methon = "get";
  20496. // Dictionary<string, string> headValues = null;
  20497. // string bodyStr = string.Empty;
  20498. // if (param.ContainsKey("methon"))
  20499. // {
  20500. // methon = param["methon"]!.ToString().ToLower();
  20501. // }
  20502. // if (param.ContainsKey("header"))
  20503. // {
  20504. // var header = param["header"]!.ToString();
  20505. // JObject headerJobject = JObject.Parse(header);
  20506. // headValues = new Dictionary<string, string>();
  20507. // foreach (JProperty item in headerJobject.Properties())
  20508. // {
  20509. // var value = item.Value.ToString();
  20510. // var head = item.Path;
  20511. // headValues.Add(head, value);
  20512. // }
  20513. // }
  20514. // HttpClient client = new HttpClient();
  20515. // string responseString = string.Empty;
  20516. // StringContent content = null;
  20517. // if (headValues != null)
  20518. // {
  20519. // foreach (var item in headValues.Keys)
  20520. // {
  20521. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  20522. // {
  20523. // if (param.ContainsKey("body"))
  20524. // {
  20525. // bodyStr = param["body"]!.ToString();
  20526. // }
  20527. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  20528. // }
  20529. // else
  20530. // {
  20531. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  20532. // }
  20533. // }
  20534. // }
  20535. // try
  20536. // {
  20537. // if (methon == "get")
  20538. // {
  20539. // responseString = await client.GetStringAsync(url);
  20540. // }
  20541. // else if (methon == "post")
  20542. // {
  20543. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  20544. // {
  20545. // Content = content
  20546. // };
  20547. // var response = await client.SendAsync(request);
  20548. // try
  20549. // {
  20550. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  20551. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  20552. // {
  20553. // using (StreamReader reader = new StreamReader(gzipStream))
  20554. // {
  20555. // responseString = await reader.ReadToEndAsync();
  20556. // }
  20557. // }
  20558. // }
  20559. // catch (Exception)
  20560. // {
  20561. // responseString = await response.Content.ReadAsStringAsync();
  20562. // }
  20563. // }
  20564. // else
  20565. // {
  20566. // responseString = "methon error";
  20567. // }
  20568. // jw = JsonView(true, "success", responseString);
  20569. // }
  20570. // catch (Exception ex)
  20571. // {
  20572. // jw.Msg = "error " + ex.Message;
  20573. // jw.Data = ex.StackTrace;
  20574. // }
  20575. // finally
  20576. // {
  20577. // client.Dispose();
  20578. // }
  20579. // return Ok(jw);
  20580. //}
  20581. #endregion
  20582. #region 团组接待意见调查
  20583. /// <summary>
  20584. /// 团组接待意见调查 - 信息管理
  20585. /// 基础数据(团组)
  20586. /// </summary>
  20587. /// <returns></returns>
  20588. [HttpGet]
  20589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20590. public async Task<IActionResult> OpinionaireInit()
  20591. {
  20592. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  20593. .Select(x => new
  20594. {
  20595. x.Id,
  20596. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  20597. })
  20598. .OrderByDescending(x => x.Id)
  20599. .ToListAsync();
  20600. return Ok(JsonView(groupData, groupData.Count));
  20601. }
  20602. /// <summary>
  20603. /// 团组接待意见调查 - 信息管理
  20604. /// 列表
  20605. /// </summary>
  20606. /// <param name="groupId"></param>
  20607. /// <returns></returns>
  20608. [HttpGet("{groupId}")]
  20609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20610. public async Task<IActionResult> OpinionaireManageList(int groupId)
  20611. {
  20612. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20613. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  20614. .Select(x => new
  20615. {
  20616. x.Id,
  20617. x.TourGuideName,
  20618. x.CityName,
  20619. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  20620. x.CreateTime
  20621. })
  20622. .OrderBy(x => x.Id)
  20623. .ToListAsync();
  20624. return Ok(JsonView(data));
  20625. }
  20626. /// <summary>
  20627. /// 团组接待意见调查 - 信息管理
  20628. /// 保存
  20629. /// </summary>
  20630. /// <param name="dto"></param>
  20631. /// <returns></returns>
  20632. [HttpPost]
  20633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20634. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  20635. {
  20636. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20637. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20638. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20639. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  20640. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  20641. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  20642. _opinionaireRep.BeginTran();
  20643. if (addData != null && addData.Count > 0)
  20644. {
  20645. foreach (var item in addData)
  20646. {
  20647. item.CreateUserId = currUserInfo.UserId;
  20648. item.DiId = dto.DiId;
  20649. }
  20650. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  20651. }
  20652. if (updData != null && updData.Count > 0)
  20653. {
  20654. var upd = await _opinionaireRep._sqlSugar
  20655. .Updateable(updData)
  20656. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  20657. .WhereColumns(x => new { x.Id })
  20658. .ExecuteCommandAsync();
  20659. }
  20660. _opinionaireRep.CommitTran();
  20661. return Ok(JsonView("操作成功!"));
  20662. }
  20663. /// <summary>
  20664. /// 团组接待意见调查 - 信息管理
  20665. /// 删除
  20666. /// </summary>
  20667. /// <param name="id"></param>
  20668. /// <returns></returns>
  20669. [HttpDelete("{id}")]
  20670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20671. public async Task<IActionResult> OpinionaireManageDel(int id)
  20672. {
  20673. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20674. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20675. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  20676. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  20677. if (!del) return Ok(JsonView("操作失败!"));
  20678. return Ok(JsonView("操作成功!"));
  20679. }
  20680. /// <summary>
  20681. /// 团组接待意见调查 - 用户
  20682. /// 列表
  20683. /// </summary>
  20684. /// <param name="diId"></param>
  20685. /// <returns></returns>
  20686. [HttpGet("{diId}")]
  20687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20688. public async Task<IActionResult> OpinionaireUserList(int diId)
  20689. {
  20690. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20691. var sql = string.Format(@"
  20692. SELECT
  20693. o.Id,
  20694. o.DiId,
  20695. di.TeamName AS 'GroupName',
  20696. di.VisitPNumber AS 'PeopleNumber',
  20697. di.ClientName AS 'LeadGroup',
  20698. di.VisitCountry AS 'Travel',
  20699. di.VisitDays AS 'Days',
  20700. o.CityName,
  20701. o.TourGuideName,
  20702. o.Catering,
  20703. o.CateringReason,
  20704. o.Stay,
  20705. o.StayReason,
  20706. o.[Route],
  20707. o.RouteReason,
  20708. o.OfficialActivity,
  20709. o.OfficialActivityReason,
  20710. o.TourGuide,
  20711. o.TourGuideReason,
  20712. o.[Translate],
  20713. o.TranslateReason,
  20714. o.Trip,
  20715. o.TripReason,
  20716. o.ESFileName,
  20717. o.SignatureDate,
  20718. o.Remark
  20719. FROM
  20720. Grp_Opinionaire o
  20721. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  20722. WHERE
  20723. o.IsDel = 0
  20724. AND o.DiId = {0}
  20725. ORDER BY
  20726. o.Id ASC", diId);
  20727. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  20728. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  20729. return Ok(JsonView(data));
  20730. }
  20731. /// <summary>
  20732. /// 团组接待意见调查 - 用户
  20733. /// 保存
  20734. /// </summary>
  20735. /// <param name="dto"></param>
  20736. /// <returns></returns>
  20737. [HttpPost]
  20738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20739. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  20740. {
  20741. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  20742. foreach (var item in dto)
  20743. {
  20744. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  20745. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  20746. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  20747. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  20748. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  20749. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  20750. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  20751. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  20752. }
  20753. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  20754. if (!Directory.Exists(filePathBase))
  20755. {
  20756. Directory.CreateDirectory(filePathBase);
  20757. }
  20758. #region 上传文件
  20759. var filePaths = new List<string>();
  20760. foreach (var item in dto)
  20761. {
  20762. var file = item.File;
  20763. // 将文件保存到指定位置
  20764. var filePath = Path.Combine(filePathBase, file.FileName);
  20765. using (var stream = new FileStream(filePath, FileMode.Create))
  20766. {
  20767. await file.CopyToAsync(stream);
  20768. }
  20769. //验证文件是否上传成功
  20770. if (!System.IO.File.Exists(filePath))
  20771. {
  20772. foreach (var filePathStr in filePaths)
  20773. {
  20774. System.IO.File.Delete(filePathStr);
  20775. }
  20776. return Ok(JsonView(false, "文件上传失败!"));
  20777. }
  20778. item.ESFileName = file.FileName;
  20779. }
  20780. #endregion
  20781. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  20782. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  20783. .UpdateColumns(x => new
  20784. {
  20785. x.Catering,
  20786. x.CateringReason,
  20787. x.Stay,
  20788. x.StayReason,
  20789. x.Route,
  20790. x.RouteReason,
  20791. x.OfficialActivity,
  20792. x.OfficialActivityReason,
  20793. x.TourGuide,
  20794. x.TourGuideReason,
  20795. x.Translate,
  20796. x.TranslateReason,
  20797. x.Trip,
  20798. x.TripReason,
  20799. x.ESFileName,
  20800. x.SignatureDate,
  20801. x.Remark
  20802. })
  20803. .WhereColumns(x => new { x.Id })
  20804. .ExecuteCommandAsync();
  20805. if (upd < 1)
  20806. {
  20807. foreach (var filePathStr in filePaths)
  20808. {
  20809. System.IO.File.Delete(filePathStr);
  20810. }
  20811. return Ok(JsonView(false));
  20812. }
  20813. return Ok(JsonView(true));
  20814. }
  20815. #endregion
  20816. #region 团组餐厅相关信息
  20817. /// <summary>
  20818. /// 团组相关餐厅信息
  20819. /// 基础数据(团组)
  20820. /// </summary>
  20821. /// <returns></returns>
  20822. [HttpGet]
  20823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20824. public async Task<IActionResult> RestaurantInit()
  20825. {
  20826. return Ok(await _restaurantRep.InitAsync());
  20827. }
  20828. /// <summary>
  20829. /// 团组相关餐厅信息
  20830. /// Item
  20831. /// </summary>
  20832. /// <param name="dto"></param>
  20833. /// <returns></returns>
  20834. [HttpPost]
  20835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20836. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  20837. {
  20838. int portType = dto.PortType,
  20839. groupId = dto.GroupId;
  20840. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20841. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20842. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  20843. }
  20844. /// <summary>
  20845. /// 团组相关餐厅信息
  20846. /// List
  20847. /// </summary>
  20848. /// <param name="dto"></param>
  20849. /// <returns></returns>
  20850. [HttpPost]
  20851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20852. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  20853. {
  20854. int portType = dto.PortType,
  20855. groupId = dto.GroupId;
  20856. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20857. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20858. var sql = string.Format(@" SELECT
  20859. ri.Id,
  20860. ri.GroupId,
  20861. ri.Date,
  20862. ri.StartTime,
  20863. ri.EndTime,
  20864. CASE WHEN ri.Type = 1 THEN '早餐'
  20865. WHEN ri.Type = 2 THEN '午餐'
  20866. WHEN ri.Type = 3 THEN '晚餐'
  20867. ELSE '其他'
  20868. END AS 'Type',
  20869. ri.Name,
  20870. ri.Address,
  20871. ri.Tel,
  20872. ri.Remark,
  20873. ri.CreateTime,
  20874. u.CnName AS CreateUserName
  20875. FROM
  20876. Grp_RestaurantInfo ri
  20877. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  20878. WHERE
  20879. ri.IsDel = 0
  20880. AND ri.GroupId = {0}
  20881. ORDER BY
  20882. ri.Date ASC
  20883. ", groupId);
  20884. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  20885. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  20886. return Ok(JsonView(infos));
  20887. }
  20888. /// <summary>
  20889. /// 团组相关餐厅信息
  20890. /// Info
  20891. /// </summary>
  20892. /// <param name="dto"></param>
  20893. /// <returns></returns>
  20894. [HttpPost]
  20895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20896. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  20897. {
  20898. int portType = dto.PortType,
  20899. id = dto.Id;
  20900. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20901. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20902. return Ok(await _restaurantRep.InfoAsync(portType, id));
  20903. }
  20904. /// <summary>
  20905. /// 团组相关餐厅信息
  20906. /// Op
  20907. /// </summary>
  20908. /// <param name="dto"></param>
  20909. /// <returns></returns>
  20910. [HttpPost]
  20911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20912. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  20913. {
  20914. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20915. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20916. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  20917. return Ok(await _restaurantRep.OpAsync(dto));
  20918. }
  20919. /// <summary>
  20920. /// 团组相关餐厅信息
  20921. /// Del
  20922. /// </summary>
  20923. /// <param name="dto"></param>
  20924. /// <returns></returns>
  20925. [HttpPost]
  20926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20927. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  20928. {
  20929. int userId = dto.DeleteUserId;
  20930. var id = dto.Id;
  20931. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20932. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20933. return Ok(await _restaurantRep.DelAsync(dto));
  20934. }
  20935. #endregion
  20936. // /// <summary>
  20937. // ///
  20938. // /// </summary>
  20939. // /// <param name="_dto"></param>
  20940. // /// <returns></returns>
  20941. // [HttpPost]
  20942. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20943. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20944. // {
  20945. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20946. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  20947. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  20948. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20949. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  20950. // dic_psg.Add("客人", 974);
  20951. // dic_psg.Add("司机", 975);
  20952. // dic_psg.Add("导游", 976);
  20953. // dic_psg.Add("公司内部人员", 977);
  20954. // dic_psg.Add("司机/导游/公司内部人员", 978);
  20955. // foreach (var item in list_visa)
  20956. // {
  20957. // Grp_VisaInfo temp = new Grp_VisaInfo();
  20958. // temp.Id = item.Id;
  20959. // temp.DIId = item.DIId;
  20960. // temp.VisaClient = item.VisaClient;
  20961. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  20962. // temp.VisaCurrency = item.VisaCurrency;
  20963. // temp.IsThird = item.IsThird;
  20964. // if (dic_psg.ContainsKey(item.PassengerType))
  20965. // {
  20966. // temp.PassengerType = dic_psg[item.PassengerType];
  20967. // }
  20968. // else {
  20969. // temp.PassengerType = -1;
  20970. // }
  20971. // temp.VisaNumber = item.VisaNumber;
  20972. // temp.VisaFreeNumber = item.VisaFreeNumber;
  20973. // temp.CreateUserId = item.Operators;
  20974. // DateTime dt_ct;
  20975. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  20976. // if (b_ct)
  20977. // {
  20978. // temp.CreateTime = dt_ct;
  20979. // }
  20980. // else
  20981. // {
  20982. // temp.CreateTime = DateTime.Now;
  20983. // }
  20984. // temp.DeleteTime = "";
  20985. // temp.DeleteUserId = 0;
  20986. // temp.Remark = item.Remark;
  20987. // if (string.IsNullOrEmpty(temp.Remark)) {
  20988. // temp.Remark = "";
  20989. // }
  20990. // temp.IsDel = item.IsDel;
  20991. // temp.VisaDescription = item.VisaAttachment;
  20992. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  20993. //([Id]
  20994. // ,[DIId]
  20995. // ,[VisaClient]
  20996. // ,[VisaPrice]
  20997. // ,[VisaCurrency]
  20998. // ,[IsThird]
  20999. // ,[PassengerType]
  21000. // ,[VisaNumber]
  21001. // ,[VisaFreeNumber]
  21002. // ,[CreateUserId]
  21003. // ,[CreateTime]
  21004. // ,[DeleteTime]
  21005. // ,[DeleteUserId]
  21006. // ,[Remark]
  21007. // ,[IsDel]
  21008. // ,[visaDescription])
  21009. // VALUES
  21010. // ({0},{1},'{2}',{3},{4}
  21011. //,{5},{6},{7},{8},{9}
  21012. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  21013. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  21014. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  21015. //);
  21016. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  21017. // }
  21018. // return Ok(JsonView(true, "操作成功!"));
  21019. // }
  21020. /// <summary>
  21021. /// 123132123
  21022. /// </summary>
  21023. /// <param name="_dto"></param>
  21024. /// <returns></returns>
  21025. [HttpPost]
  21026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21027. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21028. {
  21029. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21030. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  21031. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  21032. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21033. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  21034. dicDetail.Add(789, 1034);
  21035. dicDetail.Add(790, 1035);
  21036. dicDetail.Add(791, 1036);
  21037. dicDetail.Add(792, 1037);
  21038. dicDetail.Add(793, 1038);
  21039. dicDetail.Add(794, 1039);
  21040. dicDetail.Add(795, 1040);
  21041. dicDetail.Add(796, 1041);
  21042. dicDetail.Add(797, 1042);
  21043. dicDetail.Add(798, 1043);
  21044. dicDetail.Add(801, 1044);
  21045. dicDetail.Add(802, 1045);
  21046. dicDetail.Add(803, 1046);
  21047. Dictionary<int, int> dic = new Dictionary<int, int>();
  21048. dic.Add(806, 1027);
  21049. dic.Add(807, 1028);
  21050. dic.Add(808, 1029);
  21051. dic.Add(809, 1030);
  21052. dic.Add(810, 1031);
  21053. dic.Add(811, 1032);
  21054. dic.Add(812, 1033);
  21055. foreach (var item in list_visa)
  21056. {
  21057. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  21058. temp.Coefficient = item.coefficient;
  21059. DateTime dtCrt;
  21060. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  21061. if (b1)
  21062. {
  21063. temp.CreateTime = dtCrt;
  21064. }
  21065. else
  21066. {
  21067. temp.CreateTime = DateTime.Now;
  21068. }
  21069. temp.CreateUserId = item.Operators;
  21070. temp.DeleteTime = "";
  21071. temp.DeleteUserId = 0;
  21072. temp.DiId = int.Parse(item.DIID);
  21073. temp.FilePath = item.FilePath;
  21074. temp.IsDel = item.IsDel;
  21075. temp.Price = item.Price;
  21076. temp.PriceCount = 1;
  21077. temp.PriceCurrency = item.Currency;
  21078. int detailId = 0;
  21079. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  21080. {
  21081. detailId = dicDetail[item.PriceTypeDetail];
  21082. }
  21083. temp.PriceDetailType = detailId;
  21084. temp.PriceDt = DateTime.Now;
  21085. temp.PriceName = item.PriceName;
  21086. temp.PriceSum = item.Price;
  21087. int tid = 0;
  21088. if (dic.ContainsKey(item.PriceType))
  21089. {
  21090. tid = dic[item.PriceType];
  21091. }
  21092. temp.PriceType = tid;
  21093. temp.Remark = item.Remark;
  21094. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  21095. }
  21096. return Ok(JsonView(true, "操作成功!"));
  21097. }
  21098. [HttpPost]
  21099. public IActionResult TimeTest()
  21100. {
  21101. var jw = JsonView(false, "error");
  21102. _sqlSugar.BeginTran();
  21103. try
  21104. {
  21105. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  21106. .Select(x => new Crm_NewClientData
  21107. {
  21108. Id = x.Id,
  21109. Client = x.Client,
  21110. Contact = x.Contact,
  21111. Location = x.Location,
  21112. })
  21113. .ToList();
  21114. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  21115. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  21116. Stopwatch stopwatch = new Stopwatch();
  21117. // 开始计时
  21118. stopwatch.Start();
  21119. foreach (var item in clientList)
  21120. {
  21121. EncryptionProcessor.DecryptProperties(item);
  21122. }
  21123. stopwatch.Stop();
  21124. jw.Code = 200;
  21125. jw.Data = stopwatch.ElapsedMilliseconds;
  21126. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  21127. }
  21128. catch (Exception ex)
  21129. {
  21130. jw.Code = 400;
  21131. jw.Msg = ex.Message;
  21132. }
  21133. return Ok(jw);
  21134. }
  21135. }
  21136. }