GroupsController.cs 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462
  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. /// 团组增减款项操作 自动审核test
  4373. /// </summary>
  4374. /// <param name="groupId"></param>
  4375. /// <param name="dataId"></param>
  4376. /// <returns></returns>
  4377. [HttpPost]
  4378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4379. public async Task<IActionResult> DecreaseFeeAutomaticAudit(int groupId,int dataId)
  4380. {
  4381. //自动审核
  4382. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, groupId, dataId);
  4383. return Ok(autoAdit);
  4384. }
  4385. /// <summary>
  4386. /// 团组增减款项操作 删除
  4387. /// </summary>
  4388. /// <param name="dto"></param>
  4389. /// <returns></returns>
  4390. [HttpPost]
  4391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4392. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4393. {
  4394. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4395. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4396. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4397. if (res.Code == 0)
  4398. {
  4399. return Ok(JsonView(true, "删除成功!"));
  4400. }
  4401. return Ok(JsonView(false, "删除失败!"));
  4402. }
  4403. /// <summary>
  4404. /// 根据团组增减款项Id查询
  4405. /// </summary>
  4406. /// <param name="dto"></param>
  4407. /// <returns></returns>
  4408. [HttpPost]
  4409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4410. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4411. {
  4412. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4413. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4414. }
  4415. /// <summary>
  4416. /// 查询供应商名称
  4417. /// </summary>
  4418. /// <param name="dto"></param>
  4419. /// <returns></returns>
  4420. [HttpPost]
  4421. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4422. {
  4423. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4424. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4425. ?? new List<Grp_DecreasePayments>();
  4426. dbResult = dbResult.Distinct(new
  4427. ProductComparer()).ToList();
  4428. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4429. {
  4430. x.Id,
  4431. x.SupplierAddress,
  4432. x.SupplierArea,
  4433. x.SupplierContact,
  4434. x.SupplierContactNumber,
  4435. x.SupplierEmail,
  4436. x.SupplierName,
  4437. x.SupplierSocialAccount,
  4438. x.SupplierTypeId,
  4439. }).ToList());
  4440. return Ok(jw);
  4441. }
  4442. /// <summary>
  4443. /// 团组增减款项 OTA匹配
  4444. /// </summary>
  4445. /// <param name="file"></param>
  4446. /// <returns></returns>
  4447. [HttpPost]
  4448. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4449. {
  4450. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4451. string fileName = file.FileName;
  4452. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4453. {
  4454. return Ok(JsonView(false, "请上传Excel文件!"));
  4455. }
  4456. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4457. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4458. if (!Directory.Exists(path))
  4459. {
  4460. Directory.CreateDirectory(path);
  4461. }
  4462. var filePath = @$"{path}/{fileName}";
  4463. //保存文件
  4464. using (FileStream fs = System.IO.File.Create(filePath))
  4465. {
  4466. file.CopyTo(fs);
  4467. fs.Flush();
  4468. }
  4469. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4470. //读取ExcelFile
  4471. DataTable dt = ConvertExcelToDataTable(filePath);
  4472. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4473. dt.TableName = "TB";
  4474. //修改table列名
  4475. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4476. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4477. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4478. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4479. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4480. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4481. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4482. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4483. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4484. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4485. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4486. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4487. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4488. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4489. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4490. var otaOrderNos = new List<string>();
  4491. foreach (DataRow item in dt.Rows)
  4492. {
  4493. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4494. }
  4495. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4496. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4497. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4498. .Select((dp, di) => new
  4499. {
  4500. dp.PriceName,
  4501. dp.OTAOrderNo,
  4502. dp.FeeTotal,
  4503. di.TeamName,
  4504. })
  4505. .ToListAsync();
  4506. foreach (DataRow item in dt.Rows)
  4507. {
  4508. var otaOrderNo = item["OTAOrderNo"].ToString();
  4509. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4510. if (oaData == null) continue;
  4511. item["GroupName"] = oaData.TeamName;
  4512. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4513. }
  4514. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4515. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4516. List<DataTable> datas = new List<DataTable>();
  4517. datas.Add(dt);
  4518. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4519. return Ok(JsonView(true, "操作成功", new { url = url }));
  4520. }
  4521. #region
  4522. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4523. {
  4524. // 创建Workbook对象
  4525. Workbook workbook = new Workbook(excelFilePath);
  4526. // 获取第一个工作表
  4527. Worksheet worksheet = workbook.Worksheets[0];
  4528. // 将工作表转换为DataTable
  4529. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4530. return dataTable;
  4531. }
  4532. #endregion
  4533. #endregion
  4534. #region 文件上传、删除
  4535. /// <summary>
  4536. /// region 文件上传 可以带参数
  4537. /// </summary>
  4538. /// <param name="file"></param>
  4539. /// <returns></returns>
  4540. [HttpPost]
  4541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4542. public async Task<IActionResult> UploadProject(IFormFile file)
  4543. {
  4544. //var TypeName = Request.Headers["TypeName"].ToString();
  4545. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4546. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4547. ////文件名称
  4548. //string projectFileName = file.FileName;
  4549. ////上传的文件的路径
  4550. //string filePath = $"{fileDir}/{projectFileName}";
  4551. //if (TypeName == "A")//A代表团组增减款项
  4552. //{
  4553. // filePath = fileDir + $@"\团组增减款项相关文件";
  4554. // if (!Directory.Exists(filePath))
  4555. // {
  4556. // Directory.CreateDirectory(filePath);
  4557. // }
  4558. // //上传的文件的路径
  4559. // filePath += $@"\{projectFileName}";
  4560. //}
  4561. //else if (TypeName == "B")//B代表商邀相关文件
  4562. //{
  4563. // //上传的文件的路径
  4564. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4565. // if (!Directory.Exists(filePath))
  4566. // {
  4567. // Directory.CreateDirectory(filePath);
  4568. // }
  4569. // //上传的文件的路径
  4570. // filePath = $@"\{projectFileName}";
  4571. //}
  4572. //try
  4573. //{
  4574. // using (FileStream fs = System.IO.File.Create(filePath))
  4575. // {
  4576. // file.CopyTo(fs);
  4577. // fs.Flush();
  4578. // }
  4579. //}
  4580. //catch (Exception ex)
  4581. //{
  4582. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4583. //}
  4584. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4585. try
  4586. {
  4587. var TypeName = Request.Headers["TypeName"].ToString();
  4588. if (file != null)
  4589. {
  4590. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4591. //文件名称
  4592. string projectFileName = file.FileName;
  4593. //上传的文件的路径
  4594. string filePath = $"{fileDir}/{projectFileName}";
  4595. if (TypeName == "A")//A代表团组增减款项
  4596. {
  4597. if (!Directory.Exists(fileDir))
  4598. {
  4599. Directory.CreateDirectory(fileDir);
  4600. }
  4601. //上传的文件的路径
  4602. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4603. }
  4604. else if (TypeName == "B")//B代表商邀相关文件
  4605. {
  4606. if (!Directory.Exists(fileDir))
  4607. {
  4608. Directory.CreateDirectory(fileDir);
  4609. }
  4610. //上传的文件的路径
  4611. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4612. }
  4613. using (FileStream fs = System.IO.File.Create(filePath))
  4614. {
  4615. file.CopyTo(fs);
  4616. fs.Flush();
  4617. }
  4618. return Ok(JsonView(true, "上传成功!", projectFileName));
  4619. }
  4620. else
  4621. {
  4622. return Ok(JsonView(false, "上传失败!"));
  4623. }
  4624. }
  4625. catch (Exception ex)
  4626. {
  4627. return Ok(JsonView(false, "程序错误!"));
  4628. }
  4629. }
  4630. /// <summary>
  4631. /// 删除指定文件
  4632. /// </summary>
  4633. /// <param name="dto"></param>
  4634. /// <returns></returns>
  4635. [HttpPost]
  4636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4637. public async Task<IActionResult> DelFile(DelFileDto dto)
  4638. {
  4639. try
  4640. {
  4641. var TypeName = Request.Headers["TypeName"].ToString();
  4642. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4643. string filePath = "";
  4644. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4645. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4646. int id = 0;
  4647. if (TypeName == "A")
  4648. {
  4649. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4650. // 删除该文件
  4651. System.IO.File.Delete(filePath);
  4652. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4653. .Where(a => a.Id == dto.Id)
  4654. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4655. .ExecuteCommandAsync();
  4656. }
  4657. else if (TypeName == "B")
  4658. {
  4659. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4660. // 删除该文件
  4661. System.IO.File.Delete(filePath);
  4662. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4663. if (info != null)
  4664. {
  4665. string[] files = new string[] { };
  4666. if (!string.IsNullOrEmpty(info.Attachment))
  4667. {
  4668. try
  4669. {
  4670. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4671. }
  4672. catch (Exception)
  4673. {
  4674. files = new List<string>() { info.Attachment }.ToArray();
  4675. }
  4676. }
  4677. if (files.Length > 0)
  4678. {
  4679. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4680. string filePath2 = string.Empty;
  4681. if (files1.Length > 0)
  4682. {
  4683. filePath2 = JsonConvert.SerializeObject(files1);
  4684. }
  4685. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4686. .Where(a => a.Id == dto.Id)
  4687. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4688. .ExecuteCommandAsync();
  4689. }
  4690. }
  4691. }
  4692. if (id != 0)
  4693. {
  4694. return Ok(JsonView(true, "成功!"));
  4695. }
  4696. else
  4697. {
  4698. return Ok(JsonView(false, "失败!"));
  4699. }
  4700. }
  4701. catch (Exception ex)
  4702. {
  4703. return Ok(JsonView(false, "程序错误!"));
  4704. throw;
  4705. }
  4706. }
  4707. /// <summary>
  4708. /// 文件上传多个文件 可以带参数
  4709. /// </summary>
  4710. /// <param name="files"></param>
  4711. /// <returns></returns>
  4712. [HttpPost]
  4713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4714. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4715. {
  4716. try
  4717. {
  4718. var TypeName = Request.Headers["TypeName"].ToString();
  4719. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4720. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4721. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4722. var filePahts = new List<string>();
  4723. foreach (var file in files)
  4724. {
  4725. //文件名称
  4726. string projectFileName = file.FileName;
  4727. //上传的文件的路径
  4728. string filePath = $"{fileDir}/{projectFileName}";
  4729. if (TypeName == "A")//A代表团组增减款项
  4730. {
  4731. if (!Directory.Exists(fileDir))
  4732. {
  4733. Directory.CreateDirectory(fileDir);
  4734. }
  4735. //上传的文件的路径
  4736. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4737. }
  4738. else if (TypeName == "B")//B代表商邀相关文件
  4739. {
  4740. if (!Directory.Exists(fileDir))
  4741. {
  4742. Directory.CreateDirectory(fileDir);
  4743. }
  4744. //上传的文件的路径
  4745. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4746. }
  4747. using (FileStream fs = System.IO.File.Create(filePath))
  4748. {
  4749. file.CopyTo(fs);
  4750. fs.Flush();
  4751. }
  4752. filePahts.Add(projectFileName);
  4753. }
  4754. return Ok(JsonView(true, "上传成功!", filePahts));
  4755. }
  4756. catch (Exception ex)
  4757. {
  4758. return Ok(JsonView(false, "程序错误!"));
  4759. }
  4760. }
  4761. #endregion
  4762. #region 商邀费用录入
  4763. /// <summary>
  4764. /// 根据团组Id查询商邀费用列表
  4765. /// </summary>
  4766. /// <param name="dto"></param>
  4767. /// <returns></returns>
  4768. [HttpPost]
  4769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4770. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4771. {
  4772. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4773. if (groupData.Code != 0)
  4774. {
  4775. return Ok(JsonView(false, groupData.Msg));
  4776. }
  4777. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4778. }
  4779. /// <summary>
  4780. /// 商邀费用列表
  4781. /// 下载文件
  4782. /// </summary>
  4783. /// <param name="id"></param>
  4784. /// <returns></returns>
  4785. [HttpGet("{id}")]
  4786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4787. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4788. {
  4789. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4790. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4791. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4792. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4793. var filePaths = new List<string>();
  4794. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4795. try
  4796. {
  4797. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4798. }
  4799. catch (Exception ex)
  4800. {
  4801. filePaths.Add(info.Attachment);
  4802. }
  4803. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4804. for (int i = 0; i < filePaths.Count; i++)
  4805. {
  4806. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4807. }
  4808. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4809. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4810. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4811. {
  4812. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4813. {
  4814. foreach (string filePath in filePaths)
  4815. {
  4816. if (System.IO.File.Exists(filePath))
  4817. {
  4818. // 获取文件名
  4819. string fileName = Path.GetFileName(filePath);
  4820. // 将文件添加到ZIP归档中
  4821. zipArchive.CreateEntryFromFile(filePath, fileName);
  4822. }
  4823. }
  4824. }
  4825. }
  4826. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4827. }
  4828. /// <summary>
  4829. /// 商邀费用 Info Page 基础数据源
  4830. /// </summary>
  4831. /// <returns></returns>
  4832. [HttpPost]
  4833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4834. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4835. {
  4836. try
  4837. {
  4838. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4839. if (groupData.Code != 0)
  4840. {
  4841. return Ok(JsonView(false, groupData.Msg));
  4842. }
  4843. return Ok(JsonView(true, "操作成功", groupData.Data));
  4844. }
  4845. catch (Exception ex)
  4846. {
  4847. return Ok(JsonView(false, ex.Message));
  4848. throw;
  4849. }
  4850. }
  4851. /// <summary>
  4852. /// 根据商邀费用ID查询C表和商邀费用数据
  4853. /// </summary>
  4854. /// <param name="dto"></param>
  4855. /// <returns></returns>
  4856. [HttpPost]
  4857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4858. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4859. {
  4860. try
  4861. {
  4862. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4863. if (groupData.Code != 0)
  4864. {
  4865. return Ok(JsonView(false, groupData.Msg));
  4866. }
  4867. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4868. }
  4869. catch (Exception ex)
  4870. {
  4871. return Ok(JsonView(false, ex.Message));
  4872. throw;
  4873. }
  4874. }
  4875. /// <summary>
  4876. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4877. /// </summary>
  4878. /// <param name="dto"></param>
  4879. /// <returns></returns>
  4880. [HttpPost]
  4881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4882. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4883. {
  4884. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4885. if (groupData.Code != 0)
  4886. {
  4887. return Ok(JsonView(false, groupData.Msg));
  4888. }
  4889. #region 应用推送
  4890. try
  4891. {
  4892. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4893. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4894. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4895. //2024-10-21 新增LZ UID
  4896. var userIds = new List<int>() { 21 };
  4897. string title = $"系统通知";
  4898. string content = "";
  4899. var diId = dto.DiId;
  4900. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4901. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4902. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4903. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4904. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4905. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4906. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4907. }
  4908. catch (Exception ex)
  4909. {
  4910. }
  4911. #endregion
  4912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4913. }
  4914. /// <summary>
  4915. /// 商邀删除
  4916. /// </summary>
  4917. /// <param name="dto"></param>
  4918. /// <returns></returns>
  4919. [HttpPost]
  4920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4921. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4922. {
  4923. try
  4924. {
  4925. _sqlSugar.BeginTran();
  4926. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4927. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4928. {
  4929. IsDel = 1,
  4930. DeleteUserId = dto.DeleteUserId,
  4931. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4932. })
  4933. .Where(it => it.Id == dto.Id)
  4934. .ExecuteCommand();
  4935. if (res1 > 0)
  4936. {
  4937. int _diId = 0;
  4938. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4939. if (_ioaInfo != null)
  4940. {
  4941. _diId = _ioaInfo.DiId;
  4942. }
  4943. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4944. .SetColumns(a => new Grp_CreditCardPayment()
  4945. {
  4946. IsDel = 1,
  4947. DeleteUserId = dto.DeleteUserId,
  4948. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4949. })
  4950. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4951. .ExecuteCommand();
  4952. if (res2 > 0)
  4953. {
  4954. _sqlSugar.CommitTran();
  4955. return Ok(JsonView(true, "删除成功!"));
  4956. }
  4957. }
  4958. _sqlSugar.RollbackTran();
  4959. return Ok(JsonView(false, "删除失败"));
  4960. }
  4961. catch (Exception ex)
  4962. {
  4963. _sqlSugar.RollbackTran();
  4964. return Ok(JsonView(false, ex.Message));
  4965. }
  4966. }
  4967. #endregion
  4968. #region 票据上传
  4969. /// <summary>
  4970. /// 团组模块文件上传
  4971. /// </summary>
  4972. /// <param name="dto"></param>
  4973. /// <returns></returns>
  4974. [HttpPost]
  4975. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4976. {
  4977. var jw = JsonView(false);
  4978. long M = 1024 * 1024;
  4979. if (dto.Files == null || dto.Files.Count == 0)
  4980. {
  4981. jw.Msg = "无文件信息!";
  4982. return Ok(jw);
  4983. }
  4984. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4985. {
  4986. jw.Msg = "文件大小超过20M!";
  4987. return Ok(jw);
  4988. }
  4989. //var nameSp = dto.File.FileName.Split(".");
  4990. //if (nameSp.Length < 2)
  4991. //{
  4992. // jw.Msg = "拓展名称有误!";
  4993. // return Ok(jw);
  4994. //}
  4995. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4996. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4997. //{
  4998. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4999. // return Ok(jw);
  5000. //}
  5001. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5002. if (Ctable == null)
  5003. {
  5004. jw.Msg = "Ctable指向有误!";
  5005. return Ok(jw);
  5006. }
  5007. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5008. if (groupInfo == null)
  5009. {
  5010. jw.Msg = "团组信息不存在!";
  5011. return Ok(jw);
  5012. }
  5013. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5014. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5015. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5016. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5017. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5018. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5019. try
  5020. {
  5021. if (!Directory.Exists(fileBase))
  5022. {
  5023. Directory.CreateDirectory(fileBase);
  5024. }
  5025. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5026. foreach (var fileStream in dto.Files)
  5027. {
  5028. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5029. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5030. {
  5031. Cid = dto.Cid,
  5032. CreateTime = DateTime.Now,
  5033. CreateUserId = dto.Userid,
  5034. Ctable = dto.Ctable,
  5035. Diid = dto.Diid,
  5036. IsDel = 0,
  5037. FilePath = saveFilePath,
  5038. FileName = fileStream.FileName
  5039. };
  5040. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5041. {
  5042. fileStream.CopyTo(fs);
  5043. fs.Flush();
  5044. }
  5045. saveArr.Add(file);
  5046. }
  5047. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5048. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5049. jw = JsonView(true, "保存成功!", new
  5050. {
  5051. count = addResult,
  5052. filesName = saveArr.Select(x => x.FileName)
  5053. });
  5054. }
  5055. catch (Exception ex)
  5056. {
  5057. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5058. {
  5059. count = 0,
  5060. filesName = new string[0],
  5061. });
  5062. }
  5063. return Ok(jw);
  5064. }
  5065. /// <summary>
  5066. /// 查询各模块已保存文件
  5067. /// </summary>
  5068. /// <param name="dto"></param>
  5069. /// <returns></returns>
  5070. [HttpPost]
  5071. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5072. {
  5073. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5074. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5075. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5076. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5077. {
  5078. expression = Expressionable.Create<Grp_GroupModelFile>()
  5079. .And(x => visaIds.Contains(x.CreateUserId));
  5080. }
  5081. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5082. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5083. .Where(expression.ToExpression())
  5084. .ToList();
  5085. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5086. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5087. {
  5088. x.FileName,
  5089. x.Id,
  5090. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5091. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5092. })));
  5093. }
  5094. /// <summary>
  5095. /// 下载该团组下的所有文件
  5096. /// </summary>
  5097. /// <param name="dto"></param>
  5098. /// <returns></returns>
  5099. [HttpPost]
  5100. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5101. {
  5102. var jw = JsonView(false);
  5103. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5104. if (groupInfo == null)
  5105. {
  5106. jw.Msg = "团组信息不存在!";
  5107. return Ok(jw);
  5108. }
  5109. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5110. var isModule = Convert.ToBoolean(dto.isModule);
  5111. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5112. IOOperatorHelper io = new IOOperatorHelper();
  5113. if (isModule)
  5114. {
  5115. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5116. foreach (var moduleArr in moduleGroup)
  5117. {
  5118. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5119. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5120. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5121. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5122. foreach (var item in moduleArr)
  5123. {
  5124. if (System.IO.File.Exists(item.FilePath))
  5125. {
  5126. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5127. {
  5128. byte[] bytes = new byte[fileStream.Length];
  5129. fileStream.Read(bytes, 0, bytes.Length);
  5130. fileStream.Close();
  5131. Stream stream = new MemoryStream(bytes);
  5132. chiZips.Add(item.FileName, stream);
  5133. }
  5134. }
  5135. }
  5136. if (chiZips.Count > 0)
  5137. {
  5138. var byts = io.ConvertZipStream(chiZips);
  5139. Stream stream = new MemoryStream(byts);
  5140. Zips.Add(key.Name + "_.zip", stream);
  5141. }
  5142. }
  5143. }
  5144. else
  5145. {
  5146. foreach (var item in dbQuery)
  5147. {
  5148. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5149. {
  5150. byte[] bytes = new byte[fileStream.Length];
  5151. fileStream.Read(bytes, 0, bytes.Length);
  5152. fileStream.Close();
  5153. Stream stream = new MemoryStream(bytes);
  5154. while (Zips.Keys.Contains(item.FileName))
  5155. {
  5156. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5157. }
  5158. Zips.Add(item.FileName, stream);
  5159. }
  5160. }
  5161. }
  5162. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5163. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5164. if (Zips.Count > 0)
  5165. {
  5166. var byts = io.ConvertZipStream(Zips);
  5167. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5168. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5169. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5170. }
  5171. else
  5172. {
  5173. jw.Msg = "暂无生成文件!";
  5174. }
  5175. return Ok(jw);
  5176. }
  5177. /// <summary>
  5178. /// 下载该团组下此模块的所有文件
  5179. /// </summary>
  5180. /// <param name="dto"></param>
  5181. /// <returns></returns>
  5182. [HttpPost]
  5183. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5184. {
  5185. var jw = JsonView(false);
  5186. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5187. if (groupInfo == null)
  5188. {
  5189. jw.Msg = "团组信息不存在!";
  5190. return Ok(jw);
  5191. }
  5192. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5193. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5194. && x.IsDel == 0);
  5195. if (key == null)
  5196. {
  5197. jw.Msg = "Ctable指向错误!";
  5198. return Ok(jw);
  5199. }
  5200. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5201. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5202. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5203. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5204. IOOperatorHelper io = new IOOperatorHelper();
  5205. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5206. foreach (var item in dbQuery)
  5207. {
  5208. if (System.IO.File.Exists(item.FilePath))
  5209. {
  5210. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5211. {
  5212. byte[] bytes = new byte[fileStream.Length];
  5213. fileStream.Read(bytes, 0, bytes.Length);
  5214. fileStream.Close();
  5215. Stream stream = new MemoryStream(bytes);
  5216. while (Zips.Keys.Contains(item.FileName))
  5217. {
  5218. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5219. }
  5220. Zips.Add(item.FileName, stream);
  5221. }
  5222. }
  5223. }
  5224. if (Zips.Count > 0)
  5225. {
  5226. var byts = io.ConvertZipStream(Zips);
  5227. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5228. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5229. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5230. }
  5231. else
  5232. {
  5233. jw.Msg = "暂无生成文件!";
  5234. }
  5235. return Ok(jw);
  5236. }
  5237. /// <summary>
  5238. /// 删除该团组下的指定文件
  5239. /// </summary>
  5240. /// <param name="dto"></param>
  5241. /// <returns></returns>
  5242. [HttpPost]
  5243. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5244. {
  5245. var jw = JsonView(false);
  5246. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5247. if (sing == null)
  5248. {
  5249. jw.Msg = "暂无";
  5250. return Ok(jw);
  5251. }
  5252. if (System.IO.File.Exists(sing.FilePath))
  5253. {
  5254. try
  5255. {
  5256. System.IO.File.Delete(sing.FilePath);
  5257. }
  5258. catch (Exception ex)
  5259. {
  5260. jw.Msg = "删除失败!" + ex.Message;
  5261. return Ok(jw);
  5262. }
  5263. }
  5264. sing.IsDel = 1;
  5265. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5266. sing.DeleteUserId = dto.UserId;
  5267. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5268. jw = JsonView(true, "删除成功!");
  5269. return Ok(jw);
  5270. }
  5271. #endregion
  5272. #region 共享文件上传
  5273. /// <summary>
  5274. /// 共享文件数据初始化
  5275. /// </summary>
  5276. /// <returns></returns>
  5277. [HttpGet]
  5278. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  5279. {
  5280. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  5281. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5282. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5283. .Select(x => x.Id)
  5284. .ToList()
  5285. .Contains(userid);
  5286. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5287. .Where(x => x.STid == 111 && x.IsDel == 0)
  5288. .Select(x => new
  5289. {
  5290. x.Name,
  5291. x.Id,
  5292. }).ToList();
  5293. if (isMarketingDepartment)
  5294. {
  5295. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5296. }
  5297. if (portType == 1)
  5298. {
  5299. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5300. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5301. .Where(x => x.IsDel == 0)
  5302. .OrderByDescending(x=> x.VisitDate )
  5303. .Select(x => new
  5304. {
  5305. x.TeamName,
  5306. x.Id,
  5307. x.CityId,
  5308. })
  5309. .ToList()
  5310. .Select(x=>
  5311. {
  5312. var provinceId = x.CityId;
  5313. var isDefualtVal = true;
  5314. if (provinceId > 0)
  5315. {
  5316. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5317. if (parentId != null)
  5318. {
  5319. isDefualtVal = false;
  5320. provinceId = (int)parentId;
  5321. }
  5322. }
  5323. if (isDefualtVal)
  5324. {
  5325. provinceId = 122; //默认四川
  5326. }
  5327. return new
  5328. {
  5329. x.TeamName,
  5330. x.Id,
  5331. provinceId,
  5332. };
  5333. })
  5334. .ToList();
  5335. return Ok(JsonView(true, "SUCCESS!", new
  5336. {
  5337. dropDownType,
  5338. dropDownGroupList,
  5339. isMarketingDepartment
  5340. }));
  5341. }
  5342. else if (portType == 2 || portType == 3)
  5343. {
  5344. return Ok(JsonView(true, "SUCCESS!", new
  5345. {
  5346. dropDownType,
  5347. isMarketingDepartment
  5348. }));
  5349. }
  5350. else
  5351. {
  5352. return Ok(JsonView(false, "portType有误!"));
  5353. }
  5354. }
  5355. /// <summary>
  5356. /// 共享文件上传
  5357. /// </summary>
  5358. /// <param name="dto"></param>
  5359. /// <returns></returns>
  5360. [HttpPost]
  5361. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5362. {
  5363. var isGroup = new List<int> { 1412 };
  5364. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5365. {
  5366. return Ok(JsonView(false, "该文件需要关联团组!"));
  5367. }
  5368. if (dto.Files == null || dto.Files.Count == 0)
  5369. {
  5370. return Ok(JsonView(false, "无文件信息!"));
  5371. }
  5372. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5373. {
  5374. return Ok(JsonView(false, "文件大小超过20M!"));
  5375. }
  5376. if (dto.Userid < 1)
  5377. {
  5378. return Ok(JsonView(false, "请传入有效的Userid!"));
  5379. }
  5380. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5381. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5382. .Select((u, j) => new
  5383. {
  5384. u.CnName,
  5385. UserId = u.Id,
  5386. j.JobName,
  5387. })
  5388. .First();
  5389. if (jobInfo == null)
  5390. {
  5391. return Ok(JsonView(false, "请传入有效的Userid!"));
  5392. }
  5393. List<string> commonFileExtensions = new List<string>
  5394. {
  5395. // 文本文件
  5396. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5397. // 图片文件
  5398. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5399. // 视频文件
  5400. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5401. // 音频文件
  5402. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5403. // 压缩文件
  5404. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5405. // 数据文件
  5406. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5407. };
  5408. try
  5409. {
  5410. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5411. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5412. commonFileExtensions.AddRange(settingExtend);
  5413. }
  5414. catch (Exception)
  5415. { }
  5416. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5417. if (setdata == null)
  5418. {
  5419. return Ok(JsonView(false, "请传入有效的FileType!"));
  5420. }
  5421. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5422. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5423. if (!Directory.Exists(winPath))
  5424. {
  5425. Directory.CreateDirectory(winPath);
  5426. }
  5427. foreach (var item in dto.Files)
  5428. {
  5429. var houzui = Path.GetExtension(item.FileName);
  5430. if (!commonFileExtensions.Contains(houzui))
  5431. {
  5432. return Ok(JsonView(false, "未知后缀名称!"));
  5433. }
  5434. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5435. var saveFilePath = winPath + fileName;
  5436. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5437. {
  5438. item.CopyTo(fs);
  5439. fs.Flush();
  5440. }
  5441. var fileDetail = new Grp_GroupShareFile()
  5442. {
  5443. CreateUserId = dto.Userid,
  5444. CreateTime = DateTime.Now,
  5445. UploadJob = jobInfo.JobName,
  5446. FileName = fileName,
  5447. FileType = dto.FileType,
  5448. Diid = dto.Diid,
  5449. FilePath = winPath + fileName,
  5450. };
  5451. insertList.Add(fileDetail);
  5452. }
  5453. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5454. return Ok(JsonView(true, "保存成功!"));
  5455. }
  5456. /// <summary>
  5457. /// 查询共享文件列表
  5458. /// </summary>
  5459. /// <param name="dto"></param>
  5460. /// <returns></returns>
  5461. [HttpPost]
  5462. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5463. {
  5464. var isGroup = new List<int> { 1412 };
  5465. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5466. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5467. .And(x => x.Diid == dto.Diid)
  5468. .And(x => x.FileType == dto.FileType)
  5469. .And(x => x.IsDel == 0)
  5470. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5471. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5472. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5473. int totalCount = 0;
  5474. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5475. .Where(queryExpression.ToExpression())
  5476. .OrderBy(x => x.UploadJob)
  5477. .Select(x => new
  5478. {
  5479. x.Id,
  5480. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5481. x.FileName,
  5482. x.FileType,
  5483. x.CreateTime,
  5484. })
  5485. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5486. return Ok(JsonView(true, "SUCCESS!", new
  5487. {
  5488. FileList = dbQuery,
  5489. dto.PageSize,
  5490. dto.PageIndex,
  5491. totalCount
  5492. }));
  5493. }
  5494. /// <summary>
  5495. /// 删除共享文件模块下的指定文件
  5496. /// </summary>
  5497. /// <param name="dto"></param>
  5498. /// <returns></returns>
  5499. [HttpPost]
  5500. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5501. {
  5502. var jw = JsonView(false);
  5503. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5504. if (sing == null)
  5505. {
  5506. jw.Msg = "暂无文件信息!";
  5507. return Ok(jw);
  5508. }
  5509. if (sing.CreateUserId != dto.UserId)
  5510. {
  5511. jw.Msg = "只能删除自己上传的文件!";
  5512. return Ok(jw);
  5513. }
  5514. if (System.IO.File.Exists(sing.FilePath))
  5515. {
  5516. try
  5517. {
  5518. System.IO.File.Delete(sing.FilePath);
  5519. }
  5520. catch (Exception ex)
  5521. {
  5522. jw.Msg = "删除失败!" + ex.Message;
  5523. return Ok(jw);
  5524. }
  5525. }
  5526. sing.IsDel = 1;
  5527. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5528. sing.DeleteUserId = dto.UserId;
  5529. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5530. jw = JsonView(true, "删除成功!");
  5531. return Ok(jw);
  5532. }
  5533. #endregion
  5534. #region 团组英文资料
  5535. /// <summary>
  5536. /// 查询团组英文所有资料
  5537. /// </summary>
  5538. /// <param name="dto"></param>
  5539. /// <returns></returns>
  5540. [HttpPost]
  5541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5542. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5543. {
  5544. try
  5545. {
  5546. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5547. if (groupData.Code != 0)
  5548. {
  5549. return Ok(JsonView(false, groupData.Msg));
  5550. }
  5551. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5552. }
  5553. catch (Exception ex)
  5554. {
  5555. return Ok(JsonView(false, "程序错误!"));
  5556. throw;
  5557. }
  5558. }
  5559. /// <summary>
  5560. /// 团组英文资料操作(Status:1.新增,2.修改)
  5561. /// </summary>
  5562. /// <param name="dto"></param>
  5563. /// <returns></returns>
  5564. [HttpPost]
  5565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5566. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5567. {
  5568. try
  5569. {
  5570. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5571. if (groupData.Code != 0)
  5572. {
  5573. return Ok(JsonView(false, groupData.Msg));
  5574. }
  5575. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5576. }
  5577. catch (Exception ex)
  5578. {
  5579. return Ok(JsonView(false, "程序错误!"));
  5580. throw;
  5581. }
  5582. }
  5583. /// <summary>
  5584. /// 团组英文资料Id查询数据
  5585. /// </summary>
  5586. /// <param name="dto"></param>
  5587. /// <returns></returns>
  5588. [HttpPost]
  5589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5590. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5591. {
  5592. try
  5593. {
  5594. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5595. if (_DelegationEnData != null)
  5596. {
  5597. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5598. }
  5599. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5600. }
  5601. catch (Exception ex)
  5602. {
  5603. return Ok(JsonView(false, "程序错误!"));
  5604. throw;
  5605. }
  5606. }
  5607. /// <summary>
  5608. /// 团组英文资料删除
  5609. /// </summary>
  5610. /// <param name="dto"></param>
  5611. /// <returns></returns>
  5612. [HttpPost]
  5613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5614. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5615. {
  5616. try
  5617. {
  5618. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5619. if (!res)
  5620. {
  5621. return Ok(JsonView(false, "删除失败"));
  5622. }
  5623. return Ok(JsonView(true, "删除成功!"));
  5624. }
  5625. catch (Exception ex)
  5626. {
  5627. return Ok(JsonView(false, "程序错误!"));
  5628. throw;
  5629. }
  5630. }
  5631. #endregion
  5632. #region 导出邀请函
  5633. /// <summary>
  5634. /// 导出邀请函页面初始化
  5635. /// </summary>
  5636. /// <param name="dto"></param>
  5637. /// <returns></returns>
  5638. [HttpPost]
  5639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5640. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5641. {
  5642. try
  5643. {
  5644. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5645. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5646. if (dto.DiId == 0)
  5647. {
  5648. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5649. }
  5650. else
  5651. {
  5652. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5653. }
  5654. return Ok(JsonView(true, "查询成功!", new
  5655. {
  5656. deleClient = crm_Deles,
  5657. delegations = grp_Delegations
  5658. }));
  5659. }
  5660. catch (Exception ex)
  5661. {
  5662. return Ok(JsonView(false, "程序错误!"));
  5663. throw;
  5664. }
  5665. }
  5666. /// <summary>
  5667. /// 导出邀请函
  5668. /// </summary>
  5669. /// <param name="dto"></param>
  5670. /// <returns></returns>
  5671. [HttpPost]
  5672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5673. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5674. {
  5675. #region 参数验证
  5676. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5677. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5678. #endregion
  5679. try
  5680. {
  5681. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5682. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5683. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5684. From Grp_TourClientList tcl
  5685. Left Join
  5686. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5687. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5688. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5689. From Crm_DeleClient dc
  5690. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5691. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5692. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5693. Where dc.IsDel = 0) temp
  5694. On temp.DcId =tcl.ClientId
  5695. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5696. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5697. List<string> texts = new List<string>();
  5698. if (datas.Count != 0)
  5699. {
  5700. foreach (TourClientListDetailsView item in datas)
  5701. {
  5702. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5703. {
  5704. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5705. }
  5706. else
  5707. {
  5708. string name = item.LastName + item.FirstName;
  5709. texts.Add(name);
  5710. }
  5711. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5712. {
  5713. if (!transDic.ContainsKey(item.Job))
  5714. {
  5715. texts.Add(item.Job);
  5716. }
  5717. }
  5718. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5719. {
  5720. texts.Add(item.CompanyFullName);
  5721. }
  5722. }
  5723. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5724. if (transData.Count > 0)
  5725. {
  5726. foreach (TranslateResult item in transData)
  5727. {
  5728. if (!transDic.ContainsKey(item.Query))
  5729. {
  5730. transDic.Add(item.Query, item.Translation);
  5731. }
  5732. }
  5733. }
  5734. List<GuestList> list = new List<GuestList>();
  5735. foreach (TourClientListDetailsView dele in datas)
  5736. {
  5737. GuestList guestList = new GuestList();
  5738. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5739. {
  5740. guestList.Name = dele.Pinyin;
  5741. }
  5742. else
  5743. {
  5744. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5745. guestList.Name = Name;
  5746. }
  5747. if (dele.Sex == 0)
  5748. {
  5749. guestList.Sex = "Male";
  5750. }
  5751. else if (dele.Sex == 1)
  5752. {
  5753. guestList.Sex = "Female";
  5754. }
  5755. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5756. if (!string.IsNullOrEmpty(dele.Job))
  5757. {
  5758. guestList.Job = dele.Job;
  5759. }
  5760. list.Add(guestList);
  5761. }
  5762. //载入模板
  5763. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5764. DocumentBuilder builder = new DocumentBuilder(doc);
  5765. //获取word里所有表格
  5766. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5767. //获取所填表格的序数
  5768. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5769. var rowStart = tableOne.Rows[0]; //获取第1行
  5770. //循环赋值
  5771. for (int i = 0; i < list.Count; i++)
  5772. {
  5773. builder.MoveToCell(0, i + 1, 0, 0);
  5774. builder.Write(list[i].Name.ToString());
  5775. builder.MoveToCell(0, i + 1, 1, 0);
  5776. builder.Write(list[i].Sex.ToString());
  5777. builder.MoveToCell(0, i + 1, 2, 0);
  5778. builder.Write(list[i].DOB.ToString());
  5779. builder.MoveToCell(0, i + 1, 3, 0);
  5780. builder.Write(list[i].Job.ToString());
  5781. }
  5782. //删除多余行
  5783. while (tableOne.Rows.Count > list.Count + 1)
  5784. {
  5785. tableOne.Rows.RemoveAt(list.Count + 1);
  5786. }
  5787. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5788. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5789. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5790. doc.Save(filePath);
  5791. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5792. return Ok(JsonView(true, "操作成功!", Url));
  5793. }
  5794. else
  5795. {
  5796. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5797. }
  5798. }
  5799. catch (Exception ex)
  5800. {
  5801. return Ok(JsonView(false, ex.Message));
  5802. throw;
  5803. }
  5804. }
  5805. #endregion
  5806. #region 团组经理模块 出入境费用
  5807. /// <summary>
  5808. /// 团组模块 - 出入境费用 - 省份基础数据源
  5809. /// </summary>
  5810. /// <returns></returns>
  5811. [HttpGet]
  5812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5813. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5814. {
  5815. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5816. }
  5817. /// <summary>
  5818. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5819. /// </summary>
  5820. /// <returns></returns>
  5821. [HttpPost]
  5822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5823. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5824. {
  5825. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5826. var groupNamFirst = groupNameData.FirstOrDefault();
  5827. //SetDataInfoView
  5828. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5829. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5830. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5831. //验证城市归属并给默认值
  5832. int provinceId = 122;
  5833. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5834. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5835. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5836. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5837. return Ok(JsonView(true, "查询成功!", new
  5838. {
  5839. GroupNameData = groupNameData,
  5840. CurrencyData = _CurrencyData,
  5841. WordTypeData = wordTypeData,
  5842. ExcelTypeData = excelTypeData,
  5843. CurrencyInit = _currencyInfos,
  5844. ViewPermissionData = viewPermissionData
  5845. }));
  5846. }
  5847. /// <summary>
  5848. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5849. /// </summary>
  5850. /// <returns></returns>
  5851. [HttpGet("{provinceId}")]
  5852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5853. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5854. {
  5855. //验证城市归属并给默认值
  5856. if (provinceId < 1) provinceId = 122;
  5857. /*
  5858. * 122 四川
  5859. * 108 贵州
  5860. * 103 重庆
  5861. * 132 云南
  5862. */
  5863. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5864. return Ok(JsonView(true, "查询成功!", new
  5865. {
  5866. WordTypeData = wordTypeData,
  5867. ExcelTypeData = excelTypeData,
  5868. }));
  5869. }
  5870. /// <summary>
  5871. /// 团组模块 - 出入境费用
  5872. /// 实时汇率 tips
  5873. /// 签证费用 tips
  5874. /// 机票费用 tips
  5875. /// </summary>
  5876. /// <returns></returns>
  5877. [HttpPost]
  5878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5879. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5880. {
  5881. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5882. //默认币种显示
  5883. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5884. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5885. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5886. return Ok(JsonView(true, "查询成功!", new
  5887. {
  5888. //GroupNameData = groupNameData.Data,
  5889. visaData = visaData.Data,
  5890. airData = airData.Data,
  5891. reteInfos = reteInfos
  5892. }));
  5893. }
  5894. /// <summary>
  5895. /// 团组模块 - 出入境费用 - Info
  5896. /// </summary>
  5897. /// <returns></returns>
  5898. [HttpPost]
  5899. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5901. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5902. {
  5903. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5904. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5905. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5906. }
  5907. /// <summary>
  5908. /// 团组模块 - 出入境费用 - 设置view权限
  5909. /// </summary>
  5910. /// <returns></returns>
  5911. [HttpPost]
  5912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5913. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5914. {
  5915. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5916. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5917. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5918. var permissions = new List<Grp_EnterExitCostPermission>();
  5919. foreach (var userId in dto.UserIds)
  5920. {
  5921. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5922. }
  5923. if (permissions.Any())
  5924. {
  5925. _sqlSugar.BeginTran();
  5926. try
  5927. {
  5928. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5929. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5930. if (result < 1)
  5931. {
  5932. _sqlSugar.RollbackTran();
  5933. return Ok(JsonView(false));
  5934. }
  5935. }
  5936. catch (Exception ex)
  5937. {
  5938. _sqlSugar.RollbackTran();
  5939. return Ok(JsonView(false, ex.Message));
  5940. }
  5941. _sqlSugar.CommitTran();
  5942. return Ok(JsonView(true));
  5943. }
  5944. return Ok(JsonView(false));
  5945. }
  5946. /// <summary>
  5947. /// 团组模块 - 出入境费用 - Add And Update
  5948. /// </summary>
  5949. /// <returns></returns>
  5950. [HttpPost]
  5951. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5953. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5954. {
  5955. try
  5956. {
  5957. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5958. if (dto.DayOtherPriceData.Any())
  5959. {
  5960. var inserList = dto.DayOtherPriceData
  5961. .Where(x => x.Id == 0)
  5962. .Select(x => new Grp_DayOtherPrice
  5963. {
  5964. Cost = x.Cost,
  5965. Id = x.Id,
  5966. CreateTime = DateTime.Now,
  5967. CreateUserId = dto.UserId,
  5968. Currency = x.Currency,
  5969. Diid = x.DiId,
  5970. Index = x.Index,
  5971. IsDel = 0,
  5972. SetDataId = x.SetDataId,
  5973. SubTotal = x.SubTotal,
  5974. Remark = x.Remark
  5975. })
  5976. .ToList();
  5977. var updateList = dto.DayOtherPriceData
  5978. .Where(x => x.Id != 0)
  5979. .Select(x => new Grp_DayOtherPrice
  5980. {
  5981. Cost = x.Cost,
  5982. Id = x.Id,
  5983. CreateTime = DateTime.Now,
  5984. CreateUserId = dto.UserId,
  5985. Currency = x.Currency,
  5986. Diid = x.DiId,
  5987. Index = x.Index,
  5988. IsDel = 0,
  5989. SetDataId = x.SetDataId,
  5990. SubTotal = x.SubTotal,
  5991. Remark = x.Remark
  5992. })
  5993. .ToList();
  5994. //添加
  5995. _sqlSugar.BeginTran();
  5996. if (inserList.Any())
  5997. {
  5998. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5999. }
  6000. if (updateList.Any())
  6001. {
  6002. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6003. }
  6004. _sqlSugar.CommitTran();
  6005. }
  6006. if (data.Code != 0)
  6007. {
  6008. return Ok(JsonView(false, data.Msg));
  6009. }
  6010. //生成默认文件pdf并且通知人员
  6011. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6012. {
  6013. DiId = dto.DiId,
  6014. ExportType = 1,
  6015. SubTypeId = 1005
  6016. }, "pdf");
  6017. //发送通知
  6018. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6019. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6020. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6021. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6022. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6023. //汇率信息记录
  6024. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6025. return Ok(JsonView(true, data.Msg, data.Data));
  6026. }
  6027. catch (Exception ex)
  6028. {
  6029. return Ok(JsonView(false, ex.Message));
  6030. }
  6031. }
  6032. /// <summary>
  6033. /// 团组模块 - 出入境费用 - Confirm 费用
  6034. /// </summary>
  6035. /// <returns></returns>
  6036. [HttpPost]
  6037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6038. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6039. {
  6040. //TODO:测试完毕需把对应的用户ID更改
  6041. //1、数据表添加字段
  6042. //2、更改字段接口()
  6043. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6044. //3、确认成功 给财务发送消息
  6045. if (_view.Code == 200)
  6046. {
  6047. if (dto.Type == 1)
  6048. {
  6049. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6050. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6051. }
  6052. }
  6053. return Ok(_view);
  6054. }
  6055. /// <summary>
  6056. /// 团组模块 - 出入境费用 - File download
  6057. /// </summary>
  6058. /// <param name="dto"></param>
  6059. /// <returns></returns>
  6060. [HttpPost]
  6061. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6063. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6064. {
  6065. try
  6066. {
  6067. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6068. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6069. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6070. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6071. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6072. 3 团组成员名单 1 团组成员名单", ""));
  6073. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6074. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6075. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6076. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6077. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6078. //数据源
  6079. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6080. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6081. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6082. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6083. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6084. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6085. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6086. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6087. .Select((x, a, b) => new
  6088. {
  6089. x.Index,
  6090. itemName = a.Name,
  6091. CurrencyStr = b.Name,
  6092. x.Cost,
  6093. x.SubTotal,
  6094. x.Remark
  6095. })
  6096. .OrderBy((x) => x.Index)
  6097. .ToList(); //其他款项费用
  6098. var peiceItemCurrencys = new List<string>();
  6099. if (_DayAndCosts.Any())
  6100. {
  6101. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6102. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6103. }
  6104. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6105. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6106. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6107. {
  6108. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6109. }
  6110. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6111. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6112. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6113. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6114. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6115. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6116. .Select((tcl, dc, cc) => new ClientInfo
  6117. {
  6118. LastName = dc.LastName,
  6119. FirstName = dc.FirstName,
  6120. Sex = dc.Sex,
  6121. Birthday = dc.BirthDay,
  6122. Company = cc.CompanyFullName,
  6123. Job = dc.Job
  6124. })
  6125. .ToList();
  6126. foreach (var item in DeleClientList)
  6127. {
  6128. EncryptionProcessor.DecryptProperties(item);
  6129. }
  6130. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6131. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6132. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6133. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6134. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6135. if (dto.ExportType == 1) //明细表
  6136. {
  6137. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6138. {
  6139. //获取模板
  6140. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6141. //载入模板
  6142. Document doc = new Document(tempPath);
  6143. DocumentBuilder builder = new DocumentBuilder(doc);
  6144. //利用键值对存放数据
  6145. Dictionary<string, string> dic = new Dictionary<string, string>();
  6146. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6147. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6148. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6149. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6150. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6151. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6152. //境内费用(其他费用)
  6153. if (_EnterExitCosts.ChoiceOne == 1)
  6154. {
  6155. string row1_1 = "";
  6156. if (_EnterExitCosts.Visa > 0)
  6157. {
  6158. //insidePayTotal += _EnterExitCosts.Visa;
  6159. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6160. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6161. //{
  6162. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6163. //}
  6164. }
  6165. string row1_2 = "";
  6166. if (_EnterExitCosts.YiMiao > 0)
  6167. {
  6168. //insidePayTotal += _EnterExitCosts.YiMiao;
  6169. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6170. }
  6171. if (_EnterExitCosts.HeSuan > 0)
  6172. {
  6173. //insidePayTotal += _EnterExitCosts.HeSuan;
  6174. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6175. }
  6176. if (_EnterExitCosts.Service > 0)
  6177. {
  6178. //insidePayTotal += _EnterExitCosts.Service;
  6179. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6180. }
  6181. string row1_3 = "";
  6182. if (_EnterExitCosts.Safe > 0)
  6183. {
  6184. //insidePayTotal += _EnterExitCosts.Safe;
  6185. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6186. }
  6187. if (_EnterExitCosts.Ticket > 0)
  6188. {
  6189. //insidePayTotal += _EnterExitCosts.Ticket;
  6190. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6191. }
  6192. string row1 = "";
  6193. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6194. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6195. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6196. row1 += $"备注:{_EnterExitCosts.Remark}";
  6197. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6198. dic.Add("Row1Str", row1);
  6199. }
  6200. string airTotalStr = string.Empty,
  6201. airPriceStr = string.Empty;
  6202. //经济舱
  6203. if (_EnterExitCosts.SumJJC == 1)
  6204. {
  6205. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6206. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6207. }
  6208. //公务舱
  6209. if (_EnterExitCosts.SumGWC == 1)
  6210. {
  6211. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6212. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6213. }
  6214. //头等舱
  6215. if (_EnterExitCosts.SumTDC == 1)
  6216. {
  6217. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6218. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6219. }
  6220. //汇率描述
  6221. string rateStr = "";
  6222. if (peiceItemCurrencyInfos.Any())
  6223. {
  6224. rateStr = "\r\n汇率描述:";
  6225. foreach (var item in peiceItemCurrencyInfos)
  6226. {
  6227. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6228. }
  6229. }
  6230. string twoItemRemark = "备注:";
  6231. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6232. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6233. dic.Add("AirTotalStr", airTotalStr);
  6234. dic.Add("AirPriceStr", airPriceStr);
  6235. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6236. dic.Add("TwoItemRemark", twoItemRemark);
  6237. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6238. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6239. int table1Row = 0,
  6240. table2Row = 0,
  6241. table3Row = 0,
  6242. table4Row = 0,
  6243. table5Row = 0;
  6244. //住宿费
  6245. if (_EnterExitCosts.ChoiceThree == 1)
  6246. {
  6247. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6248. table1Row = dac1.Count;
  6249. #region 填充word表格内容
  6250. for (int i = 0; i < dac1.Count; i++)
  6251. {
  6252. Grp_DayAndCost dac = dac1[i];
  6253. if (dac == null) continue;
  6254. builder.MoveToCell(0, i, 0, 0);
  6255. builder.Write("第" + dac.Days.ToString() + "晚:");
  6256. builder.MoveToCell(0, i, 1, 0);
  6257. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6258. //builder.Write(dac.Place == null ? "" : dac.Place);
  6259. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6260. builder.MoveToCell(0, i, 2, 0);
  6261. builder.Write("费用标准:");
  6262. string curr = "";
  6263. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6264. if (currData != null)
  6265. {
  6266. curr = currData.Name;
  6267. }
  6268. builder.MoveToCell(0, i, 3, 0);
  6269. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6270. builder.MoveToCell(0, i, 4, 0);
  6271. builder.Write("费用小计:");
  6272. builder.MoveToCell(0, i, 5, 0);
  6273. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6274. }
  6275. #endregion
  6276. }
  6277. else dic.Add("SubZS", "0.00");
  6278. //删除多余行
  6279. while (table1.Rows.Count > table1Row)
  6280. {
  6281. table1.Rows.RemoveAt(table1Row);
  6282. }
  6283. //伙食费
  6284. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6285. if (_EnterExitCosts.ChoiceFour == 1)
  6286. {
  6287. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6288. table2Row = dac2.Count;
  6289. #region 填充word表格内容
  6290. for (int i = 0; i < dac2.Count; i++)
  6291. {
  6292. Grp_DayAndCost dac = dac2[i];
  6293. if (dac == null) continue;
  6294. builder.MoveToCell(1, i, 0, 0);
  6295. builder.Write("第" + dac.Days.ToString() + "天:");
  6296. builder.MoveToCell(1, i, 1, 0);
  6297. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6298. builder.MoveToCell(1, i, 2, 0);
  6299. builder.Write("费用标准:");
  6300. string curr = "";
  6301. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6302. if (currData != null)
  6303. {
  6304. curr = currData.Name;
  6305. }
  6306. builder.MoveToCell(1, i, 3, 0);
  6307. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6308. builder.MoveToCell(1, i, 4, 0);
  6309. builder.Write("费用小计:");
  6310. builder.MoveToCell(1, i, 5, 0);
  6311. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6312. }
  6313. #endregion
  6314. }
  6315. else dic.Add("SubHS", "0.00");
  6316. //删除多余行
  6317. while (table2.Rows.Count > table2Row)
  6318. {
  6319. table2.Rows.RemoveAt(table2Row);
  6320. }
  6321. //公杂费
  6322. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6323. if (_EnterExitCosts.ChoiceFive == 1)
  6324. {
  6325. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6326. table3Row = dac3.Count;
  6327. #region 填充word表格内容
  6328. for (int i = 0; i < dac3.Count; i++)
  6329. {
  6330. Grp_DayAndCost dac = dac3[i];
  6331. if (dac == null) continue;
  6332. builder.MoveToCell(2, i, 0, 0);
  6333. builder.Write("第" + dac.Days.ToString() + "天:");
  6334. builder.MoveToCell(2, i, 1, 0);
  6335. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6336. builder.MoveToCell(2, i, 2, 0);
  6337. builder.Write("费用标准:");
  6338. string curr = "";
  6339. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6340. if (currData != null)
  6341. {
  6342. curr = currData.Name;
  6343. }
  6344. builder.MoveToCell(2, i, 3, 0);
  6345. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6346. builder.MoveToCell(2, i, 4, 0);
  6347. builder.Write("费用小计:");
  6348. builder.MoveToCell(2, i, 5, 0);
  6349. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6350. }
  6351. //删除多余行
  6352. while (table3.Rows.Count > table3Row)
  6353. {
  6354. table3.Rows.RemoveAt(table3Row);
  6355. }
  6356. #endregion
  6357. }
  6358. else dic.Add("SubGZF", "0.00");
  6359. //删除多余行
  6360. while (table3.Rows.Count > table3Row)
  6361. {
  6362. table3.Rows.RemoveAt(table3Row);
  6363. }
  6364. //培训费
  6365. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6366. if (_EnterExitCosts.ChoiceSix == 1)
  6367. {
  6368. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6369. dic.Add("SubPX", pxStr);
  6370. table4Row = dac4.Count;
  6371. #region 填充word表格内容
  6372. for (int i = 0; i < dac4.Count; i++)
  6373. {
  6374. Grp_DayAndCost dac = dac4[i];
  6375. if (dac == null) continue;
  6376. builder.MoveToCell(3, i, 0, 0);
  6377. builder.Write("第" + dac.Days.ToString() + "天:");
  6378. builder.MoveToCell(3, i, 1, 0);
  6379. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6380. builder.MoveToCell(3, i, 2, 0);
  6381. builder.Write("费用标准:");
  6382. string curr = "";
  6383. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6384. if (currData != null)
  6385. {
  6386. curr = currData.Name;
  6387. }
  6388. builder.MoveToCell(3, i, 3, 0);
  6389. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6390. builder.MoveToCell(3, i, 4, 0);
  6391. builder.Write("费用小计:");
  6392. builder.MoveToCell(3, i, 5, 0);
  6393. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6394. }
  6395. #endregion
  6396. }
  6397. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6398. //删除多余行
  6399. while (table4.Rows.Count > table4Row)
  6400. {
  6401. table4.Rows.RemoveAt(table4Row);
  6402. }
  6403. //其他费用
  6404. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6405. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6406. {
  6407. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6408. dic.Add("titleQi", qtStr);
  6409. table5Row = dac5.Count;
  6410. #region 填充word表格内容
  6411. for (int i = 0; i < dac5.Count; i++)
  6412. {
  6413. var dac = dac5[i];
  6414. if (dac == null) continue;
  6415. builder.MoveToCell(4, i, 0, 0);
  6416. builder.Write("第" + dac.Index.ToString() + "项:");
  6417. builder.MoveToCell(4, i, 1, 0);
  6418. builder.Write(dac.itemName);
  6419. builder.MoveToCell(4, i, 2, 0);
  6420. builder.Write("费用标准:");
  6421. builder.MoveToCell(4, i, 3, 0);
  6422. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6423. builder.MoveToCell(4, i, 4, 0);
  6424. builder.Write("费用小计:");
  6425. builder.MoveToCell(4, i, 5, 0);
  6426. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6427. builder.MoveToCell(4, i, 6, 0);
  6428. builder.Write("备注:");
  6429. builder.MoveToCell(4, i, 7, 0);
  6430. builder.Write(dac.Remark);
  6431. }
  6432. #endregion
  6433. }
  6434. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6435. //删除多余行
  6436. while (table5.Rows.Count > table5Row)
  6437. {
  6438. table5.Rows.RemoveAt(table5Row);
  6439. }
  6440. //加上其他费用
  6441. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6442. decimal subJJC = 0.00M,
  6443. subGWC = 0.00M,
  6444. subTDC = 0.00M;
  6445. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6446. string totalLabel = string.Format("全部费用总计:");
  6447. //经济舱
  6448. if (_EnterExitCosts.SumJJC == 1)
  6449. {
  6450. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6451. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6452. }
  6453. //公务舱
  6454. if (_EnterExitCosts.SumGWC == 1)
  6455. {
  6456. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6457. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6458. }
  6459. //头等舱
  6460. if (_EnterExitCosts.SumTDC == 1)
  6461. {
  6462. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6463. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6464. }
  6465. //TotalLabel
  6466. dic.Add("TotalLabel", totalLabel);
  6467. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6468. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6469. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6470. #region 填充word模板书签内容
  6471. foreach (var key in dic.Keys)
  6472. {
  6473. Bookmark bookmark = doc.Range.Bookmarks[key];
  6474. if (bookmark != null)
  6475. {
  6476. builder.MoveToBookmark(key);
  6477. builder.Write(dic[key]);
  6478. }
  6479. }
  6480. #endregion
  6481. #region 设置页眉
  6482. string userLabel = string.Empty;
  6483. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6484. if (currUserInfo != null)
  6485. {
  6486. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6487. if (userInfo != null)
  6488. {
  6489. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6490. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6491. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6492. }
  6493. }
  6494. //设置页脚
  6495. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6496. #endregion
  6497. //文件名
  6498. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6499. AsposeHelper.removewatermark_v2180();
  6500. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6501. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6502. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6503. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6504. }
  6505. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6506. {
  6507. //获取模板
  6508. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6509. //载入模板
  6510. Document doc = new Document(tempPath);
  6511. DocumentBuilder builder = new DocumentBuilder(doc);
  6512. Dictionary<string, string> dic = new Dictionary<string, string>();
  6513. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6514. {
  6515. List<string> list = new List<string>();
  6516. try
  6517. {
  6518. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6519. foreach (var item in spilitArr)
  6520. {
  6521. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6522. var depCode = spDotandEmpty[2].Substring(0, 3);
  6523. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6524. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6525. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6526. list.Add(depName);
  6527. list.Add(arrName);
  6528. }
  6529. list = list.Distinct().ToList();
  6530. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6531. }
  6532. catch (Exception)
  6533. {
  6534. dic.Add("ReturnCode", "行程录入不正确!");
  6535. }
  6536. }
  6537. else
  6538. {
  6539. dic.Add("ReturnCode", "未录入行程!");
  6540. }
  6541. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6542. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6543. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6544. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6545. {
  6546. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6547. dic.Add("Day", sp.Days.ToString());
  6548. }
  6549. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6550. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6551. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6552. //dic.Add("Names", Names);
  6553. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6554. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6555. decimal dac1totalPrice = 0.00M;
  6556. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6557. foreach (var dac in dac1)
  6558. {
  6559. if (dac.SubTotal == 0.00M)
  6560. {
  6561. continue;
  6562. }
  6563. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6564. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6565. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6566. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6567. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6568. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6569. builder.Write(currency);//币种
  6570. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6571. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6572. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6573. builder.Write("");//人数
  6574. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6575. builder.Write("");//天数
  6576. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6577. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6578. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6579. decimal rate = 0.00M;
  6580. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6581. builder.Write(rate.ToString("#0.0000"));//汇率
  6582. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6583. decimal rbmPrice = dac.SubTotal;
  6584. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6585. accommodationStartIndex++;
  6586. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6587. }
  6588. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6589. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6590. {
  6591. table1.Rows.RemoveAt(i - 1);
  6592. foodandotherStartIndex--;
  6593. }
  6594. if (dac2.Count == dac3.Count)//国家 币种 金额
  6595. {
  6596. for (int i = 0; i < dac2.Count; i++)
  6597. {
  6598. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6599. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6600. }
  6601. }
  6602. decimal dac2totalPrice = 0.00M;
  6603. foreach (var dac in dac2)
  6604. {
  6605. if (dac.SubTotal == 0)
  6606. {
  6607. continue;
  6608. }
  6609. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6610. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6611. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6612. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6613. builder.Write(currency);//币种
  6614. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6615. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6616. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6617. builder.Write("");//人数
  6618. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6619. builder.Write("");//天数
  6620. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6621. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6622. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6623. decimal rate = 0.00M;
  6624. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6625. builder.Write(rate.ToString("#0.0000"));//汇率
  6626. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6627. decimal rbmPrice = dac.SubTotal;
  6628. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6629. foodandotherStartIndex++;
  6630. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6631. }
  6632. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6633. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6634. {
  6635. table1.Rows.RemoveAt(i - 1);
  6636. }
  6637. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6638. string otherFeeStr = "";
  6639. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6640. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6641. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6642. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6643. foreach (var otherInfo in dac5)
  6644. {
  6645. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6646. }
  6647. #endregion
  6648. if (otherFeeStr.Length > 0)
  6649. {
  6650. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6651. otherFeeStr = $"({otherFeeStr})";
  6652. dic.Add("OtherFeeStr", otherFeeStr);
  6653. }
  6654. //总计
  6655. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6656. //国际旅费
  6657. string outsideAir = string.Empty;
  6658. string allPriceAir = string.Empty;
  6659. if (_EnterExitCosts.SumJJC == 1)
  6660. {
  6661. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6662. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6663. }
  6664. if (_EnterExitCosts.SumGWC == 1)
  6665. {
  6666. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6667. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6668. }
  6669. if (_EnterExitCosts.SumTDC == 1)
  6670. {
  6671. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6672. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6673. }
  6674. dic.Add("InTravelPrice", $"({outsideAir})");
  6675. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6676. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6677. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6678. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6679. foreach (var key in dic.Keys)
  6680. {
  6681. builder.MoveToBookmark(key);
  6682. builder.Write(dic[key]);
  6683. }
  6684. //模板文件名
  6685. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6686. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6687. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6688. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6689. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6690. }
  6691. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6692. {
  6693. //获取模板
  6694. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6695. //载入模板
  6696. WorkbookDesigner designer = new WorkbookDesigner();
  6697. designer.Workbook = new Workbook(tempPath);
  6698. Dictionary<string, string> dic = new Dictionary<string, string>();
  6699. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6700. {
  6701. List<string> list = new List<string>();
  6702. try
  6703. {
  6704. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6705. foreach (var item in spilitArr)
  6706. {
  6707. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6708. var depCode = spDotandEmpty[2].Substring(0, 3);
  6709. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6710. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6711. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6712. list.Add(depName);
  6713. list.Add(arrName);
  6714. }
  6715. list = list.Distinct().ToList();
  6716. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6717. }
  6718. catch (Exception)
  6719. {
  6720. dic.Add("ReturnCode", "行程录入不正确!");
  6721. }
  6722. }
  6723. else
  6724. {
  6725. dic.Add("ReturnCode", "未录入行程!");
  6726. }
  6727. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6728. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6729. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6730. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6731. {
  6732. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6733. dic.Add("Day", sp.Days.ToString());
  6734. }
  6735. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6736. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6737. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6738. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6739. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6740. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6741. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6742. designer.SetDataSource("Name", Names);
  6743. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6744. designer.SetDataSource("Day", dic["Day"] + "天");
  6745. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6746. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6747. int startIndex = 10;
  6748. const int startIndexcopy = 10;
  6749. if (dac2.Count == dac3.Count)//国家 币种 金额
  6750. {
  6751. for (int i = 0; i < dac2.Count; i++)
  6752. {
  6753. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6754. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6755. }
  6756. }
  6757. DataTable dtdac1 = new DataTable();
  6758. List<string> place = new List<string>();
  6759. dtdac1.Columns.AddRange(new DataColumn[] {
  6760. new DataColumn(){ ColumnName = "city"},
  6761. new DataColumn(){ ColumnName = "curr"},
  6762. new DataColumn(){ ColumnName = "criterion"},
  6763. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6764. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6765. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6766. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6767. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6768. });
  6769. DataTable dtdac2 = new DataTable();
  6770. dtdac2.Columns.AddRange(new DataColumn[] {
  6771. new DataColumn(){ ColumnName = "city"},
  6772. new DataColumn(){ ColumnName = "curr"},
  6773. new DataColumn(){ ColumnName = "criterion"},
  6774. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6775. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6776. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6777. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6778. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6779. });
  6780. dtdac1.TableName = "tb1";
  6781. dtdac2.TableName = "tb2";
  6782. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6783. foreach (var item in dac1)
  6784. {
  6785. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6786. if (place.Contains(item.Place))
  6787. {
  6788. continue;
  6789. }
  6790. DataRow row = dtdac1.NewRow();
  6791. row["city"] = item.Place;
  6792. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6793. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6794. row["curr"] = currency;
  6795. row["rate"] = rate.ToString("#0.0000");
  6796. row["criterion"] = item.Cost.ToString("#0.00");
  6797. row["number"] = 1;
  6798. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6799. //row["costRMB"] = rbmPrice;
  6800. dtdac1.Rows.Add(row);
  6801. place.Add(item.Place);
  6802. }
  6803. place = new List<string>();
  6804. foreach (var item in dac2)
  6805. {
  6806. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6807. if (place.Contains(item.Place))
  6808. {
  6809. continue;
  6810. }
  6811. DataRow row = dtdac2.NewRow();
  6812. row["city"] = item.Place;
  6813. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6814. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6815. row["curr"] = currency;
  6816. row["rate"] = rate.ToString("#0.0000");
  6817. row["criterion"] = item.Cost.ToString("#0.00");
  6818. row["number"] = 1;
  6819. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6820. //row["cost"] = item.SubTotal;
  6821. //row["costRMB"] = rbmPrice;
  6822. dtdac2.Rows.Add(row);
  6823. place.Add(item.Place);
  6824. //dac2totalPrice += rbmPrice;
  6825. }
  6826. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6827. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6828. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6829. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6830. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6831. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6832. string cell4Str1 = string.Empty;
  6833. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6834. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6835. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6836. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6837. string cellStr = $" 5.其他费用(";
  6838. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6839. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6840. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6841. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6842. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6843. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6844. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6845. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6846. foreach (var otherInfo in dac5)
  6847. {
  6848. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6849. }
  6850. #endregion
  6851. if (cellStr.Length > 8)
  6852. {
  6853. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6854. }
  6855. cellStr += ")";
  6856. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6857. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6858. decimal pxFee = dac4.Sum(it => it.Cost);
  6859. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6860. string celllastStr1 = "";
  6861. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6862. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6863. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6864. celllastStr1 += $",国际旅费 元";
  6865. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6866. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6867. designer.SetDataSource("cell4Str", cell4Str);
  6868. designer.SetDataSource("cellStr", cellStr);
  6869. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6870. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6871. designer.SetDataSource("celllastStr", celllastStr);
  6872. Workbook wb = designer.Workbook;
  6873. var sheet = wb.Worksheets[0];
  6874. //绑定datatable数据集
  6875. designer.SetDataSource(dtdac1);
  6876. designer.SetDataSource(dtdac2);
  6877. designer.Process();
  6878. var rowStart = dtdac1.Rows.Count;
  6879. while (rowStart > 0)
  6880. {
  6881. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6882. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6883. startIndex++;
  6884. rowStart--;
  6885. }
  6886. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6887. startIndex += 1; //总计行
  6888. rowStart = dtdac2.Rows.Count;
  6889. while (rowStart > 0)
  6890. {
  6891. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6892. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6893. startIndex++;
  6894. rowStart--;
  6895. }
  6896. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6897. wb.CalculateFormula(true);
  6898. //模板文件名
  6899. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6900. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6901. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6902. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6903. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6904. }
  6905. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6906. {
  6907. //获取模板
  6908. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6909. //载入模板
  6910. Document doc = new Document(tempPath);
  6911. DocumentBuilder builder = new DocumentBuilder(doc);
  6912. Dictionary<string, string> dic = new Dictionary<string, string>();
  6913. dic.Add("GroupName", _DelegationInfo.TeamName);
  6914. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6915. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6916. string missionLeaderJob = "";//负责人job
  6917. //int groupNumber = 0; //团人数
  6918. if (DeleClientList.Count > 0)
  6919. {
  6920. missionLeader = DeleClientList[0]?.Name ?? "";
  6921. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6922. }
  6923. dic.Add("MissionLeader", missionLeader); //团负责人
  6924. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6925. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6926. #region MyRegion
  6927. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6928. //{
  6929. // List<string> list = new List<string>();
  6930. // try
  6931. // {
  6932. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6933. // foreach (var item in spilitArr)
  6934. // {
  6935. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6936. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6937. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6938. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6939. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6940. // list.Add(depName);
  6941. // list.Add(arrName);
  6942. // }
  6943. // list = list.Distinct().ToList();
  6944. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6945. // }
  6946. // catch (Exception)
  6947. // {
  6948. // dic.Add("ReturnCode", "行程录入不正确!");
  6949. // }
  6950. //}
  6951. //else
  6952. //{
  6953. // dic.Add("ReturnCode", "未录入行程!");
  6954. //}
  6955. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6956. dic.Add("ReturnCode", string.Join("、", countrys));
  6957. #endregion
  6958. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6959. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6960. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6961. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6962. //{
  6963. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6964. // dic.Add("Day", sp.Days.ToString());
  6965. //}
  6966. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6967. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6968. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6969. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6970. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6971. //培训人员名单
  6972. int cultivateRowIndex = 7;
  6973. foreach (var item in DeleClientList)
  6974. {
  6975. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6976. builder.Write(item.Name);
  6977. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6978. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6979. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6980. string birthDay = "";
  6981. if (item.Birthday != null)
  6982. {
  6983. DateTime dt = Convert.ToDateTime(item.Birthday);
  6984. birthDay = $"{dt.Year}.{dt.Month}";
  6985. }
  6986. builder.Write(birthDay);
  6987. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6988. builder.Write(item.Company);
  6989. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6990. builder.Write(item.Job);
  6991. cultivateRowIndex++;
  6992. }
  6993. //删除多余行
  6994. //cultivateRowIndex -= 2;
  6995. int delRows = 10 + 7 - cultivateRowIndex;
  6996. if (delRows > 0)
  6997. {
  6998. for (int i = 0; i < delRows; i++)
  6999. {
  7000. table1.Rows.RemoveAt(cultivateRowIndex);
  7001. //cultivateRowIndex++;
  7002. }
  7003. }
  7004. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7005. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7006. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7007. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7008. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7009. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7010. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7011. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7012. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7013. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7014. //其他费用
  7015. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7016. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7017. //其他费用合计
  7018. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7019. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7020. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7021. //公务舱合计
  7022. //国际旅费
  7023. //string outsideJJ = "";
  7024. //string allPriceJJ = "";
  7025. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7026. {
  7027. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7028. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7029. }
  7030. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7031. {
  7032. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7033. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7034. }
  7035. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7036. {
  7037. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7038. dic.Add("AirFeeTotal", airFeeTotalStr);
  7039. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7040. dic.Add("FeeTotal", feeTotalStr);
  7041. }
  7042. foreach (var key in dic.Keys)
  7043. {
  7044. builder.MoveToBookmark(key);
  7045. builder.Write(dic[key]);
  7046. }
  7047. //模板文件名
  7048. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7049. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7050. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7051. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7052. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7053. }
  7054. }
  7055. else if (dto.ExportType == 2) //表格
  7056. {
  7057. //利用键值对存放数据
  7058. Dictionary<string, string> dic = new Dictionary<string, string>();
  7059. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7060. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7061. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7062. dic.Add("Day", sp.Days.ToString());
  7063. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7064. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7065. {
  7066. //获取模板
  7067. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7068. //载入模板
  7069. Document doc = new Document(tempPath);
  7070. DocumentBuilder builder = new DocumentBuilder(doc);
  7071. dic.Add("TeamName", _DelegationInfo.TeamName);
  7072. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7073. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7074. string missionLeaderName = "",
  7075. missionLeaderJob = "";
  7076. if (DeleClientList.Count > 0)
  7077. {
  7078. missionLeaderName = DeleClientList[0].Name;
  7079. missionLeaderJob = DeleClientList[0].Job;
  7080. }
  7081. dic.Add("MissionLeaderName", missionLeaderName);
  7082. dic.Add("MissionLeaderJob", missionLeaderJob);
  7083. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7084. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7085. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7086. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7087. int rowCount = 10;//总人数行
  7088. int startRowIndex = 7; //起始行
  7089. for (int i = 0; i < DeleClientList.Count; i++)
  7090. {
  7091. builder.MoveToCell(0, startRowIndex, 0, 0);
  7092. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7093. builder.MoveToCell(0, startRowIndex, 1, 0);
  7094. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7095. builder.Write(sex);//性别
  7096. builder.MoveToCell(0, startRowIndex, 2, 0);
  7097. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7098. builder.MoveToCell(0, startRowIndex, 3, 0);
  7099. builder.Write(DeleClientList[i].Company);//工作单位
  7100. builder.MoveToCell(0, startRowIndex, 4, 0);
  7101. builder.Write(DeleClientList[i].Job);//职务及级别
  7102. builder.MoveToCell(0, startRowIndex, 5, 0);
  7103. builder.Write("");//人员属性
  7104. builder.MoveToCell(0, startRowIndex, 6, 0);
  7105. builder.Write("");//上次出国时间
  7106. startRowIndex++;
  7107. }
  7108. int nullRow = rowCount - DeleClientList.Count;//空行
  7109. for (int i = 0; i < nullRow; i++)
  7110. {
  7111. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7112. }
  7113. foreach (var key in dic.Keys)
  7114. {
  7115. builder.MoveToBookmark(key);
  7116. builder.Write(dic[key]);
  7117. }
  7118. //模板文件名
  7119. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7120. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7121. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7122. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7123. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7124. }
  7125. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7126. {
  7127. //获取模板
  7128. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7129. //载入模板
  7130. Document doc = new Document(tempPath);
  7131. DocumentBuilder builder = new DocumentBuilder(doc);
  7132. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7133. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7134. dic.Add("Names", Names);
  7135. int accommodationRows = 12;
  7136. //int foodandotherRows = 12;
  7137. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7138. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7139. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7140. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7141. int accommodationStartIndex = 6;
  7142. decimal dac1totalPrice = 0.00M;
  7143. foreach (var dac in dac1)
  7144. {
  7145. if (dac.SubTotal == 0)
  7146. {
  7147. continue;
  7148. }
  7149. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7150. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7151. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7152. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7153. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7154. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7155. builder.Write(currency);//币种
  7156. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7157. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7158. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7159. builder.Write("");//人数
  7160. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7161. builder.Write("");//天数
  7162. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7163. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7164. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7165. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7166. builder.Write(rate.ToString("#0.0000"));//汇率
  7167. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7168. decimal rbmPrice = rate * dac.SubTotal;
  7169. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7170. accommodationStartIndex++;
  7171. dac1totalPrice += rbmPrice;
  7172. }
  7173. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7174. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7175. builder.Write("小计");
  7176. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7177. builder.Write(dac1totalPrice.ToString("#0.00"));
  7178. accommodationStartIndex++;
  7179. int nullRow = accommodationRows - dac1.Count;
  7180. //删除空行
  7181. //if (nullRow > 0)
  7182. //{
  7183. // int rowIndex = accommodationStartIndex;
  7184. // for (int i = 0; i < nullRow; i++)
  7185. // {
  7186. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7187. // row.Remove();
  7188. // rowIndex++;
  7189. // }
  7190. //}
  7191. if (dac2.Count == dac3.Count)//国家 币种 金额
  7192. {
  7193. for (int i = 0; i < dac2.Count; i++)
  7194. {
  7195. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7196. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7197. }
  7198. }
  7199. int foodandotherStartIndex = 19;//
  7200. decimal dac2totalPrice = 0.00M;
  7201. foreach (var dac in dac2)
  7202. {
  7203. if (dac.SubTotal == 0)
  7204. {
  7205. continue;
  7206. }
  7207. //foodandotherStartIndex = 12;
  7208. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7209. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7210. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7211. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7212. builder.Write(currency);//币种
  7213. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7214. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7215. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7216. builder.Write("");//人数
  7217. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7218. builder.Write("");//天数
  7219. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7220. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7221. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7222. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7223. builder.Write(rate.ToString("#0.0000"));//汇率
  7224. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7225. decimal rbmPrice = rate * dac.SubTotal;
  7226. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7227. foodandotherStartIndex++;
  7228. dac2totalPrice += rbmPrice;
  7229. }
  7230. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7231. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7232. //删除空行
  7233. //if (dac2.Count < foodandotherRows)
  7234. //{
  7235. // while (table2.Rows.Count > dac2.Count)
  7236. // {
  7237. // table2.Rows.RemoveAt(dac2.Count);
  7238. // }
  7239. //}
  7240. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7241. string otherFeeStr = "";
  7242. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7243. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7244. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7245. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7246. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7247. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7248. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7249. foreach (var otherInfo in dac5)
  7250. {
  7251. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7252. }
  7253. #endregion
  7254. if (otherFeeStr.Length > 0)
  7255. {
  7256. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7257. otherFeeStr = $"({otherFeeStr})";
  7258. dic.Add("OtherFeeStr", otherFeeStr);
  7259. }
  7260. foreach (var key in dic.Keys)
  7261. {
  7262. builder.MoveToBookmark(key);
  7263. builder.Write(dic[key]);
  7264. }
  7265. //模板文件名
  7266. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7267. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7268. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7269. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7270. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7271. }
  7272. }
  7273. else if (dto.ExportType == 3)
  7274. {
  7275. if (dto.SubTypeId == 1) //团组成员名单
  7276. {
  7277. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7278. //获取模板
  7279. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7280. //载入模板
  7281. Document doc = new Document(tempPath);
  7282. DocumentBuilder builder = new DocumentBuilder(doc);
  7283. //获取word里所有表格
  7284. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7285. //获取所填表格的序数
  7286. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7287. var rowStart = tableOne.Rows[0]; //获取第1行
  7288. //循环赋值
  7289. for (int i = 0; i < DeleClientList.Count; i++)
  7290. {
  7291. builder.MoveToCell(0, i + 1, 0, 0);
  7292. builder.Write(DeleClientList[i].Name);
  7293. builder.MoveToCell(0, i + 1, 1, 0);
  7294. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7295. builder.Write(sex);
  7296. builder.MoveToCell(0, i + 1, 2, 0);
  7297. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7298. builder.MoveToCell(0, i + 1, 3, 0);
  7299. builder.Write(DeleClientList[i].Company);
  7300. builder.MoveToCell(0, i + 1, 4, 0);
  7301. builder.Write(DeleClientList[i].Job);
  7302. }
  7303. //删除多余行
  7304. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7305. {
  7306. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7307. }
  7308. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7309. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7310. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7311. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7312. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7313. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7314. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7315. }
  7316. }
  7317. return Ok(JsonView(400, "操作失败!", ""));
  7318. }
  7319. catch (Exception ex)
  7320. {
  7321. return Ok(JsonView(400, ex.Message, ""));
  7322. }
  7323. }
  7324. /// <summary>
  7325. /// 获取三公费用标准city
  7326. /// </summary>
  7327. /// <param name="placeData"></param>
  7328. /// <param name="nationalTravelFeeId"></param>
  7329. /// <returns></returns>
  7330. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7331. {
  7332. string _city = string.Empty;
  7333. if (placeData.Count < 1) return _city;
  7334. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7335. if (data == null) return _city;
  7336. string country = data.Country;
  7337. string city = data.City;
  7338. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7339. else _city = city;
  7340. return _city;
  7341. }
  7342. ///// <summary>
  7343. ///// 团组模块 - 出入境费用 - 明细表导出
  7344. ///// </summary>
  7345. ///// <returns></returns>
  7346. //[HttpPost]
  7347. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7348. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7349. //{
  7350. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7351. // if (data.Code != 0)
  7352. // {
  7353. // return Ok(JsonView(false, data.Msg));
  7354. // }
  7355. // return Ok(JsonView(true, data.Msg, data.Data));
  7356. //}
  7357. /// <summary>
  7358. /// 团组模块 - 出入境费用 - 一键清空
  7359. /// </summary>
  7360. /// <returns></returns>
  7361. [HttpPost]
  7362. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7364. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7365. {
  7366. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7367. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7368. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7369. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7370. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7371. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7372. .SetColumns(x => new Grp_DayOtherPrice
  7373. {
  7374. IsDel = 1,
  7375. DeleteUserId = dto.UserId,
  7376. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7377. })
  7378. .ExecuteCommandAsync();
  7379. if (_view.Code == 0)
  7380. {
  7381. return Ok(JsonView(true, "操作成功"));
  7382. }
  7383. return Ok(JsonView(false, "操作失败"));
  7384. }
  7385. /// <summary>
  7386. /// 团组模块 - 出入境费用 - 子项删除
  7387. /// </summary>
  7388. /// <returns></returns>
  7389. [HttpPost]
  7390. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7392. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7393. {
  7394. try
  7395. {
  7396. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7397. if (data.Code != 0)
  7398. {
  7399. return Ok(JsonView(false, data.Msg));
  7400. }
  7401. return Ok(JsonView(true, "操作成功!", data.Data));
  7402. }
  7403. catch (Exception ex)
  7404. {
  7405. return Ok(JsonView(false, ex.Message));
  7406. }
  7407. }
  7408. /// <summary>
  7409. /// 删除三公其他费用
  7410. /// </summary>
  7411. /// <param name="dto"></param>
  7412. /// <returns></returns>
  7413. [HttpPost]
  7414. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7415. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7416. {
  7417. var jw = JsonView(false, "删除失败!");
  7418. var data = new Grp_DayOtherPrice()
  7419. {
  7420. Id = dto.Id,
  7421. IsDel = 1,
  7422. DeleteUserId = dto.DeleteUserId,
  7423. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7424. };
  7425. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7426. if (del > 0)
  7427. {
  7428. jw.Code = 200;
  7429. jw.Msg = "删除成功!";
  7430. }
  7431. return Ok(jw);
  7432. }
  7433. /// <summary>
  7434. /// 团组模块 - 出入境国家费用标准 List
  7435. /// </summary>
  7436. /// <returns></returns>
  7437. [HttpPost]
  7438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7439. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7440. {
  7441. int provinceId = dto.ProvinceId;
  7442. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7443. var nftData = await _sqlSugar
  7444. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7445. JoinType.Left, ntf.Currency == sd1.Id,
  7446. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7447. JoinType.Left, ntf.ProvinceId == c.Id
  7448. ))
  7449. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7450. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7451. {
  7452. Id = ntf.Id,
  7453. ProvinceId = ntf.ProvinceId,
  7454. ProvinceName = c.Name_CN,
  7455. Continent = ntf.Continent,
  7456. Country = ntf.Country,
  7457. City = ntf.City,
  7458. Currency = ntf.Currency,
  7459. CurrencyCode = sd1.Name,
  7460. CurrencyName = sd1.Remark,
  7461. RoomCost = ntf.RoomCost,
  7462. FoodCost = ntf.FoodCost,
  7463. PublicCost = ntf.PublicCost,
  7464. LastUpdateUserId = ntf.LastUpdateUserId,
  7465. LastUpdateUserName = u.CnName,
  7466. LastUpdateTime = ntf.LastUpdateTime
  7467. })
  7468. .ToListAsync();
  7469. return Ok(JsonView(true, "查询成功!", nftData));
  7470. }
  7471. /// <summary>
  7472. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7473. /// </summary>
  7474. /// <returns></returns>
  7475. [HttpPost]
  7476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7477. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7478. {
  7479. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7480. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7481. List<string> countryData = new List<string>();
  7482. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7483. countryData = countryData.Distinct().ToList();
  7484. List<dynamic> dataSource = new List<dynamic>();
  7485. foreach (var item in countryData)
  7486. {
  7487. var cityData1 = new List<string>();
  7488. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7489. var countryData2 = new
  7490. {
  7491. CountryName = item,
  7492. CityData = cityData1
  7493. };
  7494. if (!dataSource.Contains(countryData2))
  7495. {
  7496. dataSource.Add(countryData2);
  7497. }
  7498. }
  7499. return Ok(JsonView(true, "查询成功!", dataSource));
  7500. }
  7501. /// <summary>
  7502. /// 团组模块 - 出入境国家费用标准 Page List
  7503. /// </summary>
  7504. /// <returns></returns>
  7505. [HttpPost]
  7506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7507. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7508. {
  7509. int portId = dto.PortType,
  7510. pageIndex = dto.PageIndex,
  7511. pageSize = dto.PageSize;
  7512. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7513. if (pageIndex == 0) pageIndex = 1;
  7514. if (pageSize == 0) pageSize = 10;
  7515. RefAsync<int> total = 0;
  7516. var nationalTravelFeeData = await _sqlSugar
  7517. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7518. JoinType.Left, ntf.Currency == sd1.Id,
  7519. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7520. JoinType.Left, ntf.ProvinceId == sd2.Id
  7521. ))
  7522. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7523. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7524. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7525. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7526. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7527. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7528. {
  7529. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7530. Id = ntf.Id,
  7531. ProvinceId = ntf.ProvinceId,
  7532. ProvinceName = sd2.Name_CN,
  7533. Continent = ntf.Continent,
  7534. Country = ntf.Country,
  7535. City = ntf.City,
  7536. Currency = ntf.Currency,
  7537. CurrencyCode = sd1.Name,
  7538. CurrencyName = sd1.Remark,
  7539. RoomCost = ntf.RoomCost,
  7540. FoodCost = ntf.FoodCost,
  7541. PublicCost = ntf.PublicCost,
  7542. LastUpdateUserId = ntf.LastUpdateUserId,
  7543. LastUpdateUserName = u.CnName,
  7544. LastUpdateTime = ntf.LastUpdateTime,
  7545. Remark = ntf.Remark
  7546. })
  7547. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7548. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7549. }
  7550. /// <summary>
  7551. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7552. /// </summary>
  7553. /// <returns></returns>
  7554. [HttpPost]
  7555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7556. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7557. {
  7558. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7559. int portId = dto.PortType;
  7560. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7561. string whereSql = string.Empty;
  7562. if (!string.IsNullOrEmpty(dto.Country))
  7563. {
  7564. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7565. }
  7566. if (!string.IsNullOrEmpty(dto.City))
  7567. {
  7568. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7569. }
  7570. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7571. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7572. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7573. From Grp_NationalTravelFee gntf
  7574. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7575. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7576. Where gntf.Isdel = 0 {0} ", whereSql);
  7577. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7578. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7579. }
  7580. /// <summary>
  7581. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7582. /// </summary>
  7583. /// <returns></returns>
  7584. [HttpPost]
  7585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7586. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7587. {
  7588. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7589. }
  7590. /// <summary>
  7591. /// 团组模块 - 出入境国家费用标准 - Del
  7592. /// </summary>
  7593. /// <returns></returns>
  7594. [HttpPost]
  7595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7596. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7597. {
  7598. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7599. {
  7600. Id = dto.Id,
  7601. DeleteUserId = dto.DeleteUserId,
  7602. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7603. IsDel = 1
  7604. };
  7605. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7606. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7607. .WhereColumns(it => new { it.Id })
  7608. .ExecuteCommandAsync();
  7609. if (delStatus <= 0)
  7610. {
  7611. return Ok(JsonView(false, "删除失败!"));
  7612. }
  7613. return Ok(JsonView(true, "操作成功!"));
  7614. }
  7615. /// <summary>
  7616. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7617. /// 注:Get 请求Headers 加 Token
  7618. /// </summary>
  7619. /// <param name="groupId"></param>
  7620. /// <returns></returns>
  7621. [HttpGet("{groupId}")]
  7622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7623. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7624. {
  7625. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7626. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7627. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7628. data.ForEach(x =>
  7629. {
  7630. x.CreateUserId = _currUserInfo.UserId;
  7631. });
  7632. if (data.Any())
  7633. {
  7634. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7635. if (add > 0)
  7636. {
  7637. return Ok(JsonView(true, "操作成功!"));
  7638. }
  7639. }
  7640. return Ok(JsonView(false, "未操作!"));
  7641. }
  7642. #endregion
  7643. #region 团组经理模块 出入境费用-草稿
  7644. /// <summary>
  7645. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7646. /// </summary>
  7647. /// <returns></returns>
  7648. [HttpGet]
  7649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7650. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7651. {
  7652. var provData = await _groupRepository.ProvinceBasicSource();
  7653. return Ok(JsonView(true, "查询成功!", provData));
  7654. }
  7655. /// <summary>
  7656. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7657. /// </summary>
  7658. /// <returns></returns>
  7659. [HttpGet("{provinceId}")]
  7660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7661. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7662. {
  7663. //验证城市归属并给默认值
  7664. if (provinceId < 1) provinceId = 122;
  7665. /*
  7666. * 122 四川
  7667. * 108 贵州
  7668. * 103 重庆
  7669. * 132 云南
  7670. */
  7671. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7672. return Ok(JsonView(true, "查询成功!", new
  7673. {
  7674. WordTypeData = wordTypeData,
  7675. ExcelTypeData = excelTypeData,
  7676. }));
  7677. }
  7678. /// <summary>
  7679. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7680. /// </summary>
  7681. /// <returns></returns>
  7682. [HttpPost]
  7683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7684. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7685. {
  7686. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7687. .Where(x => x.IsDel == 0)
  7688. .OrderByDescending(x => x.CreateTime)
  7689. .Select(x => new { x.Id, x.DraftName })
  7690. .ToListAsync();
  7691. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7692. //SetDataInfoView
  7693. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7694. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7695. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7696. int provinceId = dto.ProvinceId;
  7697. if (provinceId < 1) provinceId = 122;
  7698. /*
  7699. * 122 四川
  7700. * 108 贵州
  7701. * 103 重庆
  7702. * 132 云南
  7703. */
  7704. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7705. //默认币种显示
  7706. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7707. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7708. return Ok(JsonView(true, "查询成功!", new
  7709. {
  7710. DraftNameDatas = draftNameDatas,
  7711. CurrencyData = _CurrencyData,
  7712. WordTypeData = wordTypeData,
  7713. ExcelTypeData = excelTypeData,
  7714. CurrencyInit = _currencyInfos,
  7715. ViewPermissionData = viewPermissionData
  7716. }));
  7717. }
  7718. /// <summary>
  7719. /// 团组模块 - 出入境费用-草稿
  7720. /// 实时汇率 tips
  7721. /// 机票费用 tips
  7722. /// </summary>
  7723. /// <returns></returns>
  7724. [HttpPost]
  7725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7726. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7727. {
  7728. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7729. return Ok(JsonView(true, "查询成功!", new
  7730. {
  7731. //GroupNameData = groupNameData.Data,
  7732. //visaData = visaData.Data,
  7733. //airData = airData.Data,
  7734. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7735. }));
  7736. }
  7737. /// <summary>
  7738. /// 团组模块 - 出入境费用-草稿
  7739. /// 签证费用 tips
  7740. /// </summary>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7744. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7745. {
  7746. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7747. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7748. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7749. .Select(x => x.NationalTravelFeeId)
  7750. .Distinct()
  7751. .ToListAsync();
  7752. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7753. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7754. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7755. .Select(x => x.Country)
  7756. .Distinct()
  7757. .ToArrayAsync();
  7758. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7759. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7760. return Ok(JsonView(true, "查询成功!", new
  7761. {
  7762. totalAmt = totalAmt,
  7763. remark = remark
  7764. }));
  7765. }
  7766. /// <summary>
  7767. /// 团组模块 - 出入境费用-草稿 - Info
  7768. /// </summary>
  7769. /// <returns></returns>
  7770. [HttpPost]
  7771. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7773. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7774. {
  7775. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7776. }
  7777. /// <summary>
  7778. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7779. /// </summary>
  7780. /// <returns></returns>
  7781. [HttpPost]
  7782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7783. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7784. {
  7785. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7786. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7787. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7788. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7789. foreach (var userId in dto.UserIds)
  7790. {
  7791. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7792. }
  7793. if (permissions.Any())
  7794. {
  7795. _sqlSugar.BeginTran();
  7796. try
  7797. {
  7798. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7799. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7800. if (result < 1)
  7801. {
  7802. _sqlSugar.RollbackTran();
  7803. return Ok(JsonView(false));
  7804. }
  7805. }
  7806. catch (Exception ex)
  7807. {
  7808. _sqlSugar.RollbackTran();
  7809. return Ok(JsonView(false, ex.Message));
  7810. }
  7811. _sqlSugar.CommitTran();
  7812. return Ok(JsonView(true));
  7813. }
  7814. return Ok(JsonView(false));
  7815. }
  7816. /// <summary>
  7817. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7818. /// </summary>
  7819. /// <returns></returns>
  7820. [HttpPost]
  7821. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7823. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7824. {
  7825. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7826. if (data.Code != 0)
  7827. {
  7828. return Ok(JsonView(false, data.Msg));
  7829. }
  7830. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7831. //汇率信息记录
  7832. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7833. return Ok(JsonView(true, data.Msg, data.Data));
  7834. }
  7835. /// <summary>
  7836. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7837. /// </summary>
  7838. /// <param name="dto"></param>
  7839. /// <returns></returns>
  7840. [HttpPost]
  7841. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7843. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7844. {
  7845. try
  7846. {
  7847. var id = dto.Id;
  7848. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7849. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7850. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7851. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7852. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7853. 3 团组成员名单 1 团组成员名单", ""));
  7854. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7855. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7856. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7857. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7858. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7859. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7860. //数据源
  7861. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7862. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7863. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7864. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7865. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7866. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7867. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7868. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7869. .Select((x, a, b) => new
  7870. {
  7871. x.Index,
  7872. itemName = a.Name,
  7873. CurrencyStr = b.Name,
  7874. x.Cost,
  7875. x.SubTotal,
  7876. x.Remark
  7877. })
  7878. .OrderBy((x) => x.Index)
  7879. .ToList(); //其他款项费用
  7880. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7881. var peiceItemCurrencys = new List<string>();
  7882. if (_DayAndCosts.Any())
  7883. {
  7884. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7885. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7886. }
  7887. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7888. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7889. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7890. {
  7891. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7892. }
  7893. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7894. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7895. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7896. if (dto.ExportType == 1) //明细表
  7897. {
  7898. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7899. {
  7900. //获取模板
  7901. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7902. //载入模板
  7903. Document doc = new Document(tempPath);
  7904. DocumentBuilder builder = new DocumentBuilder(doc);
  7905. //利用键值对存放数据
  7906. Dictionary<string, string> dic = new Dictionary<string, string>();
  7907. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7908. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7909. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7910. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7911. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7912. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7913. //境内费用(其他费用)
  7914. if (_EnterExitCosts.ChoiceOne == 1)
  7915. {
  7916. string row1_1 = "";
  7917. if (_EnterExitCosts.Visa > 0)
  7918. {
  7919. //insidePayTotal += _EnterExitCosts.Visa;
  7920. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7921. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7922. //{
  7923. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7924. //}
  7925. }
  7926. string row1_2 = "";
  7927. if (_EnterExitCosts.YiMiao > 0)
  7928. {
  7929. //insidePayTotal += _EnterExitCosts.YiMiao;
  7930. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7931. }
  7932. if (_EnterExitCosts.HeSuan > 0)
  7933. {
  7934. //insidePayTotal += _EnterExitCosts.HeSuan;
  7935. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7936. }
  7937. if (_EnterExitCosts.Service > 0)
  7938. {
  7939. //insidePayTotal += _EnterExitCosts.Service;
  7940. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7941. }
  7942. string row1_3 = "";
  7943. if (_EnterExitCosts.Safe > 0)
  7944. {
  7945. //insidePayTotal += _EnterExitCosts.Safe;
  7946. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7947. }
  7948. if (_EnterExitCosts.Ticket > 0)
  7949. {
  7950. //insidePayTotal += _EnterExitCosts.Ticket;
  7951. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7952. }
  7953. string row1 = "";
  7954. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7955. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7956. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7957. row1 += $"备注:{_EnterExitCosts.Remark}";
  7958. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7959. dic.Add("Row1Str", row1);
  7960. }
  7961. string airTotalStr = string.Empty,
  7962. airPriceStr = string.Empty;
  7963. //经济舱
  7964. if (_EnterExitCosts.SumJJC == 1)
  7965. {
  7966. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7967. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7968. }
  7969. //公务舱
  7970. if (_EnterExitCosts.SumGWC == 1)
  7971. {
  7972. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7973. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7974. }
  7975. //头等舱
  7976. if (_EnterExitCosts.SumTDC == 1)
  7977. {
  7978. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7979. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7980. }
  7981. //汇率描述
  7982. string rateStr = "";
  7983. if (peiceItemCurrencyInfos.Any())
  7984. {
  7985. rateStr = "\r\n汇率描述:";
  7986. foreach (var item in peiceItemCurrencyInfos)
  7987. {
  7988. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7989. }
  7990. }
  7991. string twoItemRemark = "备注:";
  7992. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7993. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7994. dic.Add("AirTotalStr", airTotalStr);
  7995. dic.Add("AirPriceStr", airPriceStr);
  7996. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7997. dic.Add("TwoItemRemark", twoItemRemark);
  7998. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7999. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8000. int table1Row = 0,
  8001. table2Row = 0,
  8002. table3Row = 0,
  8003. table4Row = 0,
  8004. table5Row = 0;
  8005. //住宿费
  8006. if (_EnterExitCosts.ChoiceThree == 1)
  8007. {
  8008. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8009. table1Row = dac1.Count;
  8010. #region 填充word表格内容
  8011. for (int i = 0; i < dac1.Count; i++)
  8012. {
  8013. var dac = dac1[i];
  8014. if (dac == null) continue;
  8015. builder.MoveToCell(0, i, 0, 0);
  8016. builder.Write("第" + dac.Days.ToString() + "晚:");
  8017. builder.MoveToCell(0, i, 1, 0);
  8018. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8019. //builder.Write(dac.Place == null ? "" : dac.Place);
  8020. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8021. builder.MoveToCell(0, i, 2, 0);
  8022. builder.Write("费用标准:");
  8023. string curr = "";
  8024. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8025. if (currData != null)
  8026. {
  8027. curr = currData.Name;
  8028. }
  8029. builder.MoveToCell(0, i, 3, 0);
  8030. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8031. builder.MoveToCell(0, i, 4, 0);
  8032. builder.Write("费用小计:");
  8033. builder.MoveToCell(0, i, 5, 0);
  8034. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8035. }
  8036. #endregion
  8037. }
  8038. else dic.Add("SubZS", "0.00");
  8039. //删除多余行
  8040. while (table1.Rows.Count > table1Row)
  8041. {
  8042. table1.Rows.RemoveAt(table1Row);
  8043. }
  8044. //伙食费
  8045. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8046. if (_EnterExitCosts.ChoiceFour == 1)
  8047. {
  8048. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8049. table2Row = dac2.Count;
  8050. #region 填充word表格内容
  8051. for (int i = 0; i < dac2.Count; i++)
  8052. {
  8053. var dac = dac2[i];
  8054. if (dac == null) continue;
  8055. builder.MoveToCell(1, i, 0, 0);
  8056. builder.Write("第" + dac.Days.ToString() + "天:");
  8057. builder.MoveToCell(1, i, 1, 0);
  8058. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8059. builder.MoveToCell(1, i, 2, 0);
  8060. builder.Write("费用标准:");
  8061. string curr = "";
  8062. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8063. if (currData != null)
  8064. {
  8065. curr = currData.Name;
  8066. }
  8067. builder.MoveToCell(1, i, 3, 0);
  8068. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8069. builder.MoveToCell(1, i, 4, 0);
  8070. builder.Write("费用小计:");
  8071. builder.MoveToCell(1, i, 5, 0);
  8072. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8073. }
  8074. #endregion
  8075. }
  8076. else dic.Add("SubHS", "0.00");
  8077. //删除多余行
  8078. while (table2.Rows.Count > table2Row)
  8079. {
  8080. table2.Rows.RemoveAt(table2Row);
  8081. }
  8082. //公杂费
  8083. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8084. if (_EnterExitCosts.ChoiceFive == 1)
  8085. {
  8086. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8087. table3Row = dac3.Count;
  8088. #region 填充word表格内容
  8089. for (int i = 0; i < dac3.Count; i++)
  8090. {
  8091. var dac = dac3[i];
  8092. if (dac == null) continue;
  8093. builder.MoveToCell(2, i, 0, 0);
  8094. builder.Write("第" + dac.Days.ToString() + "天:");
  8095. builder.MoveToCell(2, i, 1, 0);
  8096. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8097. builder.MoveToCell(2, i, 2, 0);
  8098. builder.Write("费用标准:");
  8099. string curr = "";
  8100. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8101. if (currData != null)
  8102. {
  8103. curr = currData.Name;
  8104. }
  8105. builder.MoveToCell(2, i, 3, 0);
  8106. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8107. builder.MoveToCell(2, i, 4, 0);
  8108. builder.Write("费用小计:");
  8109. builder.MoveToCell(2, i, 5, 0);
  8110. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8111. }
  8112. //删除多余行
  8113. while (table3.Rows.Count > table3Row)
  8114. {
  8115. table3.Rows.RemoveAt(table3Row);
  8116. }
  8117. #endregion
  8118. }
  8119. else dic.Add("SubGZF", "0.00");
  8120. //删除多余行
  8121. while (table3.Rows.Count > table3Row)
  8122. {
  8123. table3.Rows.RemoveAt(table3Row);
  8124. }
  8125. //培训费
  8126. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8127. if (_EnterExitCosts.ChoiceSix == 1)
  8128. {
  8129. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8130. dic.Add("SubPX", pxStr);
  8131. table4Row = dac4.Count;
  8132. #region 填充word表格内容
  8133. for (int i = 0; i < dac4.Count; i++)
  8134. {
  8135. var dac = dac4[i];
  8136. if (dac == null) continue;
  8137. builder.MoveToCell(3, i, 0, 0);
  8138. builder.Write("第" + dac.Days.ToString() + "天:");
  8139. builder.MoveToCell(3, i, 1, 0);
  8140. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8141. builder.MoveToCell(3, i, 2, 0);
  8142. builder.Write("费用标准:");
  8143. string curr = "";
  8144. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8145. if (currData != null)
  8146. {
  8147. curr = currData.Name;
  8148. }
  8149. builder.MoveToCell(3, i, 3, 0);
  8150. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8151. builder.MoveToCell(3, i, 4, 0);
  8152. builder.Write("费用小计:");
  8153. builder.MoveToCell(3, i, 5, 0);
  8154. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8155. }
  8156. #endregion
  8157. }
  8158. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8159. //删除多余行
  8160. while (table4.Rows.Count > table4Row)
  8161. {
  8162. table4.Rows.RemoveAt(table4Row);
  8163. }
  8164. //其他费用
  8165. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8166. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8167. {
  8168. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8169. dic.Add("titleQi", qtStr);
  8170. table5Row = dac5.Count;
  8171. #region 填充word表格内容
  8172. for (int i = 0; i < dac5.Count; i++)
  8173. {
  8174. var dac = dac5[i];
  8175. if (dac == null) continue;
  8176. builder.MoveToCell(4, i, 0, 0);
  8177. builder.Write("第" + dac.Index.ToString() + "项:");
  8178. builder.MoveToCell(4, i, 1, 0);
  8179. builder.Write(dac.itemName);
  8180. builder.MoveToCell(4, i, 2, 0);
  8181. builder.Write("费用标准:");
  8182. builder.MoveToCell(4, i, 3, 0);
  8183. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8184. builder.MoveToCell(4, i, 4, 0);
  8185. builder.Write("费用小计:");
  8186. builder.MoveToCell(4, i, 5, 0);
  8187. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8188. builder.MoveToCell(4, i, 6, 0);
  8189. builder.Write("备注:");
  8190. builder.MoveToCell(4, i, 7, 0);
  8191. builder.Write(dac.Remark);
  8192. }
  8193. #endregion
  8194. }
  8195. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8196. //删除多余行
  8197. while (table5.Rows.Count > table5Row)
  8198. {
  8199. table5.Rows.RemoveAt(table5Row);
  8200. }
  8201. //加上其他费用
  8202. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8203. decimal subJJC = 0.00M,
  8204. subGWC = 0.00M,
  8205. subTDC = 0.00M;
  8206. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8207. string totalLabel = string.Format("全部费用总计:");
  8208. //经济舱
  8209. if (_EnterExitCosts.SumJJC == 1)
  8210. {
  8211. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8212. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8213. }
  8214. //公务舱
  8215. if (_EnterExitCosts.SumGWC == 1)
  8216. {
  8217. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8218. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8219. }
  8220. //头等舱
  8221. if (_EnterExitCosts.SumTDC == 1)
  8222. {
  8223. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8224. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8225. }
  8226. //TotalLabel
  8227. dic.Add("TotalLabel", totalLabel);
  8228. #region 填充word模板书签内容
  8229. foreach (var key in dic.Keys)
  8230. {
  8231. Bookmark bookmark = doc.Range.Bookmarks[key];
  8232. if (bookmark != null)
  8233. {
  8234. builder.MoveToBookmark(key);
  8235. builder.Write(dic[key]);
  8236. }
  8237. }
  8238. #endregion
  8239. //文件名
  8240. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8241. strFileName = CommonFun.ValidFileName(strFileName);
  8242. AsposeHelper.removewatermark_v2180();
  8243. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8244. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8245. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8246. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8247. }
  8248. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8249. {
  8250. //获取模板
  8251. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8252. //载入模板
  8253. Document doc = new Document(tempPath);
  8254. DocumentBuilder builder = new DocumentBuilder(doc);
  8255. Dictionary<string, string> dic = new Dictionary<string, string>();
  8256. string returnCodeLabel = string.Empty;
  8257. if (nationalTravelFeeData.Any())
  8258. {
  8259. List<string> list = new List<string>();
  8260. foreach (var item in nationalTravelFeeData)
  8261. {
  8262. list.Add($"{item.Country}({item.City})");
  8263. }
  8264. list = list.Distinct().ToList();
  8265. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8266. }
  8267. var countryLabel = string.Empty;
  8268. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8269. if (countryData.Any())
  8270. {
  8271. countryLabel = string.Join("、", countryData);
  8272. }
  8273. dic.Add("ReturnCodeAir", returnCodeLabel);
  8274. dic.Add("VisitStartDate", "-");
  8275. dic.Add("VisitEndDate", "-");
  8276. dic.Add("Day", "-");
  8277. dic.Add("VisitCountry", countryLabel);
  8278. dic.Add("ClientUnit", "-");
  8279. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8280. //dic.Add("Names", Names);
  8281. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8282. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8283. decimal dac1totalPrice = 0.00M;
  8284. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8285. foreach (var dac in dac1)
  8286. {
  8287. if (dac.SubTotal == 0.00M)
  8288. {
  8289. continue;
  8290. }
  8291. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8292. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8293. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8294. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8295. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8296. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8297. builder.Write(currency);//币种
  8298. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8299. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8300. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8301. builder.Write("");//人数
  8302. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8303. builder.Write("");//天数
  8304. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8305. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8306. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8307. decimal rate = 0.00M;
  8308. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8309. builder.Write(rate.ToString("#0.0000"));//汇率
  8310. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8311. decimal rbmPrice = dac.SubTotal;
  8312. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8313. accommodationStartIndex++;
  8314. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8315. }
  8316. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8317. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8318. {
  8319. table1.Rows.RemoveAt(i - 1);
  8320. foodandotherStartIndex--;
  8321. }
  8322. if (dac2.Count == dac3.Count)//国家 币种 金额
  8323. {
  8324. for (int i = 0; i < dac2.Count; i++)
  8325. {
  8326. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8327. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8328. }
  8329. }
  8330. decimal dac2totalPrice = 0.00M;
  8331. foreach (var dac in dac2)
  8332. {
  8333. if (dac.SubTotal == 0)
  8334. {
  8335. continue;
  8336. }
  8337. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8338. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8339. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8340. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8341. builder.Write(currency);//币种
  8342. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8343. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8344. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8345. builder.Write("");//人数
  8346. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8347. builder.Write("");//天数
  8348. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8349. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8350. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8351. decimal rate = 0.00M;
  8352. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8353. builder.Write(rate.ToString("#0.0000"));//汇率
  8354. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8355. decimal rbmPrice = dac.SubTotal;
  8356. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8357. foodandotherStartIndex++;
  8358. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8359. }
  8360. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8361. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8362. {
  8363. table1.Rows.RemoveAt(i - 1);
  8364. }
  8365. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8366. string otherFeeStr = "";
  8367. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8368. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8369. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8370. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8371. foreach (var otherInfo in dac5)
  8372. {
  8373. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8374. }
  8375. #endregion
  8376. if (otherFeeStr.Length > 0)
  8377. {
  8378. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8379. otherFeeStr = $"({otherFeeStr})";
  8380. dic.Add("OtherFeeStr", otherFeeStr);
  8381. }
  8382. //总计
  8383. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8384. //国际旅费
  8385. string outsideAir = string.Empty;
  8386. string allPriceAir = string.Empty;
  8387. if (_EnterExitCosts.SumJJC == 1)
  8388. {
  8389. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8390. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8391. }
  8392. if (_EnterExitCosts.SumGWC == 1)
  8393. {
  8394. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8395. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8396. }
  8397. if (_EnterExitCosts.SumTDC == 1)
  8398. {
  8399. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8400. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8401. }
  8402. dic.Add("InTravelPrice", $"({outsideAir})");
  8403. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8404. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8405. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8406. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8407. foreach (var key in dic.Keys)
  8408. {
  8409. builder.MoveToBookmark(key);
  8410. builder.Write(dic[key]);
  8411. }
  8412. //模板文件名
  8413. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8414. strFileName = CommonFun.ValidFileName(strFileName);
  8415. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8416. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8417. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8418. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8419. }
  8420. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8421. {
  8422. //获取模板
  8423. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8424. //载入模板
  8425. WorkbookDesigner designer = new WorkbookDesigner();
  8426. designer.Workbook = new Workbook(tempPath);
  8427. Dictionary<string, string> dic = new Dictionary<string, string>();
  8428. string returnCodeLabel = string.Empty;
  8429. if (nationalTravelFeeData.Any())
  8430. {
  8431. List<string> list = new List<string>();
  8432. foreach (var item in nationalTravelFeeData)
  8433. {
  8434. list.Add($"{item.Country}({item.City})");
  8435. }
  8436. list = list.Distinct().ToList();
  8437. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8438. }
  8439. var countryLabel = string.Empty;
  8440. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8441. if (countryData.Any())
  8442. {
  8443. countryLabel = string.Join("、", countryData);
  8444. }
  8445. dic.Add("ReturnCodeAir", returnCodeLabel);
  8446. dic.Add("VisitStartDate", "-");
  8447. dic.Add("VisitEndDate", "-");
  8448. dic.Add("Day", "0");
  8449. dic.Add("VisitCountry", countryLabel);
  8450. dic.Add("ClientUnit", "-");
  8451. designer.SetDataSource("ClientUnit", "-");
  8452. designer.SetDataSource("VisitCountry", countryLabel);
  8453. designer.SetDataSource("Group", "-");
  8454. designer.SetDataSource("ClientUnitTitle", "-");
  8455. designer.SetDataSource("Name", "-");
  8456. designer.SetDataSource("VisitStartDate", "-");
  8457. designer.SetDataSource("Day", "0");
  8458. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8459. designer.SetDataSource("ReturnCodeAir", "-");
  8460. int startIndex = 10;
  8461. const int startIndexcopy = 10;
  8462. if (dac2.Count == dac3.Count)//国家 币种 金额
  8463. {
  8464. for (int i = 0; i < dac2.Count; i++)
  8465. {
  8466. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8467. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8468. }
  8469. }
  8470. DataTable dtdac1 = new DataTable();
  8471. List<string> place = new List<string>();
  8472. dtdac1.Columns.AddRange(new DataColumn[] {
  8473. new DataColumn(){ ColumnName = "city"},
  8474. new DataColumn(){ ColumnName = "curr"},
  8475. new DataColumn(){ ColumnName = "criterion"},
  8476. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8477. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8478. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8479. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8480. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8481. });
  8482. DataTable dtdac2 = new DataTable();
  8483. dtdac2.Columns.AddRange(new DataColumn[] {
  8484. new DataColumn(){ ColumnName = "city"},
  8485. new DataColumn(){ ColumnName = "curr"},
  8486. new DataColumn(){ ColumnName = "criterion"},
  8487. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8488. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8489. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8490. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8491. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8492. });
  8493. dtdac1.TableName = "tb1";
  8494. dtdac2.TableName = "tb2";
  8495. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8496. foreach (var item in dac1)
  8497. {
  8498. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8499. if (place.Contains(item.Place))
  8500. {
  8501. continue;
  8502. }
  8503. DataRow row = dtdac1.NewRow();
  8504. row["city"] = item.Place;
  8505. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8506. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8507. row["curr"] = currency;
  8508. row["rate"] = rate.ToString("#0.0000");
  8509. row["criterion"] = item.Cost.ToString("#0.00");
  8510. row["number"] = 1;
  8511. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8512. //row["costRMB"] = rbmPrice;
  8513. dtdac1.Rows.Add(row);
  8514. place.Add(item.Place);
  8515. }
  8516. place = new List<string>();
  8517. foreach (var item in dac2)
  8518. {
  8519. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8520. if (place.Contains(item.Place))
  8521. {
  8522. continue;
  8523. }
  8524. DataRow row = dtdac2.NewRow();
  8525. row["city"] = item.Place;
  8526. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8527. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8528. row["curr"] = currency;
  8529. row["rate"] = rate.ToString("#0.0000");
  8530. row["criterion"] = item.Cost.ToString("#0.00");
  8531. row["number"] = 1;
  8532. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8533. //row["cost"] = item.SubTotal;
  8534. //row["costRMB"] = rbmPrice;
  8535. dtdac2.Rows.Add(row);
  8536. place.Add(item.Place);
  8537. //dac2totalPrice += rbmPrice;
  8538. }
  8539. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8540. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8541. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8542. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8543. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8544. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8545. string cell4Str1 = string.Empty;
  8546. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8547. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8548. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8549. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8550. string cellStr = $" 5.其他费用(";
  8551. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8552. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8553. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8554. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8555. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8556. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8557. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8558. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8559. foreach (var otherInfo in dac5)
  8560. {
  8561. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8562. }
  8563. #endregion
  8564. if (cellStr.Length > 8)
  8565. {
  8566. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8567. }
  8568. cellStr += ")";
  8569. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8570. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8571. decimal pxFee = dac4.Sum(it => it.Cost);
  8572. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8573. string celllastStr1 = "";
  8574. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8575. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8576. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8577. celllastStr1 += $",国际旅费 元";
  8578. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8579. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8580. designer.SetDataSource("cell4Str", cell4Str);
  8581. designer.SetDataSource("cellStr", cellStr);
  8582. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8583. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8584. designer.SetDataSource("celllastStr", celllastStr);
  8585. Workbook wb = designer.Workbook;
  8586. var sheet = wb.Worksheets[0];
  8587. //绑定datatable数据集
  8588. designer.SetDataSource(dtdac1);
  8589. designer.SetDataSource(dtdac2);
  8590. designer.Process();
  8591. var rowStart = dtdac1.Rows.Count;
  8592. while (rowStart > 0)
  8593. {
  8594. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8595. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8596. startIndex++;
  8597. rowStart--;
  8598. }
  8599. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8600. startIndex += 1; //总计行
  8601. rowStart = dtdac2.Rows.Count;
  8602. while (rowStart > 0)
  8603. {
  8604. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8605. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8606. startIndex++;
  8607. rowStart--;
  8608. }
  8609. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8610. wb.CalculateFormula(true);
  8611. //模板文件名
  8612. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8613. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8614. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8615. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8616. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8617. }
  8618. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8619. {
  8620. //获取模板
  8621. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8622. //载入模板
  8623. Document doc = new Document(tempPath);
  8624. DocumentBuilder builder = new DocumentBuilder(doc);
  8625. Dictionary<string, string> dic = new Dictionary<string, string>();
  8626. dic.Add("GroupName", "-");
  8627. dic.Add("ClientUnit", "-");
  8628. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8629. //string missionLeaderJob = "";//负责人job
  8630. //int groupNumber = 0; //团人数
  8631. dic.Add("MissionLeader", "-"); //团负责人
  8632. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8633. dic.Add("GroupNumber", "0"); //团人数
  8634. dic.Add("Day", "0");
  8635. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8636. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8637. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8638. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8639. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8640. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8641. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8642. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8643. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8644. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8645. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8646. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8647. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8648. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8649. //其他费用
  8650. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8651. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8652. //其他费用合计
  8653. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8654. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8655. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8656. //公务舱合计
  8657. //国际旅费
  8658. //string outsideJJ = "";
  8659. //string allPriceJJ = "";
  8660. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8661. {
  8662. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8663. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8664. }
  8665. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8666. {
  8667. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8668. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8669. }
  8670. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8671. {
  8672. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8673. dic.Add("AirFeeTotal", airFeeTotalStr);
  8674. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8675. dic.Add("FeeTotal", feeTotalStr);
  8676. }
  8677. foreach (var key in dic.Keys)
  8678. {
  8679. builder.MoveToBookmark(key);
  8680. builder.Write(dic[key]);
  8681. }
  8682. //模板文件名
  8683. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8684. strFileName = CommonFun.ValidFileName(strFileName);
  8685. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8686. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8687. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8688. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8689. }
  8690. }
  8691. else if (dto.ExportType == 2) //表格
  8692. {
  8693. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8694. }
  8695. else if (dto.ExportType == 3)
  8696. {
  8697. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8698. }
  8699. return Ok(JsonView(400, "只可导出明细表!", ""));
  8700. }
  8701. catch (Exception ex)
  8702. {
  8703. return Ok(JsonView(400, ex.Message, ""));
  8704. }
  8705. }
  8706. /// <summary>
  8707. /// 获取三公费用标准city
  8708. /// </summary>
  8709. /// <param name="placeData"></param>
  8710. /// <param name="nationalTravelFeeId"></param>
  8711. /// <returns></returns>
  8712. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8713. {
  8714. string _city = string.Empty;
  8715. if (!placeData.Any()) return _city;
  8716. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8717. if (data == null) return _city;
  8718. string country = data.Country;
  8719. string city = data.City;
  8720. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8721. else _city = city;
  8722. return _city;
  8723. }
  8724. /// <summary>
  8725. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8726. /// </summary>
  8727. /// <returns></returns>
  8728. [HttpPost]
  8729. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8731. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8732. {
  8733. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8734. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8735. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8736. if (_view.Code == 0)
  8737. {
  8738. return Ok(JsonView(true, "操作成功"));
  8739. }
  8740. return Ok(JsonView(false, "操作失败"));
  8741. }
  8742. /// <summary>
  8743. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8744. /// </summary>
  8745. /// <returns></returns>
  8746. [HttpPost]
  8747. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8749. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8750. {
  8751. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8752. if (data.Code != 0)
  8753. {
  8754. return Ok(JsonView(false, data.Msg));
  8755. }
  8756. return Ok(JsonView(true, "操作成功!", data.Data));
  8757. }
  8758. /// <summary>
  8759. /// 三公其他费用草稿 删除
  8760. /// </summary>
  8761. /// <param name="dto"></param>
  8762. /// <returns></returns>
  8763. [HttpPost]
  8764. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8765. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8766. {
  8767. var jw = JsonView(false, "删除失败!");
  8768. var data = new Grp_DayOtherPriceDraft()
  8769. {
  8770. Id = dto.Id,
  8771. IsDel = 1,
  8772. DeleteUserId = dto.DeleteUserId,
  8773. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8774. };
  8775. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8776. if (del > 0)
  8777. {
  8778. jw.Code = 200;
  8779. jw.Msg = "删除成功!";
  8780. }
  8781. return Ok(jw);
  8782. }
  8783. /// <summary>
  8784. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8785. /// </summary>
  8786. /// <returns></returns>
  8787. [HttpPost]
  8788. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8789. {
  8790. var jw = JsonView(false);
  8791. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8792. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8793. jw.Code = StatusCodes.Status200OK;
  8794. jw.Msg = "操作成功!";
  8795. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8796. return Ok(jw);
  8797. }
  8798. /// <summary>
  8799. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8800. /// </summary>
  8801. /// <param name="dto"></param>
  8802. /// <returns></returns>
  8803. [HttpPost]
  8804. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8805. {
  8806. int userId = dto.UserId,
  8807. portId = dto.PortType,
  8808. groupId = dto.GroupId,
  8809. draftId = dto.DraftId;
  8810. _portTypeData.Add(1);
  8811. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8812. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8813. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8814. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8815. _sqlSugar.BeginTran();
  8816. try
  8817. {
  8818. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8819. if (draftDatas == null)
  8820. {
  8821. _sqlSugar.RollbackTran();
  8822. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8823. }
  8824. //验证可覆盖已有数据 两边创建人需为同一人;
  8825. int draftCreateUserId = draftDatas.CreateUserId,
  8826. formalCreateUserId = 0;
  8827. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8828. if (formalData != null)
  8829. {
  8830. formalCreateUserId = formalData.CreateUserId;
  8831. if (draftCreateUserId != formalCreateUserId)
  8832. {
  8833. _sqlSugar.RollbackTran();
  8834. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8835. }
  8836. }
  8837. //默认添加查看、编辑权限(创建人、自己)
  8838. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8839. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8840. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8841. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8842. newExterData.DiId = groupId;
  8843. newExterData.CreateUserId = userId;
  8844. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8845. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8846. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8847. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8848. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8849. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8850. //数据如果存在执行删除
  8851. if (enterExitCostInfo != null)
  8852. {
  8853. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8854. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8855. .Where(x => x.Id == enterExitCostInfo.Id)
  8856. .ExecuteCommand();
  8857. _sqlSugar.Updateable<Grp_DayAndCost>()
  8858. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8859. .Where(x => x.DiId == groupId)
  8860. .ExecuteCommand();
  8861. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8862. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8863. .Where(x => x.Diid == groupId)
  8864. .ExecuteCommand();
  8865. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8866. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8867. .Where(x => x.GroupId == groupId)
  8868. .ExecuteCommand();
  8869. }
  8870. //执行insert
  8871. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8872. if (insertId < 1)
  8873. {
  8874. _sqlSugar.RollbackTran();
  8875. return Ok(JsonView(false, "草稿数据导入失败!"));
  8876. }
  8877. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8878. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8879. #region 默认添加权限
  8880. #endregion
  8881. _sqlSugar.CommitTran();
  8882. //执行操作之后
  8883. //生成默认文件pdf并且通知人员
  8884. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8885. {
  8886. DiId = groupId,
  8887. ExportType = 1,
  8888. SubTypeId = 1005
  8889. }, "pdf");
  8890. //发送通知
  8891. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8892. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8893. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8894. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8895. //汇率信息记录
  8896. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8897. return Ok(JsonView(true));
  8898. }
  8899. catch (Exception ex)
  8900. {
  8901. _sqlSugar.RollbackTran();
  8902. return Ok(JsonView(false, ex.Message));
  8903. }
  8904. }
  8905. #endregion
  8906. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8907. /// <summary>
  8908. /// 获取币种基础数据(含逻辑处理)
  8909. /// </summary>
  8910. /// <returns></returns>
  8911. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8912. {
  8913. return await GeneralMethod.EnterExitCostInitRate();
  8914. }
  8915. /// <summary>
  8916. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8917. /// </summary>
  8918. /// <returns></returns>
  8919. [HttpPost]
  8920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8921. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8922. {
  8923. //验证城市归属并给默认值
  8924. int provinceId = dto.ProvinceId;
  8925. if (provinceId < 1) provinceId = 122;
  8926. var dataSource = await _sqlSugar
  8927. .Queryable<Sys_SetData>()
  8928. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8929. .ToListAsync();
  8930. var fileTypes = new List<EecSetDataInfoView>();
  8931. //三公费用-Word明细类型
  8932. var wordTypeData = dataSource
  8933. .Where(it => it.STid == 72)
  8934. .Select(x => new EecSetDataInfoView
  8935. {
  8936. ParentId = 1,
  8937. Id = x.Id,
  8938. Name = x.Name
  8939. })
  8940. .ToArray();
  8941. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8942. var excelTypeData = dataSource
  8943. .Where(it => it.STid == 73)
  8944. .Select(x => new EecSetDataInfoView
  8945. {
  8946. ParentId = 2,
  8947. Id = x.Id,
  8948. Name = x.Name
  8949. })
  8950. .ToArray();
  8951. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8952. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8953. fileTypes.Add(groupNameList);
  8954. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8955. //默认币种显示
  8956. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8957. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8958. return Ok(JsonView(true, "查询成功!", new
  8959. {
  8960. FileTypeData = fileTypes,
  8961. CurrencyInit = _currencyInfos,
  8962. viewPermissionData = viewPermissionData
  8963. }));
  8964. }
  8965. /// <summary>
  8966. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8967. /// </summary>
  8968. /// <returns></returns>
  8969. [HttpPost]
  8970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8971. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8972. {
  8973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8974. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8975. RefAsync<int> total = 0;
  8976. int diId = 0;
  8977. var status = int.TryParse(dto.GroupName, out diId);
  8978. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8979. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8980. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8981. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8982. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8983. .OrderByDescending(x => x.VisitStartDate)
  8984. .Select(x => new EnterExitCostMobileGroupView()
  8985. {
  8986. Id = x.Id,
  8987. GroupName = x.TeamName,
  8988. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8989. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8990. ProvinceId = x.CityId
  8991. })
  8992. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8993. //处理省份Id
  8994. if (data.Any())
  8995. {
  8996. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8997. if (provCityDatas.Any())
  8998. {
  8999. foreach (var item in data)
  9000. {
  9001. var provinceId = item.ProvinceId;
  9002. var isDefualtVal = true;
  9003. if (provinceId > 0)
  9004. {
  9005. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9006. if (parentId != null)
  9007. {
  9008. isDefualtVal = false;
  9009. item.ProvinceId = (int)parentId;
  9010. }
  9011. }
  9012. if (isDefualtVal)
  9013. {
  9014. item.ProvinceId = 122; //默认四川
  9015. }
  9016. }
  9017. }
  9018. }
  9019. //处理是否显示
  9020. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9021. {
  9022. foreach (var item in data)
  9023. {
  9024. item.IsView = true;
  9025. }
  9026. }
  9027. return Ok(JsonView(true, "查询成功!", data, total));
  9028. }
  9029. /// <summary>
  9030. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9031. /// </summary>
  9032. /// <returns></returns>
  9033. [HttpPost]
  9034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9035. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9036. {
  9037. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9038. RefAsync<int> total = 0;
  9039. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9040. .Where(x => x.IsDel == 0 && x.STid == 66)
  9041. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9042. .Select(x => new
  9043. {
  9044. id = x.Id,
  9045. name = x.Name,
  9046. remark = x.Remark,
  9047. })
  9048. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9049. return Ok(JsonView(true, "查询成功!", data, total));
  9050. }
  9051. /// <summary>
  9052. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9053. /// </summary>
  9054. /// <returns></returns>
  9055. [HttpPost]
  9056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9057. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9058. {
  9059. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9060. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9061. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9062. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9063. var groupOtherRateData = groupRateData.TeamRates;
  9064. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9065. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9066. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9067. groupOtherRateData = groupOtherRateData
  9068. .Select(x => new TeamRateDescAddCurrencyIdView
  9069. {
  9070. CurrencyId = x.CurrencyId,
  9071. CurrencyName = x.CurrencyName,
  9072. CurrencyCode = x.CurrencyCode,
  9073. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9074. }).ToList();
  9075. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9076. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9077. }
  9078. /// <summary>
  9079. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9080. /// </summary>
  9081. /// <returns></returns>
  9082. [HttpPost]
  9083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9084. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9085. {
  9086. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9087. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9088. var tipsData = new List<int>() { 1, 2, 3 };
  9089. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9090. if (dto.TipsType == 1)
  9091. {
  9092. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9093. }
  9094. else if (dto.TipsType == 2)
  9095. {
  9096. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9097. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9098. }
  9099. else if (dto.TipsType == 3)
  9100. {
  9101. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  9102. return Ok(JsonView(true, "查询成功!", airData.Data));
  9103. }
  9104. return Ok(JsonView(false));
  9105. }
  9106. /// <summary>
  9107. /// 团组模块 - 出入境国家费用标准-移动端 List
  9108. /// </summary>
  9109. /// <returns></returns>
  9110. [HttpPost]
  9111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9112. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9113. {
  9114. Stopwatch sw = new Stopwatch();
  9115. sw.Start();
  9116. int provinceId = dto.ProvinceId;
  9117. if (provinceId < 1) provinceId = 122; // 默认四川
  9118. RefAsync<int> total = 0;
  9119. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9120. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9121. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9122. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9123. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9124. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9125. .Select((ntf, sd, u, sd1) => new
  9126. {
  9127. Id = ntf.Id,
  9128. Area = $"{ntf.Country}-{ntf.City}",
  9129. Currency = ntf.Currency,
  9130. CurrencyCode = sd.Name,
  9131. CurrencyName = sd.Remark,
  9132. RoomCost = ntf.RoomCost,
  9133. FoodCost = ntf.FoodCost,
  9134. PublicCost = ntf.PublicCost,
  9135. TrainCost = ntf.TrainCost,
  9136. LastUpdateUserId = ntf.LastUpdateUserId,
  9137. LastUpdateUserName = u.CnName,
  9138. LastUpdateTime = ntf.LastUpdateTime
  9139. })
  9140. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9141. sw.Stop();
  9142. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9143. }
  9144. /// <summary>
  9145. /// 团组模块 - 出入境费用-移动端 - Info
  9146. /// </summary>
  9147. /// <returns></returns>
  9148. [HttpPost]
  9149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9150. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9151. {
  9152. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9153. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9154. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9155. return Ok(data);
  9156. }
  9157. /// <summary>
  9158. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9159. /// </summary>
  9160. /// <returns></returns>
  9161. [HttpPost]
  9162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9163. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9164. {
  9165. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9166. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9167. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9168. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9169. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9170. mobileInfo.DiId = dto.DiId;
  9171. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9172. if (eecInfo == null) return Ok(mobileInfo);
  9173. //验证查看权限
  9174. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9175. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9176. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9177. mobileInfo.IsAssignPerm = isSet;
  9178. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9179. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9180. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9181. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9182. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9183. {
  9184. SubId = dac.Id,
  9185. DiId = dac.DiId,
  9186. Type = dac.Type,
  9187. Days = dac.Days,
  9188. NationalTravelFeeId = dac.NationalTravelFeeId,
  9189. Arae = $"{ntf.Country}-{ntf.City}",
  9190. Cost = dac.Cost,
  9191. Currency = dac.Currency,
  9192. CurrencyName = sd.Name,
  9193. SubTotal = dac.SubTotal,
  9194. })
  9195. .ToList();
  9196. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9197. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9198. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9199. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9200. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9201. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9202. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9203. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9204. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9205. //其他款项
  9206. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9207. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9208. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9209. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9210. .OrderBy((dop, sd1, sd2) => dop.Index)
  9211. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9212. {
  9213. SubId = dop.Id,
  9214. DiId = dop.Diid,
  9215. Index = dop.Index,
  9216. SetDataId = dop.SetDataId,
  9217. SetDataName = sd1.Name,
  9218. Cost = dop.Cost,
  9219. Currency = dop.Currency,
  9220. CurrencyName = sd2.Remark,
  9221. SubTotal = dop.SubTotal,
  9222. Remark = dop.Remark,
  9223. })
  9224. .ToArray();
  9225. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9226. return Ok(mobileInfo);
  9227. }
  9228. /// <summary>
  9229. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9230. /// </summary>
  9231. /// <returns></returns>
  9232. [HttpPost]
  9233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9234. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9235. {
  9236. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9237. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9238. //验证查看权限
  9239. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9240. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9241. var userIds = await _sqlSugar
  9242. .Queryable<Grp_EnterExitCostPermission>()
  9243. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9244. .Select(x => x.UserId)
  9245. .ToArrayAsync();
  9246. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9247. var perUsersView = new List<dynamic>();
  9248. foreach (var item in perUsers)
  9249. {
  9250. bool isView1 = false;
  9251. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9252. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9253. }
  9254. return Ok(JsonView(perUsersView));
  9255. }
  9256. /// <summary>
  9257. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9258. /// </summary>
  9259. /// <returns></returns>
  9260. [HttpPost]
  9261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9262. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9263. {
  9264. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9265. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9266. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9267. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9268. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9269. //验证查看权限
  9270. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9271. //if (!isView) return Ok(JsonView(false, msg));
  9272. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9273. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9274. var subType = dto.SubType;
  9275. if (subType == 1) //1:境内费用
  9276. {
  9277. var oneData = new ChoiceOneMobileSubInfoView()
  9278. {
  9279. Id = eecInfo.Id,
  9280. ChoiceOne = eecInfo.ChoiceOne,
  9281. ChoiceOneTotalCost = eecInfo.InsidePay,
  9282. Visa = eecInfo.Visa,
  9283. VisaRemark = eecInfo.VisaRemark,
  9284. YiMiao = eecInfo.YiMiao,
  9285. HeSuan = eecInfo.HeSuan,
  9286. Service = eecInfo.Service,
  9287. Ticket = eecInfo.Ticket,
  9288. Safe = eecInfo.Safe,
  9289. FirstItemRemark = eecInfo.FirstItemRemark
  9290. };
  9291. return Ok(JsonView(oneData));
  9292. }
  9293. else if (subType == 2) //2:国际旅费
  9294. {
  9295. var twoData = new ChoiceTwoMobileSubInfoView()
  9296. {
  9297. Id = eecInfo.Id,
  9298. ChoiceTwoJJ = eecInfo.SumJJC,
  9299. OutsideJJPay = eecInfo.OutsideJJPay,
  9300. ChoiceTwoGW = eecInfo.SumGWC,
  9301. OutsideGWPay = eecInfo.OutsideGWPay,
  9302. ChoiceTwoTD = eecInfo.SumTDC,
  9303. OutsideTDPay = eecInfo.OutsideTDPay,
  9304. AirJJ = eecInfo.AirJJ,
  9305. AirGW = eecInfo.AirGW,
  9306. AirTD = eecInfo.AirTD,
  9307. CityTranffic = eecInfo.CityTranffic,
  9308. TwoItemRemark = eecInfo.TwoItemRemark
  9309. };
  9310. return Ok(JsonView(twoData));
  9311. }
  9312. else if (subType == 3) //3:住宿费
  9313. {
  9314. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9315. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9316. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9317. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9318. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9319. {
  9320. SubId = dac.Id,
  9321. DiId = dac.DiId,
  9322. Type = dac.Type,
  9323. Days = dac.Days,
  9324. NationalTravelFeeId = dac.NationalTravelFeeId,
  9325. Arae = $"{ntf.Country}-{ntf.City}",
  9326. Cost = dac.Cost,
  9327. Currency = dac.Currency,
  9328. CurrencyName = sd.Name,
  9329. SubTotal = dac.SubTotal,
  9330. })
  9331. .ToArray();
  9332. var data = new ChoiceMobileSubInfo3To6View()
  9333. {
  9334. ParentId = eecInfo.Id,
  9335. Choice = eecInfo.ChoiceThree,
  9336. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9337. Details = dayAndCostDatas
  9338. };
  9339. return Ok(JsonView(data));
  9340. }
  9341. else if (subType == 4) //4:伙食费
  9342. {
  9343. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9344. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9345. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9346. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9347. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9348. {
  9349. SubId = dac.Id,
  9350. DiId = dac.DiId,
  9351. Type = dac.Type,
  9352. Days = dac.Days,
  9353. NationalTravelFeeId = dac.NationalTravelFeeId,
  9354. Arae = $"{ntf.Country}-{ntf.City}",
  9355. Cost = dac.Cost,
  9356. Currency = dac.Currency,
  9357. CurrencyName = sd.Name,
  9358. SubTotal = dac.SubTotal,
  9359. })
  9360. .ToArray();
  9361. var data = new ChoiceMobileSubInfo3To6View()
  9362. {
  9363. ParentId = eecInfo.Id,
  9364. Choice = eecInfo.ChoiceFour,
  9365. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9366. Details = dayAndCostDatas
  9367. };
  9368. return Ok(JsonView(data));
  9369. }
  9370. else if (subType == 5) //5:公杂费
  9371. {
  9372. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9373. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9374. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9375. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9376. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9377. {
  9378. SubId = dac.Id,
  9379. DiId = dac.DiId,
  9380. Type = dac.Type,
  9381. Days = dac.Days,
  9382. NationalTravelFeeId = dac.NationalTravelFeeId,
  9383. Arae = $"{ntf.Country}-{ntf.City}",
  9384. Cost = dac.Cost,
  9385. Currency = dac.Currency,
  9386. CurrencyName = sd.Name,
  9387. SubTotal = dac.SubTotal,
  9388. })
  9389. .ToArray();
  9390. var data = new ChoiceMobileSubInfo3To6View()
  9391. {
  9392. ParentId = eecInfo.Id,
  9393. Choice = eecInfo.ChoiceFive,
  9394. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9395. Details = dayAndCostDatas
  9396. };
  9397. return Ok(JsonView(data));
  9398. }
  9399. else if (subType == 6) //6:培训费
  9400. {
  9401. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9402. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9403. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9404. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9405. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9406. {
  9407. SubId = dac.Id,
  9408. DiId = dac.DiId,
  9409. Type = dac.Type,
  9410. Days = dac.Days,
  9411. NationalTravelFeeId = dac.NationalTravelFeeId,
  9412. Arae = $"{ntf.Country}-{ntf.City}",
  9413. Cost = dac.Cost,
  9414. Currency = dac.Currency,
  9415. CurrencyName = sd.Name,
  9416. SubTotal = dac.SubTotal,
  9417. })
  9418. .ToArray();
  9419. var data = new ChoiceMobileSubInfo3To6View()
  9420. {
  9421. ParentId = eecInfo.Id,
  9422. Choice = eecInfo.ChoiceSix,
  9423. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9424. Details = dayAndCostDatas
  9425. };
  9426. return Ok(JsonView(data));
  9427. }
  9428. else if (subType == 7) //7:其他
  9429. {
  9430. //其他款项
  9431. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9432. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9433. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9434. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9435. .OrderBy((dop, sd1, sd2) => dop.Index)
  9436. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9437. {
  9438. SubId = dop.Id,
  9439. DiId = dop.Diid,
  9440. Index = dop.Index,
  9441. SetDataId = dop.SetDataId,
  9442. SetDataName = sd1.Name,
  9443. Cost = dop.Cost,
  9444. Currency = dop.Currency,
  9445. CurrencyName = sd2.Name,
  9446. SubTotal = dop.SubTotal,
  9447. Remark = dop.Remark,
  9448. })
  9449. .ToArray();
  9450. var data = new ChoiceSevenMobileSubInfoView()
  9451. {
  9452. ParentId = eecInfo.Id,
  9453. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9454. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9455. Details = otherData
  9456. };
  9457. return Ok(JsonView(data));
  9458. }
  9459. return Ok(JsonView(false));
  9460. }
  9461. #region op
  9462. /// <summary>
  9463. /// 移动端更新费用消息通知
  9464. /// </summary>
  9465. /// <param name="diid"></param>
  9466. /// <param name="id"></param>
  9467. /// <param name="currUserId"></param>
  9468. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9469. {
  9470. try
  9471. {
  9472. ////生成默认文件pdf并且通知人员
  9473. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9474. //{
  9475. // DiId = diid,
  9476. // ExportType = 1,
  9477. // SubTypeId = 1005
  9478. //}, "pdf");
  9479. ////发送通知
  9480. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9481. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9482. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9483. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9484. ////汇率信息记录
  9485. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9486. }
  9487. catch (Exception ex)
  9488. {
  9489. //记录日志
  9490. throw;
  9491. }
  9492. }
  9493. /// <summary>
  9494. /// 验证出入境费用数据是否存在
  9495. /// 不存在添加
  9496. /// </summary>
  9497. /// <param name="diId"></param>
  9498. /// <param name="currUserId"></param>
  9499. /// <returns></returns>
  9500. /// <exception cref="CustomException"></exception>
  9501. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9502. {
  9503. var parentId = 0;
  9504. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9505. if (info != null)
  9506. {
  9507. parentId = info.Id;
  9508. }
  9509. else
  9510. {
  9511. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9512. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9513. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9514. parentId = addId;
  9515. }
  9516. return parentId;
  9517. }
  9518. /// <summary>
  9519. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9520. /// </summary>
  9521. /// <returns></returns>
  9522. [HttpPost]
  9523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9524. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9525. {
  9526. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9527. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9528. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9529. //验证编辑权限
  9530. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9531. //if (!isEdit) return Ok(JsonView(false, msg));
  9532. var permissions = new List<Grp_EnterExitCostPermission>();
  9533. foreach (var userId in dto.UserIds)
  9534. {
  9535. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9536. }
  9537. if (permissions.Any())
  9538. {
  9539. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9540. {
  9541. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9542. }
  9543. _sqlSugar.BeginTran();
  9544. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9545. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9546. if (result < 1)
  9547. {
  9548. _sqlSugar.RollbackTran();
  9549. return Ok(JsonView(false));
  9550. }
  9551. _sqlSugar.CommitTran();
  9552. return Ok(JsonView(true));
  9553. }
  9554. return Ok(JsonView(false));
  9555. }
  9556. /// <summary>
  9557. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9558. /// </summary>
  9559. /// <returns></returns>
  9560. [HttpPost]
  9561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9562. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9563. {
  9564. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9565. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9566. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9567. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9568. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9569. int id = dto.Id;
  9570. if (id <= 0) //add
  9571. {
  9572. //int provinceId = dto.ProvinceId;
  9573. int groupId = dto.DiId;
  9574. //if (provinceId < 1) provinceId = 122;
  9575. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9576. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9577. if (add < 1) return Ok(JsonView(false));
  9578. id = add;
  9579. }
  9580. else //update
  9581. {
  9582. ////验证编辑权限
  9583. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9584. //if (!isEdit) return Ok(JsonView(false, msg));
  9585. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9586. if (upd < 1) return Ok(JsonView(false));
  9587. }
  9588. #region 汇率变更时更改币种相关费用
  9589. var opDayCosts = new List<Grp_DayAndCost>();
  9590. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9591. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9592. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9593. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9594. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9595. .Select((dac, sd) => new
  9596. {
  9597. dac.Id,
  9598. dac.DiId,
  9599. CurrencyCode = sd.Name,
  9600. dac.Cost
  9601. })
  9602. .ToList();
  9603. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9604. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9605. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9606. .Select((dop, sd) => new
  9607. {
  9608. dop.Id,
  9609. dop.Diid,
  9610. CurrencyCode = sd.Name,
  9611. dop.Cost
  9612. })
  9613. .ToList();
  9614. if (dayCosts.Count > 0)
  9615. {
  9616. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9617. foreach (var dc in new_dayCosts)
  9618. {
  9619. var thisCurrency = dc.Key.ToUpper();
  9620. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9621. if (thisRate == 0.00M) continue;
  9622. foreach (var dcSub in dc)
  9623. {
  9624. opDayCosts.Add(new Grp_DayAndCost()
  9625. {
  9626. Id = dcSub.Id,
  9627. DiId = dcSub.DiId,
  9628. Cost = dcSub.Cost,
  9629. SubTotal = dcSub.Cost * thisRate,
  9630. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9631. });
  9632. }
  9633. }
  9634. if (opDayCosts.Count > 0)
  9635. {
  9636. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9637. }
  9638. }
  9639. if (dayOtherCosts.Count > 0)
  9640. {
  9641. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9642. foreach (var dc in new_dayOtherCosts)
  9643. {
  9644. var thisCurrency = dc.Key.ToUpper();
  9645. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9646. if (thisRate == 0.00M) continue;
  9647. foreach (var dcSub in dc)
  9648. {
  9649. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9650. {
  9651. Id = dcSub.Id,
  9652. Diid = dcSub.Diid,
  9653. Cost = dcSub.Cost,
  9654. SubTotal = dcSub.Cost * thisRate,
  9655. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9656. });
  9657. }
  9658. }
  9659. if (opDayOtherCosts.Count > 0)
  9660. {
  9661. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9662. }
  9663. }
  9664. #endregion
  9665. //消息通知
  9666. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9667. //汇率信息记录
  9668. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9669. return Ok(JsonView(new { parentId = id }));
  9670. }
  9671. /// <summary>
  9672. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9673. /// </summary>
  9674. /// <returns></returns>
  9675. [HttpPost]
  9676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9677. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9678. {
  9679. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9680. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9681. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9682. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9683. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9684. int id = dto.Id;
  9685. if (id <= 0) //add
  9686. {
  9687. checkboxInfo.CreateUserId = dto.CurrUserId;
  9688. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9689. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9690. if (add < 1) return Ok(JsonView(false));
  9691. }
  9692. else //update
  9693. {
  9694. ////验证编辑权限
  9695. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9696. //if (!isEdit) return Ok(JsonView(false, msg));
  9697. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9698. .UpdateColumns(x => new
  9699. {
  9700. x.ChoiceOne,
  9701. x.ChoiceTwo,
  9702. x.SumJJC,
  9703. x.SumGWC,
  9704. x.SumTDC,
  9705. x.ChoiceThree,
  9706. x.ChoiceFour,
  9707. x.ChoiceFive,
  9708. x.ChoiceSix,
  9709. x.OtherExpenses_Checked
  9710. })
  9711. .Where(x => x.Id == id)
  9712. .ExecuteCommandAsync();
  9713. if (upd < 1) return Ok(JsonView(false));
  9714. }
  9715. return Ok(JsonView(new { parentId = id }));
  9716. }
  9717. /// <summary>
  9718. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9719. /// </summary>
  9720. /// <returns></returns>
  9721. [HttpPost]
  9722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9723. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9724. {
  9725. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9726. // if (provinceId < 1) provinceId = 122;
  9727. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9728. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9729. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9730. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9731. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9732. var checkboxInfo = new Grp_EnterExitCost()
  9733. {
  9734. Id = id,
  9735. //ProvinceId = provinceId,
  9736. DiId = diId,
  9737. CreateUserId = currUserId
  9738. };
  9739. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9740. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9741. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9742. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9743. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9744. if (id <= 0) //add
  9745. {
  9746. checkboxInfo.CreateUserId = dto.CurrUserId;
  9747. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9748. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9749. if (add < 1) return Ok(JsonView(false));
  9750. }
  9751. else //update
  9752. {
  9753. ////验证编辑权限
  9754. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9755. //if (!isEdit) return Ok(JsonView(false, msg));
  9756. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9757. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9758. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9759. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9760. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9761. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9762. .Where(x => x.Id == id)
  9763. .ExecuteCommandAsync();
  9764. if (upd < 1) return Ok(JsonView(false));
  9765. }
  9766. return Ok(JsonView(new { parentId = id }));
  9767. }
  9768. /// <summary>
  9769. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9770. /// </summary>
  9771. /// <returns></returns>
  9772. [HttpPost]
  9773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9774. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9775. {
  9776. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9777. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9778. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9779. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9780. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9781. info.FirstItemRemark = dto.FirstItemRemark;
  9782. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9783. int id = dto.Id;
  9784. if (id <= 0) //add
  9785. {
  9786. info.CreateUserId = dto.CurrUserId;
  9787. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9788. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9789. if (add < 1) return Ok(JsonView(false));
  9790. id = add;
  9791. }
  9792. else //update
  9793. {
  9794. ////验证编辑权限
  9795. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9796. //if (!isEdit) return Ok(JsonView(false, msg));
  9797. var upd = await _sqlSugar.Updateable(info)
  9798. .UpdateColumns(x => new
  9799. {
  9800. x.ChoiceOne,
  9801. x.InsidePay,
  9802. x.VisaRemark,
  9803. x.Visa,
  9804. x.Service,
  9805. x.Safe,
  9806. x.Ticket,
  9807. x.HeSuan,
  9808. x.YiMiao,
  9809. x.FirstItemRemark
  9810. })
  9811. .Where(x => x.Id == id)
  9812. .ExecuteCommandAsync();
  9813. if (upd < 1) return Ok(JsonView(false));
  9814. }
  9815. //消息通知
  9816. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9817. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9818. }
  9819. /// <summary>
  9820. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9821. /// </summary>
  9822. /// <returns></returns>
  9823. [HttpPost]
  9824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9825. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9826. {
  9827. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9828. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9829. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9830. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9831. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9832. info.DiId = dto.DiId;
  9833. //info.ProvinceId = dto.ProvinceId;
  9834. info.OutsideJJPay = dto.OutsideJJPay;
  9835. info.OutsideGWPay = dto.OutsideGWPay;
  9836. info.OutsideTDPay = dto.OutsideTDPay;
  9837. info.AirJJ = dto.AirJJ;
  9838. info.AirGW = dto.AirGW;
  9839. info.AirTD = dto.AirTD;
  9840. info.CityTranffic = dto.CityTranffic;
  9841. info.TwoItemRemark = dto.TwoItemRemark;
  9842. info.SumJJC = dto.ChoiceTwoJJ;
  9843. info.SumGWC = dto.ChoiceTwoGW;
  9844. info.SumTDC = dto.ChoiceTwoTD;
  9845. int id = dto.Id;
  9846. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9847. if (id <= 0) //add
  9848. {
  9849. info.CreateUserId = dto.CurrUserId;
  9850. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9851. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9852. if (addId <= 0) return Ok(JsonView(false));
  9853. id = addId;
  9854. }
  9855. else //update
  9856. {
  9857. ////验证编辑权限
  9858. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9859. //if (!isEdit) return Ok(JsonView(false, msg));
  9860. var upd = await _sqlSugar.Updateable(info)
  9861. .UpdateColumns(x => new
  9862. {
  9863. x.SumJJC,
  9864. x.OutsideJJPay,
  9865. x.SumGWC,
  9866. x.OutsideGWPay,
  9867. x.SumTDC,
  9868. x.OutsideTDPay,
  9869. x.AirJJ,
  9870. x.AirGW,
  9871. x.AirTD,
  9872. x.CityTranffic,
  9873. x.TwoItemRemark
  9874. })
  9875. .Where(x => x.Id == id)
  9876. .ExecuteCommandAsync();
  9877. if (upd < 1) return Ok(JsonView(false));
  9878. }
  9879. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9880. gwcItemTotal = info.AirGW + info.CityTranffic;
  9881. tdcItemTotal = info.AirTD + info.CityTranffic;
  9882. //消息通知
  9883. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9884. return Ok(JsonView(new
  9885. {
  9886. parentId = id,
  9887. choiceTwoJJ = dto.ChoiceTwoJJ,
  9888. jjcItemTotal = jjcItemTotal,
  9889. choiceTwoGW = dto.ChoiceTwoGW,
  9890. gwcItemTotal = gwcItemTotal,
  9891. choiceTwoTD = dto.ChoiceTwoTD,
  9892. tdcItemTotal = tdcItemTotal
  9893. }));
  9894. }
  9895. /// <summary>
  9896. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9897. /// </summary>
  9898. /// <returns></returns>
  9899. [HttpPost]
  9900. [ApiExplorerSettings(IgnoreApi = true)]
  9901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9902. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9903. {
  9904. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9905. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9906. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9907. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9908. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9909. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9910. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9911. var infos = infos1.Select(x => new Grp_DayAndCost
  9912. {
  9913. Id = x.Id,
  9914. DiId = dto.DiId,
  9915. Type = dto.FeeType,
  9916. Days = x.Days,
  9917. NationalTravelFeeId = x.NationalTravelFeeId,
  9918. Cost = x.Cost,
  9919. Currency = x.Currency,
  9920. SubTotal = x.SubTotal,
  9921. CreateUserId = dto.CurrUserId
  9922. })
  9923. .ToList();
  9924. var adds = infos.Where(x => x.Id <= 0).ToList();
  9925. var upds = infos.Where(x => x.Id > 0).ToList();
  9926. if (adds.Count > 0)
  9927. {
  9928. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9929. if (add < 1) return Ok(JsonView(false));
  9930. }
  9931. if (upds.Count > 0)
  9932. {
  9933. var upd = await _sqlSugar.Updateable(adds)
  9934. .UpdateColumns(x => new
  9935. {
  9936. x.Days,
  9937. x.NationalTravelFeeId,
  9938. x.Cost,
  9939. x.Currency,
  9940. x.SubTotal
  9941. })
  9942. .WhereColumns(x => new { x.Id })
  9943. .ExecuteCommandAsync();
  9944. if (upd < 1) return Ok(JsonView(false));
  9945. }
  9946. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9947. //消息通知
  9948. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9949. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9950. return Ok(JsonView(new { itemTotal = itemTotal }));
  9951. }
  9952. /// <summary>
  9953. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9954. /// </summary>
  9955. /// <returns></returns>
  9956. [HttpPost]
  9957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9958. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9959. {
  9960. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9961. int subId = dto.SubId, feeType = dto.FeeType;
  9962. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9963. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9964. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9965. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9966. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9967. subInfo.Id = subId;
  9968. subInfo.DiId = dto.DiId;
  9969. if (feeType == 3) subInfo.Type = 1;
  9970. else if (feeType == 4) subInfo.Type = 2;
  9971. else if (feeType == 5) subInfo.Type = 3;
  9972. else if (feeType == 6) subInfo.Type = 4;
  9973. subInfo.CreateUserId = dto.CurrUserId;
  9974. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9975. if (parentId < 1) return Ok(JsonView(false));
  9976. //子表op
  9977. if (subId < 1)
  9978. {
  9979. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9980. if (subAdd < 1) return Ok(JsonView(false));
  9981. }
  9982. else
  9983. {
  9984. ////验证编辑权限
  9985. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9986. //if (!isEdit) return Ok(JsonView(false, msg));
  9987. var subUpd = await _sqlSugar.Updateable(subInfo)
  9988. .UpdateColumns(x => new
  9989. {
  9990. x.Days,
  9991. x.NationalTravelFeeId,
  9992. x.Cost,
  9993. x.Currency,
  9994. x.SubTotal
  9995. })
  9996. .WhereColumns(x => new { x.Id })
  9997. .ExecuteCommandAsync();
  9998. if (subUpd < 1) return Ok(JsonView(false));
  9999. }
  10000. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10001. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10002. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10003. }
  10004. /// <summary>
  10005. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10006. /// </summary>
  10007. /// <returns></returns>
  10008. [HttpPost]
  10009. [ApiExplorerSettings(IgnoreApi = true)]
  10010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10011. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10012. {
  10013. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10014. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10015. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10016. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10017. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10018. {
  10019. Id = x.Id,
  10020. Diid = dto.DiId,
  10021. SetDataId = x.SetDataId,
  10022. Index = x.Index,
  10023. Cost = x.Cost,
  10024. Currency = x.Currency,
  10025. SubTotal = x.SubTotal,
  10026. CreateUserId = dto.CurrUserId,
  10027. Remark = x.Remark
  10028. }).ToList();
  10029. var adds = infos.Where(x => x.Id <= 0).ToList();
  10030. var upds = infos.Where(x => x.Id > 0).ToList();
  10031. if (adds.Count > 0)
  10032. {
  10033. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10034. if (add < 1) return Ok(JsonView(false));
  10035. }
  10036. if (upds.Count > 0)
  10037. {
  10038. var upd = await _sqlSugar.Updateable(adds)
  10039. .UpdateColumns(x => new
  10040. {
  10041. x.Index,
  10042. x.SetDataId,
  10043. x.Cost,
  10044. x.Currency,
  10045. x.SubTotal,
  10046. x.Remark
  10047. })
  10048. .WhereColumns(x => new { x.Id })
  10049. .ExecuteCommandAsync();
  10050. if (upd < 1) return Ok(JsonView(false));
  10051. }
  10052. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10053. //消息通知
  10054. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10055. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10056. return Ok(JsonView(new { itemTotal = itemTotal }));
  10057. }
  10058. /// <summary>
  10059. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10060. /// </summary>
  10061. /// <returns></returns>
  10062. [HttpPost]
  10063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10064. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10065. {
  10066. int subId = dto.SubId;
  10067. int diId = dto.Diid;
  10068. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10069. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10070. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10071. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10072. subInfo.Id = subId;
  10073. subInfo.Diid = dto.Diid;
  10074. subInfo.CreateUserId = dto.CurrUserId;
  10075. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10076. if (parentId < 1) return Ok(JsonView(false));
  10077. #region 子表op
  10078. if (subId < 1)//add
  10079. {
  10080. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10081. if (subAdd < 1) return Ok(JsonView(false));
  10082. }
  10083. else //upd
  10084. {
  10085. ////验证编辑权限
  10086. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10087. //if (!isEdit) return Ok(JsonView(false, msg));
  10088. var subUpd = await _sqlSugar.Updateable(subInfo)
  10089. .UpdateColumns(x => new
  10090. {
  10091. x.Index,
  10092. x.SetDataId,
  10093. x.Cost,
  10094. x.Currency,
  10095. x.SubTotal,
  10096. x.Remark
  10097. })
  10098. .WhereColumns(x => new { x.Id })
  10099. .ExecuteCommandAsync();
  10100. if (subUpd < 1) return Ok(JsonView(false));
  10101. }
  10102. #endregion
  10103. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10104. //消息通知
  10105. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10106. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10107. }
  10108. /// <summary>
  10109. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10110. /// </summary>
  10111. /// <returns></returns>
  10112. [HttpPost]
  10113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10114. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10115. {
  10116. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10117. if (data.Code != 0)
  10118. {
  10119. return Ok(JsonView(false, data.Msg));
  10120. }
  10121. return Ok(JsonView(true, "操作成功!", data.Data));
  10122. }
  10123. /// <summary>
  10124. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10125. /// </summary>
  10126. /// <param name="dto"></param>
  10127. /// <returns></returns>
  10128. [HttpPost]
  10129. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10130. {
  10131. var data = new Grp_DayOtherPrice()
  10132. {
  10133. Id = dto.Id,
  10134. IsDel = 1,
  10135. DeleteUserId = dto.DeleteUserId,
  10136. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10137. };
  10138. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10139. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10140. return Ok(JsonView(false, "删除失败!"));
  10141. }
  10142. #endregion
  10143. #endregion
  10144. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10145. /// <summary>
  10146. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10147. /// </summary>
  10148. /// <returns></returns>
  10149. [HttpGet]
  10150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10151. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10152. {
  10153. var provData = await _groupRepository.ProvinceBasicSource();
  10154. return Ok(JsonView(true, "查询成功!", provData));
  10155. }
  10156. /// <summary>
  10157. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10158. /// </summary>
  10159. /// <returns></returns>
  10160. [HttpPost]
  10161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10162. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10163. {
  10164. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10165. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10166. RefAsync<int> total = 0;
  10167. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10168. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10169. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10170. .Select(x => new
  10171. {
  10172. Id = x.Id,
  10173. DraftName = x.DraftName,
  10174. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10175. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10176. .Any()
  10177. })
  10178. .OrderByDescending(x => x.Id)
  10179. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10180. return Ok(JsonView(true, "查询成功!", data, total));
  10181. }
  10182. /// <summary>
  10183. /// 出入境费用-草稿 移动端
  10184. /// 获取币种基础数据(含逻辑处理)
  10185. /// </summary>
  10186. /// <returns></returns>
  10187. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10188. {
  10189. return await GeneralMethod.EnterExitCostInitRate();
  10190. }
  10191. /// <summary>
  10192. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10193. /// </summary>
  10194. /// <returns></returns>
  10195. [HttpPost]
  10196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10197. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10198. {
  10199. //验证城市归属并给默认值
  10200. int provinceId = dto.ProvinceId;
  10201. if (provinceId < 1) provinceId = 122;
  10202. var dataSource = await _sqlSugar
  10203. .Queryable<Sys_SetData>()
  10204. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10205. .ToListAsync();
  10206. //三公费用-Word明细类型
  10207. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10208. .Select(x => new SetDataInfoView
  10209. {
  10210. Id = x.Id,
  10211. Name = x.Name,
  10212. Remark = x.Remark
  10213. })
  10214. .ToList();
  10215. //三公费用-Excel明细类型
  10216. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10217. .Select(x => new SetDataInfoView
  10218. {
  10219. Id = x.Id,
  10220. Name = x.Name,
  10221. Remark = x.Remark
  10222. })
  10223. .ToList();
  10224. //默认币种显示
  10225. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10226. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10227. return Ok(JsonView(true, "查询成功!", new
  10228. {
  10229. WordTypeData = wordTypeData,
  10230. ExcelTypeData = excelTypeData,
  10231. CurrencyInit = _currencyInfos,
  10232. viewPermissionData = viewPermissionData
  10233. }));
  10234. }
  10235. /// <summary>
  10236. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10237. /// </summary>
  10238. /// <returns></returns>
  10239. [HttpPost]
  10240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10241. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10242. {
  10243. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10244. RefAsync<int> total = 0;
  10245. int diId = 0;
  10246. var status = int.TryParse(dto.GroupName, out diId);
  10247. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10248. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10249. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10250. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10251. .OrderByDescending(x => x.VisitStartDate)
  10252. .Select(x => new
  10253. {
  10254. Id = x.Id,
  10255. GroupName = x.TeamName
  10256. })
  10257. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10258. return Ok(JsonView(true, "查询成功!", data, total));
  10259. }
  10260. /// <summary>
  10261. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10262. /// </summary>
  10263. /// <returns></returns>
  10264. [HttpPost]
  10265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10266. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10267. {
  10268. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10269. RefAsync<int> total = 0;
  10270. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10271. .Where(x => x.IsDel == 0 && x.STid == 66)
  10272. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10273. .Select(x => new
  10274. {
  10275. id = x.Id,
  10276. name = x.Name,
  10277. remark = x.Remark,
  10278. })
  10279. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10280. return Ok(JsonView(true, "查询成功!", data, total));
  10281. }
  10282. /// <summary>
  10283. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10284. /// </summary>
  10285. /// <returns></returns>
  10286. [HttpPost]
  10287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10288. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10289. {
  10290. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10291. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10292. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10293. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10294. var groupOtherRateData = groupRateData.TeamRates;
  10295. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10296. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10297. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10298. groupOtherRateData = groupOtherRateData
  10299. .Select(x => new TeamRateDescAddCurrencyIdView
  10300. {
  10301. CurrencyId = x.CurrencyId,
  10302. CurrencyName = x.CurrencyName,
  10303. CurrencyCode = x.CurrencyCode,
  10304. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10305. }).ToList();
  10306. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10307. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10308. }
  10309. /// <summary>
  10310. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10311. /// </summary>
  10312. /// <returns></returns>
  10313. [HttpPost]
  10314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10315. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10316. {
  10317. int portType = dto.PortType;
  10318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10319. var tipsData = new List<int>() { 1, 2, 3 };
  10320. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10321. if (dto.TipsType == 1)
  10322. {
  10323. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10324. }
  10325. else if (dto.TipsType == 2)
  10326. {
  10327. if (portType == 2)
  10328. {
  10329. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10330. }
  10331. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10332. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10333. .Select(x => x.NationalTravelFeeId)
  10334. .Distinct()
  10335. .ToListAsync();
  10336. if (portType == 2)
  10337. {
  10338. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10339. }
  10340. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10341. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10342. .Select(x => x.Country)
  10343. .Distinct()
  10344. .ToArrayAsync();
  10345. if (portType == 2)
  10346. {
  10347. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10348. }
  10349. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10350. return Ok(JsonView(true, "查询成功!", new
  10351. {
  10352. totalAmt = totalAmt,
  10353. remark = remark
  10354. }));
  10355. }
  10356. else if (dto.TipsType == 3)
  10357. {
  10358. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10359. }
  10360. return Ok(JsonView(false));
  10361. }
  10362. /// <summary>
  10363. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10364. /// </summary>
  10365. /// <returns></returns>
  10366. [HttpPost]
  10367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10368. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10369. {
  10370. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10371. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10372. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10373. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10374. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10375. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10376. var info = new Grp_EnterExitCostDraft()
  10377. {
  10378. ProvinceId = dto.ProvinceId,
  10379. DraftName = dto.DraftName,
  10380. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10381. CreateUserId = dto.CurrUserId
  10382. };
  10383. _sqlSugar.BeginTran();
  10384. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10385. if (draftId < 1)
  10386. {
  10387. _sqlSugar.RollbackTran();
  10388. return Ok(JsonView(false, "草稿创建失败!"));
  10389. }
  10390. //添加默认权限
  10391. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10392. _sqlSugar.CommitTran();
  10393. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10394. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10395. mobileInfo.Id = draftId;
  10396. mobileInfo.DraftName = dto.DraftName;
  10397. mobileInfo.Currencys = rateInfos;
  10398. mobileInfo.IsAssignPerm = assignPerm;
  10399. return Ok(JsonView(mobileInfo));
  10400. }
  10401. /// <summary>
  10402. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10403. /// </summary>
  10404. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10405. /// <summary>
  10406. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10407. /// </summary>
  10408. /// <returns></returns>
  10409. [HttpPost]
  10410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10411. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10412. {
  10413. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10414. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10415. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10416. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10417. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10418. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10419. //验证查看编辑权限
  10420. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10421. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10422. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10423. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10424. mobileInfo.IsAssignPerm = assignPerm;
  10425. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10426. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10427. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10428. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10429. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10430. {
  10431. ParentId = dac.ParentId,
  10432. SubId = dac.Id,
  10433. Type = dac.Type,
  10434. Days = dac.Days,
  10435. NationalTravelFeeId = dac.NationalTravelFeeId,
  10436. Arae = $"{ntf.Country}-{ntf.City}",
  10437. Cost = dac.Cost,
  10438. Currency = dac.Currency,
  10439. CurrencyName = sd.Name,
  10440. SubTotal = dac.SubTotal,
  10441. })
  10442. .ToList();
  10443. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10444. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10445. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10446. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10447. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10448. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10449. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10450. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10451. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10452. //其他款项
  10453. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10454. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10455. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10456. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10457. .OrderBy((dop, sd1, sd2) => dop.Index)
  10458. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10459. {
  10460. ParentId = dop.ParentId,
  10461. SubId = dop.Id,
  10462. Index = dop.Index,
  10463. SetDataId = dop.SetDataId,
  10464. SetDataName = sd1.Name,
  10465. Cost = dop.Cost,
  10466. Currency = dop.Currency,
  10467. CurrencyName = sd2.Remark,
  10468. SubTotal = dop.SubTotal,
  10469. Remark = dop.Remark,
  10470. })
  10471. .ToArray();
  10472. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10473. return Ok(mobileInfo);
  10474. }
  10475. /// <summary>
  10476. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10477. /// </summary>
  10478. /// <returns></returns>
  10479. [HttpPost]
  10480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10481. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10482. {
  10483. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10484. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10485. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10486. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10487. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10488. //验证查看编辑权限
  10489. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10490. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10491. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10492. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10493. var subType = dto.SubType;
  10494. if (subType == 1) //1:境内费用
  10495. {
  10496. var oneData = new ChoiceOneMobileSubInfoView()
  10497. {
  10498. Id = eecInfo.Id,
  10499. ChoiceOne = eecInfo.ChoiceOne,
  10500. ChoiceOneTotalCost = eecInfo.InsidePay,
  10501. Visa = eecInfo.Visa,
  10502. VisaRemark = eecInfo.VisaRemark,
  10503. YiMiao = eecInfo.YiMiao,
  10504. HeSuan = eecInfo.HeSuan,
  10505. Service = eecInfo.Service,
  10506. Ticket = eecInfo.Ticket,
  10507. Safe = eecInfo.Safe,
  10508. FirstItemRemark = eecInfo.FirstItemRemark
  10509. };
  10510. return Ok(JsonView(oneData));
  10511. }
  10512. else if (subType == 2) //2:国际旅费
  10513. {
  10514. var twoData = new ChoiceTwoMobileSubInfoView()
  10515. {
  10516. Id = eecInfo.Id,
  10517. ChoiceTwoJJ = eecInfo.SumJJC,
  10518. OutsideJJPay = eecInfo.OutsideJJPay,
  10519. ChoiceTwoGW = eecInfo.SumGWC,
  10520. OutsideGWPay = eecInfo.OutsideGWPay,
  10521. ChoiceTwoTD = eecInfo.SumTDC,
  10522. OutsideTDPay = eecInfo.OutsideTDPay,
  10523. AirJJ = eecInfo.AirJJ,
  10524. AirGW = eecInfo.AirGW,
  10525. AirTD = eecInfo.AirTD,
  10526. CityTranffic = eecInfo.CityTranffic,
  10527. TwoItemRemark = eecInfo.TwoItemRemark
  10528. };
  10529. return Ok(JsonView(twoData));
  10530. }
  10531. else if (subType == 3) //3:住宿费
  10532. {
  10533. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10534. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10535. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10536. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10537. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10538. {
  10539. ParentId = dac.ParentId,
  10540. SubId = dac.Id,
  10541. Type = dac.Type,
  10542. Days = dac.Days,
  10543. NationalTravelFeeId = dac.NationalTravelFeeId,
  10544. Arae = $"{ntf.Country}-{ntf.City}",
  10545. Cost = dac.Cost,
  10546. Currency = dac.Currency,
  10547. CurrencyName = sd.Name,
  10548. SubTotal = dac.SubTotal,
  10549. })
  10550. .ToArray();
  10551. var data = new ChoiceDraftMobileSubInfo3To6View()
  10552. {
  10553. ParentId = eecInfo.Id,
  10554. Choice = eecInfo.ChoiceThree,
  10555. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10556. Details = dayAndCostDatas
  10557. };
  10558. return Ok(JsonView(data));
  10559. }
  10560. else if (subType == 4) //4:伙食费
  10561. {
  10562. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10563. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10564. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10565. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10566. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10567. {
  10568. ParentId = dac.ParentId,
  10569. SubId = dac.Id,
  10570. Type = dac.Type,
  10571. Days = dac.Days,
  10572. NationalTravelFeeId = dac.NationalTravelFeeId,
  10573. Arae = $"{ntf.Country}-{ntf.City}",
  10574. Cost = dac.Cost,
  10575. Currency = dac.Currency,
  10576. CurrencyName = sd.Name,
  10577. SubTotal = dac.SubTotal,
  10578. })
  10579. .ToArray();
  10580. var data = new ChoiceDraftMobileSubInfo3To6View()
  10581. {
  10582. ParentId = eecInfo.Id,
  10583. Choice = eecInfo.ChoiceFour,
  10584. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10585. Details = dayAndCostDatas
  10586. };
  10587. return Ok(JsonView(data));
  10588. }
  10589. else if (subType == 5) //5:公杂费
  10590. {
  10591. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10592. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10593. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10594. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10595. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10596. {
  10597. ParentId = dac.ParentId,
  10598. SubId = dac.Id,
  10599. Type = dac.Type,
  10600. Days = dac.Days,
  10601. NationalTravelFeeId = dac.NationalTravelFeeId,
  10602. Arae = $"{ntf.Country}-{ntf.City}",
  10603. Cost = dac.Cost,
  10604. Currency = dac.Currency,
  10605. CurrencyName = sd.Name,
  10606. SubTotal = dac.SubTotal,
  10607. })
  10608. .ToArray();
  10609. var data = new ChoiceDraftMobileSubInfo3To6View()
  10610. {
  10611. ParentId = eecInfo.Id,
  10612. Choice = eecInfo.ChoiceFive,
  10613. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10614. Details = dayAndCostDatas
  10615. };
  10616. return Ok(JsonView(data));
  10617. }
  10618. else if (subType == 6) //6:培训费
  10619. {
  10620. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10621. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10622. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10623. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10624. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10625. {
  10626. ParentId = dac.ParentId,
  10627. SubId = dac.Id,
  10628. Type = dac.Type,
  10629. Days = dac.Days,
  10630. NationalTravelFeeId = dac.NationalTravelFeeId,
  10631. Arae = $"{ntf.Country}-{ntf.City}",
  10632. Cost = dac.Cost,
  10633. Currency = dac.Currency,
  10634. CurrencyName = sd.Name,
  10635. SubTotal = dac.SubTotal,
  10636. })
  10637. .ToArray();
  10638. var data = new ChoiceDraftMobileSubInfo3To6View()
  10639. {
  10640. ParentId = eecInfo.Id,
  10641. Choice = eecInfo.ChoiceSix,
  10642. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10643. Details = dayAndCostDatas
  10644. };
  10645. return Ok(JsonView(data));
  10646. }
  10647. else if (subType == 7) //7:其他
  10648. {
  10649. //其他款项
  10650. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10651. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10652. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10653. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10654. .OrderBy((dop, sd1, sd2) => dop.Index)
  10655. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10656. {
  10657. ParentId = dop.ParentId,
  10658. SubId = dop.Id,
  10659. Index = dop.Index,
  10660. SetDataId = dop.SetDataId,
  10661. SetDataName = sd1.Name,
  10662. Cost = dop.Cost,
  10663. Currency = dop.Currency,
  10664. CurrencyName = sd2.Name,
  10665. SubTotal = dop.SubTotal,
  10666. Remark = dop.Remark,
  10667. })
  10668. .ToArray();
  10669. var data = new ChoiceSevenDraftMobileSubInfoView()
  10670. {
  10671. ParentId = eecInfo.Id,
  10672. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10673. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10674. Details = otherData
  10675. };
  10676. return Ok(JsonView(data));
  10677. }
  10678. return Ok(JsonView(false));
  10679. }
  10680. #region op
  10681. /// <summary>
  10682. /// 移动端更新费用消息通知
  10683. /// </summary>
  10684. /// <param name="draftId"></param>
  10685. /// <param name="id"></param>
  10686. /// <param name="currUserId"></param>
  10687. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10688. {
  10689. try
  10690. {
  10691. ////生成默认文件pdf并且通知人员
  10692. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10693. //{
  10694. // DiId = draftId,
  10695. // ExportType = 1,
  10696. // SubTypeId = 1005
  10697. //}, "pdf");
  10698. ////发送通知
  10699. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10700. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10701. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10702. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10703. ////汇率信息记录
  10704. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10705. }
  10706. catch (Exception ex)
  10707. {
  10708. //记录日志
  10709. throw;
  10710. }
  10711. }
  10712. /// <summary>
  10713. /// 验证出入境费用数据是否存在
  10714. /// 不存在添加
  10715. /// </summary>
  10716. /// <param name="draftId"></param>
  10717. /// <param name="currUserId"></param>
  10718. /// <returns></returns>
  10719. /// <exception cref="CustomException"></exception>
  10720. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10721. {
  10722. var parentId = 0;
  10723. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10724. if (info != null) parentId = info.Id;
  10725. else
  10726. {
  10727. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10728. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10729. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10730. parentId = addId;
  10731. }
  10732. return parentId;
  10733. }
  10734. /// <summary>
  10735. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10736. /// </summary>
  10737. /// <returns></returns>
  10738. [HttpPost]
  10739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10740. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10741. {
  10742. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10743. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10744. //验证查看权限
  10745. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10746. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10747. var userIds = await _sqlSugar
  10748. .Queryable<Grp_EnterExitCostDraftPermission>()
  10749. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10750. .Select(x => x.UserId)
  10751. .ToArrayAsync();
  10752. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10753. var perUsersView = new List<dynamic>();
  10754. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10755. var viewPermissionData = new List<PermissionViewUserview>();
  10756. if (feeBasePerm.Any())
  10757. {
  10758. foreach (var item in feeBasePerm)
  10759. {
  10760. if (item.Users.Any())
  10761. {
  10762. viewPermissionData.AddRange(item.Users);
  10763. }
  10764. }
  10765. }
  10766. foreach (var item in perUsers)
  10767. {
  10768. bool isView1 = false;
  10769. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10770. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10771. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10772. }
  10773. return Ok(JsonView(perUsersView));
  10774. }
  10775. /// <summary>
  10776. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10777. /// </summary>
  10778. /// <returns></returns>
  10779. [HttpPost]
  10780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10781. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10782. {
  10783. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10784. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10785. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10786. //验证查看编辑权限
  10787. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10788. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10789. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10790. foreach (var userId in dto.UserIds)
  10791. {
  10792. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10793. }
  10794. if (permissions.Any())
  10795. {
  10796. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10797. {
  10798. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10799. }
  10800. _sqlSugar.BeginTran();
  10801. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10802. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10803. if (result < 1)
  10804. {
  10805. _sqlSugar.RollbackTran();
  10806. return Ok(JsonView(false));
  10807. }
  10808. _sqlSugar.CommitTran();
  10809. return Ok(JsonView(true));
  10810. }
  10811. return Ok(JsonView(false));
  10812. }
  10813. /// <summary>
  10814. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10815. /// </summary>
  10816. /// <returns></returns>
  10817. [HttpPost]
  10818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10819. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10820. {
  10821. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10822. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10823. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10824. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10825. int id = dto.DraftId;
  10826. if (id <= 0) //add
  10827. {
  10828. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10829. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10830. if (add < 1) return Ok(JsonView(false));
  10831. id = add;
  10832. }
  10833. else //update
  10834. {
  10835. //验证查看编辑权限
  10836. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10837. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10838. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10839. if (upd < 1) return Ok(JsonView(false));
  10840. }
  10841. return Ok(JsonView(new { parentId = id }));
  10842. }
  10843. /// <summary>
  10844. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10845. /// </summary>
  10846. /// <returns></returns>
  10847. [HttpPost]
  10848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10849. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10850. {
  10851. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10852. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10853. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10854. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10855. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10856. int id = dto.DraftId;
  10857. if (id <= 0) //add
  10858. {
  10859. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10860. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10861. if (add < 1) return Ok(JsonView(false));
  10862. id = add;
  10863. }
  10864. else //update
  10865. {
  10866. //验证查看编辑权限
  10867. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10868. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10869. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10870. if (upd < 1) return Ok(JsonView(false));
  10871. }
  10872. #region 汇率变更时更改币种相关费用
  10873. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10874. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10875. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10876. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10877. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10878. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10879. .Select((dac, sd) => new
  10880. {
  10881. dac.Id,
  10882. dac.ParentId,
  10883. CurrencyCode = sd.Name,
  10884. dac.Cost
  10885. })
  10886. .ToList();
  10887. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10888. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10889. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10890. .Select((dop, sd) => new
  10891. {
  10892. dop.Id,
  10893. dop.ParentId,
  10894. CurrencyCode = sd.Name,
  10895. dop.Cost
  10896. })
  10897. .ToList();
  10898. if (dayCosts.Count > 0)
  10899. {
  10900. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10901. foreach (var dc in new_dayCosts)
  10902. {
  10903. var thisCurrency = dc.Key.ToUpper();
  10904. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10905. if (thisRate == 0.00M) continue;
  10906. foreach (var dcSub in dc)
  10907. {
  10908. opDayCosts.Add(new Grp_DayAndCostDraft()
  10909. {
  10910. Id = dcSub.Id,
  10911. ParentId = dcSub.ParentId,
  10912. Cost = dcSub.Cost,
  10913. SubTotal = dcSub.Cost * thisRate,
  10914. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10915. });
  10916. }
  10917. }
  10918. if (opDayCosts.Count > 0)
  10919. {
  10920. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10921. }
  10922. }
  10923. if (dayOtherCosts.Count > 0)
  10924. {
  10925. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10926. foreach (var dc in new_dayOtherCosts)
  10927. {
  10928. var thisCurrency = dc.Key.ToUpper();
  10929. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10930. if (thisRate == 0.00M) continue;
  10931. foreach (var dcSub in dc)
  10932. {
  10933. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10934. {
  10935. Id = dcSub.Id,
  10936. ParentId = dcSub.ParentId,
  10937. Cost = dcSub.Cost,
  10938. SubTotal = dcSub.Cost * thisRate,
  10939. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10940. });
  10941. }
  10942. }
  10943. if (opDayOtherCosts.Count > 0)
  10944. {
  10945. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10946. }
  10947. }
  10948. #endregion
  10949. ////消息通知
  10950. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10951. ////汇率信息记录
  10952. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10953. return Ok(JsonView(new { parentId = id }));
  10954. }
  10955. /// <summary>
  10956. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10957. /// </summary>
  10958. /// <returns></returns>
  10959. [HttpPost]
  10960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10961. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10962. {
  10963. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10964. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10965. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10966. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10967. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10968. int id = dto.DraftId;
  10969. if (id <= 0) //add
  10970. {
  10971. checkboxInfo.ProvinceId = dto.ProvinceId;
  10972. checkboxInfo.CreateUserId = dto.CurrUserId;
  10973. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10974. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10975. if (add < 1) return Ok(JsonView(false));
  10976. }
  10977. else //update
  10978. {
  10979. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10980. .UpdateColumns(x => new
  10981. {
  10982. x.ChoiceOne,
  10983. x.ChoiceTwo,
  10984. x.SumJJC,
  10985. x.SumGWC,
  10986. x.SumTDC,
  10987. x.ChoiceThree,
  10988. x.ChoiceFour,
  10989. x.ChoiceFive,
  10990. x.ChoiceSix,
  10991. x.OtherExpenses_Checked
  10992. })
  10993. .Where(x => x.Id == id)
  10994. .ExecuteCommandAsync();
  10995. if (upd < 1) return Ok(JsonView(false));
  10996. }
  10997. return Ok(JsonView(new { parentId = id }));
  10998. }
  10999. /// <summary>
  11000. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11001. /// </summary>
  11002. /// <returns></returns>
  11003. [HttpPost]
  11004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11005. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11006. {
  11007. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11008. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11009. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11010. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11011. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11012. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11013. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11014. var checkboxInfo = new Grp_EnterExitCostDraft()
  11015. {
  11016. Id = draftId,
  11017. ProvinceId = dto.ProvinceId,
  11018. CreateUserId = currUserId
  11019. };
  11020. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11021. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11022. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11023. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11024. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11025. if (draftId <= 0) //add
  11026. {
  11027. checkboxInfo.CreateUserId = dto.CurrUserId;
  11028. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11029. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11030. if (add < 1) return Ok(JsonView(false));
  11031. }
  11032. else //update
  11033. {
  11034. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11035. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11036. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11037. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11038. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11039. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11040. .Where(x => x.Id == draftId)
  11041. .ExecuteCommandAsync();
  11042. if (upd < 1) return Ok(JsonView(false));
  11043. }
  11044. return Ok(JsonView(new { parentId = draftId }));
  11045. }
  11046. /// <summary>
  11047. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11048. /// </summary>
  11049. /// <returns></returns>
  11050. [HttpPost]
  11051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11052. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11053. {
  11054. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11055. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11056. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11057. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11058. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11059. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11060. info.ProvinceId = dto.ProvinceId;
  11061. info.FirstItemRemark = dto.FirstItemRemark;
  11062. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11063. if (id <= 0) //add
  11064. {
  11065. info.CreateUserId = dto.CurrUserId;
  11066. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11067. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11068. if (add < 1) return Ok(JsonView(false));
  11069. id = add;
  11070. }
  11071. else //update
  11072. {
  11073. var upd = await _sqlSugar.Updateable(info)
  11074. .UpdateColumns(x => new
  11075. {
  11076. x.ChoiceOne,
  11077. x.InsidePay,
  11078. x.VisaRemark,
  11079. x.Visa,
  11080. x.Service,
  11081. x.Safe,
  11082. x.Ticket,
  11083. x.HeSuan,
  11084. x.YiMiao,
  11085. x.FirstItemRemark
  11086. })
  11087. .Where(x => x.Id == id)
  11088. .ExecuteCommandAsync();
  11089. if (upd < 1) return Ok(JsonView(false));
  11090. }
  11091. ////消息通知
  11092. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11093. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11094. }
  11095. /// <summary>
  11096. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11097. /// </summary>
  11098. /// <returns></returns>
  11099. [HttpPost]
  11100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11101. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11102. {
  11103. int id = dto.DraftId;
  11104. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11105. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11106. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11107. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11108. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11109. info.ProvinceId = dto.ProvinceId;
  11110. info.OutsideJJPay = dto.OutsideJJPay;
  11111. info.OutsideGWPay = dto.OutsideGWPay;
  11112. info.OutsideTDPay = dto.OutsideTDPay;
  11113. info.AirJJ = dto.AirJJ;
  11114. info.AirGW = dto.AirGW;
  11115. info.AirTD = dto.AirTD;
  11116. info.CityTranffic = dto.CityTranffic;
  11117. info.TwoItemRemark = dto.TwoItemRemark;
  11118. info.SumJJC = dto.ChoiceTwoJJ;
  11119. info.SumGWC = dto.ChoiceTwoGW;
  11120. info.SumTDC = dto.ChoiceTwoTD;
  11121. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11122. if (id <= 0) //add
  11123. {
  11124. info.CreateUserId = dto.CurrUserId;
  11125. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11126. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11127. if (addId <= 0) return Ok(JsonView(false));
  11128. id = addId;
  11129. }
  11130. else //update
  11131. {
  11132. var upd = await _sqlSugar.Updateable(info)
  11133. .UpdateColumns(x => new
  11134. {
  11135. x.SumJJC,
  11136. x.OutsideJJPay,
  11137. x.SumGWC,
  11138. x.OutsideGWPay,
  11139. x.SumTDC,
  11140. x.OutsideTDPay,
  11141. x.AirJJ,
  11142. x.AirGW,
  11143. x.AirTD,
  11144. x.CityTranffic,
  11145. x.TwoItemRemark
  11146. })
  11147. .Where(x => x.Id == id)
  11148. .ExecuteCommandAsync();
  11149. if (upd < 1) return Ok(JsonView(false));
  11150. }
  11151. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11152. gwcItemTotal = info.AirGW + info.CityTranffic;
  11153. tdcItemTotal = info.AirTD + info.CityTranffic;
  11154. ////消息通知
  11155. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11156. return Ok(JsonView(new
  11157. {
  11158. parentId = id,
  11159. choiceTwoJJ = dto.ChoiceTwoJJ,
  11160. jjcItemTotal = jjcItemTotal,
  11161. choiceTwoGW = dto.ChoiceTwoGW,
  11162. gwcItemTotal = gwcItemTotal,
  11163. choiceTwoTD = dto.ChoiceTwoTD,
  11164. tdcItemTotal = tdcItemTotal
  11165. }));
  11166. }
  11167. /// <summary>
  11168. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11169. /// </summary>
  11170. /// <returns></returns>
  11171. [HttpPost]
  11172. [ApiExplorerSettings(IgnoreApi = true)]
  11173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11174. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11175. {
  11176. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11177. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11178. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11179. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11180. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11181. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11182. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11183. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11184. {
  11185. Id = x.Id,
  11186. ParentId = dto.DraftId,
  11187. Type = dto.FeeType,
  11188. Days = x.Days,
  11189. NationalTravelFeeId = x.NationalTravelFeeId,
  11190. Cost = x.Cost,
  11191. Currency = x.Currency,
  11192. SubTotal = x.SubTotal,
  11193. CreateUserId = dto.CurrUserId
  11194. })
  11195. .ToList();
  11196. var adds = infos.Where(x => x.Id <= 0).ToList();
  11197. var upds = infos.Where(x => x.Id > 0).ToList();
  11198. if (adds.Count > 0)
  11199. {
  11200. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11201. if (add < 1) return Ok(JsonView(false));
  11202. }
  11203. if (upds.Count > 0)
  11204. {
  11205. var upd = await _sqlSugar.Updateable(adds)
  11206. .UpdateColumns(x => new
  11207. {
  11208. x.Days,
  11209. x.NationalTravelFeeId,
  11210. x.Cost,
  11211. x.Currency,
  11212. x.SubTotal
  11213. })
  11214. .WhereColumns(x => new { x.Id })
  11215. .ExecuteCommandAsync();
  11216. if (upd < 1) return Ok(JsonView(false));
  11217. }
  11218. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11219. ////消息通知
  11220. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11221. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11222. return Ok(JsonView(new { itemTotal = itemTotal }));
  11223. }
  11224. /// <summary>
  11225. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11226. /// </summary>
  11227. /// <returns></returns>
  11228. [HttpPost]
  11229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11230. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11231. {
  11232. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11233. int subId = dto.SubId, feeType = dto.FeeType;
  11234. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11235. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11236. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11237. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11238. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11239. subInfo.Id = subId;
  11240. subInfo.ParentId = dto.DraftId;
  11241. if (feeType == 3) subInfo.Type = 1;
  11242. else if (feeType == 4) subInfo.Type = 2;
  11243. else if (feeType == 5) subInfo.Type = 3;
  11244. else if (feeType == 6) subInfo.Type = 4;
  11245. subInfo.CreateUserId = dto.CurrUserId;
  11246. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11247. if (parentId < 1) return Ok(JsonView(false));
  11248. //子表op
  11249. if (subId < 1)
  11250. {
  11251. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11252. if (subAdd < 1) return Ok(JsonView(false));
  11253. }
  11254. else
  11255. {
  11256. var subUpd = await _sqlSugar.Updateable(subInfo)
  11257. .UpdateColumns(x => new
  11258. {
  11259. x.Days,
  11260. x.NationalTravelFeeId,
  11261. x.Cost,
  11262. x.Currency,
  11263. x.SubTotal
  11264. })
  11265. .WhereColumns(x => new { x.Id })
  11266. .ExecuteCommandAsync();
  11267. if (subUpd < 1) return Ok(JsonView(false));
  11268. }
  11269. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11270. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11271. }
  11272. /// <summary>
  11273. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11274. /// </summary>
  11275. /// <returns></returns>
  11276. [HttpPost]
  11277. [ApiExplorerSettings(IgnoreApi = true)]
  11278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11279. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11280. {
  11281. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11282. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11283. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11284. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11285. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11286. {
  11287. Id = x.Id,
  11288. ParentId = dto.DraftId,
  11289. SetDataId = x.SetDataId,
  11290. Index = x.Index,
  11291. Cost = x.Cost,
  11292. Currency = x.Currency,
  11293. SubTotal = x.SubTotal,
  11294. CreateUserId = dto.CurrUserId,
  11295. Remark = x.Remark
  11296. }).ToList();
  11297. var adds = infos.Where(x => x.Id <= 0).ToList();
  11298. var upds = infos.Where(x => x.Id > 0).ToList();
  11299. if (adds.Count > 0)
  11300. {
  11301. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11302. if (add < 1) return Ok(JsonView(false));
  11303. }
  11304. if (upds.Count > 0)
  11305. {
  11306. var upd = await _sqlSugar.Updateable(adds)
  11307. .UpdateColumns(x => new
  11308. {
  11309. x.Index,
  11310. x.SetDataId,
  11311. x.Cost,
  11312. x.Currency,
  11313. x.SubTotal,
  11314. x.Remark
  11315. })
  11316. .WhereColumns(x => new { x.Id })
  11317. .ExecuteCommandAsync();
  11318. if (upd < 1) return Ok(JsonView(false));
  11319. }
  11320. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11321. //消息通知
  11322. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11323. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11324. return Ok(JsonView(new { itemTotal = itemTotal }));
  11325. }
  11326. /// <summary>
  11327. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11328. /// </summary>
  11329. /// <returns></returns>
  11330. [HttpPost]
  11331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11332. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11333. {
  11334. int subId = dto.SubId, id = dto.DraftId;
  11335. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11336. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11337. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11338. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11339. subInfo.Id = subId;
  11340. subInfo.ParentId = id;
  11341. subInfo.CreateUserId = dto.CurrUserId;
  11342. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11343. if (parentId < 1) return Ok(JsonView(false));
  11344. #region 子表op
  11345. if (subId < 1)//add
  11346. {
  11347. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11348. if (subAdd < 1) return Ok(JsonView(false));
  11349. }
  11350. else //upd
  11351. {
  11352. var subUpd = await _sqlSugar.Updateable(subInfo)
  11353. .UpdateColumns(x => new
  11354. {
  11355. x.Index,
  11356. x.SetDataId,
  11357. x.Cost,
  11358. x.Currency,
  11359. x.SubTotal,
  11360. x.Remark
  11361. })
  11362. .WhereColumns(x => new { x.Id })
  11363. .ExecuteCommandAsync();
  11364. if (subUpd < 1) return Ok(JsonView(false));
  11365. }
  11366. #endregion
  11367. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11368. ////消息通知
  11369. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11370. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11371. }
  11372. /// <summary>
  11373. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11374. /// </summary>
  11375. /// <returns></returns>
  11376. [HttpPost]
  11377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11378. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11379. {
  11380. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11381. if (data.Code != 0)
  11382. {
  11383. return Ok(JsonView(false, data.Msg));
  11384. }
  11385. return Ok(JsonView(true, "操作成功!", data.Data));
  11386. }
  11387. /// <summary>
  11388. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11389. /// </summary>
  11390. /// <param name="dto"></param>
  11391. /// <returns></returns>
  11392. [HttpPost]
  11393. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11394. {
  11395. var data = new Grp_DayOtherPriceDraft()
  11396. {
  11397. Id = dto.Id,
  11398. IsDel = 1,
  11399. DeleteUserId = dto.DeleteUserId,
  11400. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11401. };
  11402. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11403. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11404. return Ok(JsonView(false, "删除失败!"));
  11405. }
  11406. #endregion
  11407. #endregion
  11408. #region 团组经理模块 出入境费用报价表
  11409. /// <summary>
  11410. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11411. /// </summary>
  11412. /// <returns></returns>
  11413. [HttpPost]
  11414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11415. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11416. {
  11417. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11418. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11419. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11420. initRates.Insert(0, cnyInfo);
  11421. liveRates.Insert(0, cnyInfo);
  11422. return Ok(JsonView(true, "查询成功!", new
  11423. {
  11424. InitRates = initRates,
  11425. LiveRates = liveRates
  11426. }));
  11427. }
  11428. /// <summary>
  11429. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11430. /// </summary>
  11431. /// <returns></returns>
  11432. [HttpPost]
  11433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11434. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  11435. {
  11436. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11437. }
  11438. /// <summary>
  11439. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11440. /// </summary>
  11441. /// <returns></returns>
  11442. [HttpPost]
  11443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11444. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  11445. {
  11446. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11447. }
  11448. /// <summary>
  11449. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11450. /// </summary>
  11451. /// <returns></returns>
  11452. [HttpPost]
  11453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11454. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11455. {
  11456. int groupId = dto.DiId,
  11457. currUserId = dto.CurrUserId;
  11458. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11459. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11460. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11461. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  11462. var infoView = info.Data as EnterExitCostInfoView;
  11463. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11464. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11465. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11466. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11467. var eecRates = infoView.Currencys;
  11468. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11469. int pplNum = 1;
  11470. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11471. var views = new List<QuoteSubItemInfo>();
  11472. #region 数据填充
  11473. var intTravelCosts = new List<QuoteSubItemInfo>();
  11474. #region 机票费用 1354
  11475. int intTravelIndex = 1;
  11476. if (infoView.SumJJC == 1)
  11477. {
  11478. intTravelCosts.Add(new QuoteSubItemInfo
  11479. {
  11480. ItemId = 1354,
  11481. Index = intTravelIndex,
  11482. FeeName = "经济舱",
  11483. UnitPrice = infoView.AirJJ,
  11484. Currency = "CNY",
  11485. Quantity = 1,
  11486. PplNum = 1,
  11487. TotalAmt = infoView.AirJJ,
  11488. Remark = "",
  11489. });
  11490. intTravelIndex++;
  11491. }
  11492. if (infoView.SumGWC == 1)
  11493. {
  11494. intTravelCosts.Add(new QuoteSubItemInfo
  11495. {
  11496. ItemId = 1354,
  11497. Index = intTravelIndex,
  11498. FeeName = "公务舱",
  11499. UnitPrice = infoView.AirGW,
  11500. Currency = "CNY",
  11501. Quantity = 1,
  11502. PplNum = 1,
  11503. TotalAmt = infoView.AirGW,
  11504. Remark = "",
  11505. });
  11506. intTravelIndex++;
  11507. }
  11508. if (infoView.SumTDC == 1)
  11509. {
  11510. intTravelCosts.Add(new QuoteSubItemInfo
  11511. {
  11512. ItemId = 1354,
  11513. Index = intTravelIndex,
  11514. FeeName = "头等舱",
  11515. UnitPrice = infoView.AirTD,
  11516. Currency = "CNY",
  11517. Quantity = 1,
  11518. PplNum = 1,
  11519. TotalAmt = infoView.AirTD,
  11520. Remark = "",
  11521. });
  11522. intTravelIndex++;
  11523. }
  11524. intTravelCosts.Add(new QuoteSubItemInfo
  11525. {
  11526. ItemId = 1354,
  11527. Index = intTravelIndex,
  11528. FeeName = "城市间交通费用",
  11529. UnitPrice = infoView.CityTranffic,
  11530. Currency = "CNY",
  11531. Quantity = 1,
  11532. PplNum = pplNum,
  11533. TotalAmt = infoView.CityTranffic * pplNum,
  11534. Remark = "",
  11535. });
  11536. views.AddRange(intTravelCosts);
  11537. #endregion
  11538. var accomCosts = new List<QuoteSubItemInfo>();
  11539. #region 住宿费 1355
  11540. if (infoView.QuarterageData.Any())
  11541. {
  11542. int accomIndex = 1;
  11543. int accomItemTypeId = 1355;
  11544. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11545. foreach (var item in groupData)
  11546. {
  11547. string feeName = string.Empty;
  11548. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11549. if (countryInfo != null)
  11550. {
  11551. feeName = countryInfo.Country;
  11552. var city = countryInfo.City;
  11553. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11554. {
  11555. feeName += $"-{city}";
  11556. }
  11557. }
  11558. var hotelInfo = item.FirstOrDefault();
  11559. if (hotelInfo == null) continue;
  11560. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11561. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11562. int quantity = item.ToList().Count;
  11563. accomCosts.Add(new QuoteSubItemInfo
  11564. {
  11565. ItemId = accomItemTypeId,
  11566. Index = accomIndex,
  11567. FeeName = feeName,
  11568. UnitPrice = hotelInfo.Cost,
  11569. Currency = thisCurrency,
  11570. Quantity = quantity,
  11571. PplNum = pplNum,
  11572. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11573. Remark = "",
  11574. });
  11575. accomIndex++;
  11576. }
  11577. views.AddRange(accomCosts);
  11578. }
  11579. #endregion
  11580. var mealCosts = new List<QuoteSubItemInfo>();
  11581. #region 餐饮费 1356
  11582. if (infoView.BoardWagesData.Any())
  11583. {
  11584. var mealIndex = 1;
  11585. int mealItemTypeId = 1356;
  11586. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11587. foreach (var item in groupData)
  11588. {
  11589. string feeName = string.Empty;
  11590. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11591. if (countryInfo != null)
  11592. {
  11593. feeName = countryInfo.Country;
  11594. var city = countryInfo.City;
  11595. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11596. {
  11597. feeName += $"-{city}";
  11598. }
  11599. }
  11600. var mealInfo = item.FirstOrDefault();
  11601. if (mealInfo == null) continue;
  11602. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11603. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11604. int quantity = item.ToList().Count;
  11605. mealCosts.Add(new QuoteSubItemInfo
  11606. {
  11607. ItemId = mealItemTypeId,
  11608. Index = mealIndex,
  11609. FeeName = feeName,
  11610. UnitPrice = mealInfo.Cost,
  11611. Currency = thisCurrency,
  11612. Quantity = quantity,
  11613. PplNum = pplNum,
  11614. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11615. Remark = "",
  11616. });
  11617. mealIndex++;
  11618. }
  11619. views.AddRange(mealCosts);
  11620. }
  11621. #endregion
  11622. var miscCosts = new List<QuoteSubItemInfo>();
  11623. #region 公杂费 1364
  11624. if (infoView.MiscellaneousFeeData.Any())
  11625. {
  11626. var miscIndex = 1;
  11627. int miscItemTypeId = 1364;
  11628. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11629. foreach (var item in groupData)
  11630. {
  11631. string feeName = string.Empty;
  11632. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11633. if (countryInfo != null)
  11634. {
  11635. feeName = countryInfo.Country;
  11636. var city = countryInfo.City;
  11637. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11638. {
  11639. feeName += $"-{city}";
  11640. }
  11641. }
  11642. var miscInfo = item.FirstOrDefault();
  11643. if (miscInfo == null) continue;
  11644. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11645. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11646. int quantity = item.ToList().Count;
  11647. mealCosts.Add(new QuoteSubItemInfo
  11648. {
  11649. ItemId = miscItemTypeId,
  11650. Index = miscIndex,
  11651. FeeName = feeName,
  11652. UnitPrice = miscInfo.Cost,
  11653. Currency = thisCurrency,
  11654. Quantity = quantity,
  11655. PplNum = pplNum,
  11656. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11657. Remark = "",
  11658. });
  11659. miscIndex++;
  11660. }
  11661. views.AddRange(mealCosts);
  11662. }
  11663. #endregion
  11664. #region 签证+保险 1362
  11665. int visaInsIndex = 1;
  11666. int visaInsItemTypeId = 1362;
  11667. if (infoView.Visa > 0)
  11668. {
  11669. views.Add(new QuoteSubItemInfo()
  11670. {
  11671. ItemId = visaInsItemTypeId,
  11672. Index = visaInsIndex,
  11673. FeeName = $"签证",
  11674. UnitPrice = infoView.Visa,
  11675. Currency = $"CNY",
  11676. Quantity = 1,
  11677. PplNum = pplNum,
  11678. TotalAmt = infoView.Visa * pplNum,
  11679. Remark = "",
  11680. });
  11681. visaInsIndex++;
  11682. }
  11683. if (infoView.Safe > 0)
  11684. {
  11685. views.Add(new QuoteSubItemInfo()
  11686. {
  11687. ItemId = visaInsItemTypeId,
  11688. Index = visaInsIndex,
  11689. FeeName = $"保险",
  11690. UnitPrice = infoView.Safe,
  11691. Currency = $"CNY",
  11692. Quantity = 1,
  11693. PplNum = pplNum,
  11694. TotalAmt = infoView.Safe * pplNum,
  11695. Remark = "",
  11696. });
  11697. }
  11698. #endregion
  11699. #region 服务费 1363
  11700. int serviceFeeIndex = 1;
  11701. int serviceFeeItemTypeId = 1363;
  11702. if (infoView.Service > 0)
  11703. {
  11704. views.Add(new QuoteSubItemInfo()
  11705. {
  11706. ItemId = serviceFeeItemTypeId,
  11707. Index = serviceFeeIndex,
  11708. FeeName = $"服务费",
  11709. UnitPrice = infoView.Service,
  11710. Currency = $"CNY",
  11711. Quantity = 1,
  11712. PplNum = pplNum,
  11713. TotalAmt = infoView.Service * pplNum,
  11714. Remark = "",
  11715. });
  11716. }
  11717. #endregion
  11718. #endregion
  11719. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11720. result.Rates = eecRates.ToArray();
  11721. if (result.FeeItems.Any())
  11722. {
  11723. result.FeeItems.Select(x =>
  11724. {
  11725. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11726. if (feeInfos.Any()) x.Infos = feeInfos;
  11727. return x;
  11728. }
  11729. )
  11730. .OrderBy(x => x.Index)
  11731. .ToList();
  11732. }
  11733. return Ok(JsonView(result));
  11734. }
  11735. /// <summary>
  11736. /// 团组模块 - 出入境费用报价表 - Info
  11737. /// </summary>
  11738. /// <returns></returns>
  11739. [HttpPost]
  11740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11741. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11742. {
  11743. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11744. if (!info.Rates.Any())
  11745. {
  11746. var rates = await GeneralMethod.EnterExitCostInitRate();
  11747. info.Rates = rates.ToArray();
  11748. }
  11749. return Ok(JsonView(info));
  11750. }
  11751. /// <summary>
  11752. /// 团组模块 - 出入境费用报价表 - OP
  11753. /// </summary>
  11754. /// <returns></returns>
  11755. [HttpPost]
  11756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11757. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11758. {
  11759. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11760. }
  11761. /// <summary>
  11762. /// 团组模块 - 出入境费用报价表 - 删除 项
  11763. /// </summary>
  11764. /// <returns></returns>
  11765. [HttpPost]
  11766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11767. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11768. {
  11769. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11770. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11771. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11772. }
  11773. /// <summary>
  11774. /// 团组模块 - 出入境费用报价表 - 导出
  11775. /// </summary>
  11776. /// <returns></returns>
  11777. [HttpPost]
  11778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11779. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11780. {
  11781. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11782. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11783. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11784. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11785. var rates = info.Rates;
  11786. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11787. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11788. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11789. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11790. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11791. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11792. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11793. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11794. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11795. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11796. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11797. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11798. //获取模板
  11799. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11800. var designer = new WorkbookDesigner();
  11801. designer.Workbook = new Workbook(tempPath);
  11802. designer.SetDataSource("QuoteName", info.Name);
  11803. designer.SetDataSource("CompanyTitle", "公司名称");
  11804. designer.SetDataSource("CompanyLabel", "");
  11805. #region 国际旅费
  11806. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  11807. if (intTravelCosts.Infos.Any())
  11808. {
  11809. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11810. StringBuilder label = new StringBuilder();
  11811. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11812. if (infos.Any())
  11813. {
  11814. label.Append(infos.Sum(x => x.PplNum));
  11815. label.Append("人全程机票:");
  11816. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11817. label.AppendLine("元");
  11818. }
  11819. foreach (var item in intTravelCosts.Infos)
  11820. {
  11821. label.Append(item.FeeName);
  11822. label.Append(":");
  11823. label.Append(item.UnitPrice.TruncDecimals(2));
  11824. label.Append("元/人*");
  11825. label.Append(item.PplNum);
  11826. label.AppendLine("人");
  11827. }
  11828. if (label.HasValue())
  11829. {
  11830. label.Append("\r\n以上小计:");
  11831. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11832. label.Append("元");
  11833. }
  11834. designer.SetDataSource("IntTravelLabel", label.ToString());
  11835. }
  11836. #endregion
  11837. #region 住宿费
  11838. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  11839. if (accomCosts.Infos.Any())
  11840. {
  11841. string currencyName = string.Empty;
  11842. decimal rate = 1.0000M;
  11843. StringBuilder label = new StringBuilder();
  11844. label.AppendLine("全程五星酒店,每人1间房");
  11845. foreach (var item in accomCosts.Infos)
  11846. {
  11847. string hotelName = string.Empty;
  11848. if (item.FeeName.Contains("-"))
  11849. {
  11850. var feeName = item.FeeName.Split('-');
  11851. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11852. }
  11853. else hotelName = $"\r\n{item.FeeName}:";
  11854. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11855. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11856. rate = rateInfo?.Rate ?? 1.0000M;
  11857. label.Append(hotelName);
  11858. label.Append(item.UnitPrice.TruncDecimals(2));
  11859. label.Append(currencyName);
  11860. label.Append("/间/晚*");
  11861. label.Append(item.Quantity.ToString("#0"));
  11862. label.AppendLine("人");
  11863. }
  11864. if (label.HasValue())
  11865. {
  11866. label.Append("\r\n以上小计:");
  11867. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11868. label.Append("元(");
  11869. label.Append(currencyName);
  11870. label.Append("汇率:");
  11871. label.Append(rate.TruncDecimals(4));
  11872. label.Append(")");
  11873. }
  11874. designer.SetDataSource("AccomLabel", label.ToString());
  11875. }
  11876. #endregion
  11877. #region 餐饮费
  11878. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11879. if (mealCosts.Infos.Any())
  11880. {
  11881. string currencyName = string.Empty;
  11882. decimal rate = 1.0000M;
  11883. StringBuilder label = new StringBuilder();
  11884. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11885. foreach (var item in mealCosts.Infos)
  11886. {
  11887. string name = string.Empty;
  11888. if (item.FeeName.Contains("-"))
  11889. {
  11890. var feeName = item.FeeName.Split('-');
  11891. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11892. }
  11893. else name = $"\r\n{item.FeeName}:";
  11894. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11895. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11896. rate = rateInfo?.Rate ?? 1.0000M;
  11897. label.Append(name);
  11898. label.Append(item.UnitPrice.TruncDecimals(2));
  11899. label.Append(currencyName);
  11900. label.Append("/天*");
  11901. label.Append(item.Quantity.ToString("#0"));
  11902. label.Append("*");
  11903. label.Append(item.PplNum);
  11904. label.Append("人\r\n");
  11905. }
  11906. if (label.HasValue())
  11907. {
  11908. label.Append("\r\n以上小计:");
  11909. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11910. label.Append("元\r\n(");
  11911. label.Append("汇率:");
  11912. label.Append(rate.TruncDecimals(4));
  11913. label.Append(")");
  11914. }
  11915. designer.SetDataSource("MealLabel", label.ToString());
  11916. }
  11917. #endregion
  11918. #region 车辆安排
  11919. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11920. if (vehArranges.Infos.Any())
  11921. {
  11922. string currencyName = string.Empty;
  11923. //decimal rate = 1.0000M;
  11924. StringBuilder label = new StringBuilder();
  11925. foreach (var item in vehArranges.Infos)
  11926. {
  11927. label.Append(item.Remark);
  11928. label.AppendLine();
  11929. label.AppendLine();
  11930. label.Append(item.FeeName);
  11931. label.Append("\r\n\r\n费用:");
  11932. label.Append(item.FeeName);
  11933. label.Append(item.TotalAmt.TruncDecimals(2));
  11934. }
  11935. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11936. }
  11937. #endregion
  11938. #region 邀请函发放对象
  11939. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11940. #endregion
  11941. designer.Process();
  11942. //文件名
  11943. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11944. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11945. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11946. return Ok(JsonView(true, "成功", url));
  11947. }
  11948. #endregion
  11949. #region 签证费用录入
  11950. /// <summary>
  11951. /// 根据diid查询签证费用列表
  11952. /// </summary>
  11953. /// <param name="dto"></param>
  11954. /// <returns></returns>
  11955. [HttpPost]
  11956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11957. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11958. {
  11959. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11960. if (groupData.Code != 0)
  11961. {
  11962. return Ok(JsonView(false, groupData.Msg));
  11963. }
  11964. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11965. }
  11966. /// <summary>
  11967. /// 根据签证费用Id查询单条数据及c表数据
  11968. /// </summary>
  11969. /// <param name="dto"></param>
  11970. /// <returns></returns>
  11971. [HttpPost]
  11972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11973. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11974. {
  11975. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11976. if (groupData.Code != 0)
  11977. {
  11978. return Ok(JsonView(false, groupData.Msg));
  11979. }
  11980. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11981. }
  11982. /// <summary>
  11983. /// 签证费用删除
  11984. /// </summary>
  11985. /// <param name="dto"></param>
  11986. /// <returns></returns>
  11987. [HttpPost]
  11988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11989. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11990. {
  11991. _sqlSugar.BeginTran();
  11992. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11993. if (!res)
  11994. {
  11995. _sqlSugar.RollbackTran();
  11996. return Ok(JsonView(false, "删除失败"));
  11997. }
  11998. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11999. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12000. .SetColumns(a => new Grp_CreditCardPayment()
  12001. {
  12002. IsDel = 1,
  12003. DeleteUserId = dto.DeleteUserId,
  12004. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12005. })
  12006. .ExecuteCommand();
  12007. if (resSub < 1)
  12008. {
  12009. _sqlSugar.RollbackTran();
  12010. return Ok(JsonView(false, "删除失败"));
  12011. }
  12012. _sqlSugar.CommitTran();
  12013. return Ok(JsonView(true, "删除成功!"));
  12014. }
  12015. /// <summary>
  12016. /// 签证费用录入下拉框初始化
  12017. /// </summary>
  12018. /// <returns></returns>
  12019. [HttpPost]
  12020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12021. public async Task<IActionResult> VisaPriceAddSelect()
  12022. {
  12023. //支付方式
  12024. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12025. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12026. //币种
  12027. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12028. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12029. //乘客类型
  12030. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12031. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12032. //卡类型
  12033. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12034. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12035. //代办费类型
  12036. var agencyFeeTypeData = new List<dynamic>() {
  12037. new { id = 0 , Text = "未选择" },
  12038. new { id = 1 , Text = "小公务" },
  12039. new { id = 2 , Text = "大公务" },
  12040. };
  12041. //签证费用标准国家Data
  12042. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12043. var data = new
  12044. {
  12045. Payment = _Payment,
  12046. CurrencyList = _CurrencyList,
  12047. PassengerType = _PassengerType,
  12048. BankCard = _BankCard,
  12049. AgencyFeeType = agencyFeeTypeData,
  12050. CountryFeeData = visaCountryFeeData
  12051. };
  12052. return Ok(JsonView(true, "查询成功!", data));
  12053. }
  12054. /// <summary>
  12055. /// 签证费用录入操作(Status:1.新增,2.修改)
  12056. /// </summary>
  12057. /// <param name="dto"></param>
  12058. /// <returns></returns>
  12059. [HttpPost]
  12060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12061. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12062. {
  12063. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12064. if (groupData.Code != 0)
  12065. {
  12066. return Ok(JsonView(false, groupData.Msg));
  12067. }
  12068. #region 应用推送
  12069. try
  12070. {
  12071. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12072. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12073. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12074. //2024-10-21 新增LZ UID
  12075. var userIds = new List<int>() { 21 };
  12076. string title = $"系统通知";
  12077. string content = "";
  12078. var diId = dto.DiId;
  12079. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12080. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12081. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12082. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12083. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12084. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12085. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12086. }
  12087. catch (Exception ex)
  12088. {
  12089. }
  12090. #endregion
  12091. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12092. }
  12093. #endregion
  12094. #region 签证提成录入
  12095. /// <summary>
  12096. /// 签证提成录入
  12097. /// 基础数据
  12098. /// </summary>
  12099. /// <returns></returns>
  12100. [HttpGet]
  12101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12102. public async Task<IActionResult> VisaCommissionInit()
  12103. {
  12104. return Ok(await _visaCommissionRep.Init());
  12105. }
  12106. /// <summary>
  12107. /// 签证提成录入
  12108. /// Item
  12109. /// </summary>
  12110. /// <param name="_dto"></param>
  12111. /// <returns></returns>
  12112. [HttpPost]
  12113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12114. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12115. {
  12116. var validator = new VisaCommissionItemDtoValidator();
  12117. var validatorRes = await validator.ValidateAsync(_dto);
  12118. if (!validatorRes.IsValid)
  12119. {
  12120. StringBuilder sb = new StringBuilder();
  12121. foreach (var item in validatorRes.Errors)
  12122. {
  12123. sb.AppendLine(item.ErrorMessage);
  12124. }
  12125. return Ok(JsonView(false, sb.ToString()));
  12126. }
  12127. return Ok(await _visaCommissionRep.Item(_dto));
  12128. }
  12129. /// <summary>
  12130. /// 签证提成录入
  12131. /// Save
  12132. /// </summary>
  12133. /// <param name="_dto"></param>
  12134. /// <returns></returns>
  12135. [HttpPost]
  12136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12137. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12138. {
  12139. //参数验证
  12140. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12141. foreach (var item in _dto.Items)
  12142. {
  12143. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12144. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12145. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12146. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12147. }
  12148. return Ok(await _visaCommissionRep.Save(_dto));
  12149. }
  12150. /// <summary>
  12151. /// 签证提成录入
  12152. /// Create
  12153. /// </summary>
  12154. /// <param name="_dto"></param>
  12155. /// <returns></returns>
  12156. [HttpPost]
  12157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12158. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12159. {
  12160. var validator = new VisaCommissionCreateDtoValidator();
  12161. var validatorRes = await validator.ValidateAsync(_dto);
  12162. if (!validatorRes.IsValid)
  12163. {
  12164. StringBuilder sb = new StringBuilder();
  12165. foreach (var item in validatorRes.Errors)
  12166. {
  12167. sb.AppendLine(item.ErrorMessage);
  12168. }
  12169. return Ok(JsonView(false, sb.ToString()));
  12170. }
  12171. return Ok(await _visaCommissionRep.Create(_dto));
  12172. }
  12173. /// <summary>
  12174. /// 签证提成录入
  12175. /// Put(编辑)
  12176. /// </summary>
  12177. /// <param name="id"></param>
  12178. /// <param name="_dto"></param>
  12179. /// <returns></returns>
  12180. [HttpPut]
  12181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12182. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12183. {
  12184. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12185. var validator = new VisaCommissionCreateDtoValidator();
  12186. var validatorRes = await validator.ValidateAsync(_dto);
  12187. if (!validatorRes.IsValid)
  12188. {
  12189. StringBuilder sb = new StringBuilder();
  12190. foreach (var item in validatorRes.Errors)
  12191. {
  12192. sb.AppendLine(item.ErrorMessage);
  12193. }
  12194. return Ok(JsonView(false, sb.ToString()));
  12195. }
  12196. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12197. }
  12198. /// <summary>
  12199. /// 签证提成录入
  12200. /// Del
  12201. /// </summary>
  12202. /// <param name="id"></param>
  12203. /// <param name="currUserId"></param>
  12204. /// <returns></returns>
  12205. [HttpPost]
  12206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12207. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12208. {
  12209. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12210. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12211. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12212. }
  12213. #endregion
  12214. #region op费用录入
  12215. /// <summary>
  12216. /// 根据diid查询op费用列表
  12217. /// </summary>
  12218. /// <param name="dto"></param>
  12219. /// <returns></returns>
  12220. [HttpPost]
  12221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12222. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12223. {
  12224. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12225. if (groupData.Code != 0)
  12226. {
  12227. return Ok(JsonView(false, groupData.Msg));
  12228. }
  12229. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12230. }
  12231. /// <summary>
  12232. /// 根据op费用Id查询单条数据及c表数据
  12233. /// </summary>
  12234. /// <param name="dto"></param>
  12235. /// <returns></returns>
  12236. [HttpPost]
  12237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12238. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12239. {
  12240. try
  12241. {
  12242. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12243. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12244. var data = new
  12245. {
  12246. CarTouristGuideGround = _groupData,
  12247. CreditCardPayment = _creditCardPayment
  12248. };
  12249. return Ok(JsonView(true, "查询成功!", data));
  12250. }
  12251. catch (Exception ex)
  12252. {
  12253. return Ok(JsonView(false, "程序错误!"));
  12254. }
  12255. }
  12256. /// <summary>
  12257. /// op费用删除
  12258. /// </summary>
  12259. /// <param name="dto"></param>
  12260. /// <returns></returns>
  12261. [HttpPost]
  12262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12263. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12264. {
  12265. try
  12266. {
  12267. _sqlSugar.BeginTran();
  12268. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12269. if (!res)
  12270. {
  12271. return Ok(JsonView(false, "删除失败"));
  12272. }
  12273. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12274. {
  12275. IsDel = 1,
  12276. DeleteUserId = dto.DeleteUserId,
  12277. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12278. }).ExecuteCommandAsync();
  12279. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12280. {
  12281. IsDel = 1,
  12282. DeleteUserId = dto.DeleteUserId,
  12283. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12284. }).ExecuteCommandAsync();
  12285. #region 删除超支相关数据
  12286. //删除导入的超支数据
  12287. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12288. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12289. {
  12290. IsDel = 1,
  12291. DeleteUserId = dto.DeleteUserId,
  12292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12293. }).ExecuteCommand();
  12294. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12295. {
  12296. IsDel = 1,
  12297. DeleteUserId = dto.DeleteUserId,
  12298. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12299. }).ExecuteCommand();
  12300. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12301. {
  12302. IsDel = 1,
  12303. DeleteUserId = dto.DeleteUserId,
  12304. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12305. }).ExecuteCommand();
  12306. #endregion
  12307. _sqlSugar.CommitTran();
  12308. return Ok(JsonView(true, "删除成功!"));
  12309. }
  12310. catch (Exception ex)
  12311. {
  12312. _sqlSugar.RollbackTran();
  12313. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12314. }
  12315. }
  12316. /// <summary>
  12317. /// op费用录入操作(Status:1.新增,2.修改)
  12318. /// </summary>
  12319. /// <param name="dto"></param>
  12320. /// <returns></returns>
  12321. [HttpPost]
  12322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12323. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12324. {
  12325. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12326. if (groupData.Code != 0)
  12327. {
  12328. return Ok(JsonView(false, groupData.Msg));
  12329. }
  12330. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12331. }
  12332. /// <summary>
  12333. /// 填写费用详细页面初始化绑定
  12334. /// </summary>
  12335. /// <param name="dto"></param>
  12336. /// <returns></returns>
  12337. [HttpPost]
  12338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12339. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12340. {
  12341. try
  12342. {
  12343. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12344. if (groupData.Code != 0)
  12345. {
  12346. return Ok(JsonView(false, groupData.Msg));
  12347. }
  12348. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12349. }
  12350. catch (Exception ex)
  12351. {
  12352. return Ok(JsonView(false, ex.Message));
  12353. }
  12354. }
  12355. /// <summary>
  12356. /// 根据op费用Id查询详细数据
  12357. /// </summary>
  12358. /// <param name="dto"></param>
  12359. /// <returns></returns>
  12360. [HttpPost]
  12361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12362. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12363. {
  12364. try
  12365. {
  12366. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12367. if (groupData.Code != 0)
  12368. {
  12369. return Ok(JsonView(false, groupData.Msg));
  12370. }
  12371. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12372. }
  12373. catch (Exception ex)
  12374. {
  12375. return Ok(JsonView(false, ex.Message));
  12376. }
  12377. }
  12378. /// <summary>
  12379. /// OP费用录入填写详情
  12380. /// </summary>
  12381. /// <param name="dto"></param>
  12382. /// <returns></returns>
  12383. [HttpPost]
  12384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12385. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12386. {
  12387. try
  12388. {
  12389. #region 参数校验
  12390. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12391. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12392. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12393. #endregion
  12394. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12395. if (groupData.Code != 0)
  12396. {
  12397. return Ok(JsonView(false, groupData.Msg));
  12398. }
  12399. //自动审核
  12400. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12401. #region 应用推送
  12402. try
  12403. {
  12404. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12405. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12406. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12407. //2024-10-21 新增LZ UID
  12408. var userIds = new List<int>() { 21 };
  12409. string title = $"系统通知";
  12410. var diId = dto.DiId;
  12411. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12412. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12413. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12414. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12415. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12416. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12417. }
  12418. catch (Exception ex)
  12419. {
  12420. }
  12421. #endregion
  12422. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12423. }
  12424. catch (Exception ex)
  12425. {
  12426. return Ok(JsonView(false, ex.Message));
  12427. }
  12428. }
  12429. /// <summary>
  12430. /// 获取三公详细所有城市
  12431. /// </summary>
  12432. /// <returns></returns>
  12433. [HttpGet]
  12434. public IActionResult OpCarCityResult()
  12435. {
  12436. var jw = JsonView(false);
  12437. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12438. {
  12439. x.Id,
  12440. x.Country,
  12441. x.City,
  12442. }).ToList();
  12443. if (data.Count > 0)
  12444. {
  12445. jw = JsonView(true, "获取成功!", data);
  12446. }
  12447. else
  12448. {
  12449. jw.Msg = "城市数据为空!";
  12450. jw.Data = new string[0];
  12451. }
  12452. return Ok(jw);
  12453. }
  12454. /// <summary>
  12455. /// 导出地接费用明细
  12456. /// </summary>
  12457. /// <param name="dto"></param>
  12458. /// <returns></returns>
  12459. [HttpPost]
  12460. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12461. {
  12462. var jw = JsonView(false);
  12463. if (dto.Diid < 1)
  12464. {
  12465. jw.Msg = "请输入正确的diid!";
  12466. return Ok(jw);
  12467. }
  12468. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12469. if (group == null)
  12470. {
  12471. jw.Msg = "未找到团组信息!";
  12472. return Ok(jw);
  12473. }
  12474. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12475. if (localGuideArr.Count == 0)
  12476. {
  12477. jw.Msg = "该团组暂无地接信息!";
  12478. return Ok(jw);
  12479. }
  12480. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12481. var overspendSoure = new Dictionary<int, int>
  12482. {
  12483. { 91, 982 }, //车
  12484. { 92 , 1059} ,//导游
  12485. { 994 , 1073}, //翻译
  12486. { 988 , 1074 }, //早餐
  12487. { 93 , 1075 }, //午餐
  12488. { 989 , 1076 }, //晚餐
  12489. };
  12490. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12491. foreach (var groupArr in localGroup)
  12492. {
  12493. var keyValue = groupArr.Key;
  12494. if (int.TryParse(keyValue, out int cityid))
  12495. {
  12496. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12497. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12498. }
  12499. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12500. foreach (var item in groupArr)
  12501. {
  12502. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12503. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  12504. new Grp_CarTouristGuideGroundReservationsContentExtend
  12505. {
  12506. Count = a.Count,
  12507. CreateTime = a.CreateTime,
  12508. CreateUserId = a.CreateUserId,
  12509. CTGGRId = a.CTGGRId,
  12510. Currency = a.Currency,
  12511. DatePrice = a.DatePrice,
  12512. DeleteTime = a.DeleteTime,
  12513. DeleteUserId = a.DeleteUserId,
  12514. DiId = a.DiId,
  12515. Id = a.Id,
  12516. IsDel = a.IsDel,
  12517. Price = a.Price,
  12518. PriceContent = a.PriceContent,
  12519. Remark = a.Remark,
  12520. SId = a.SId,
  12521. SidName = b.Name,
  12522. Units = a.Units,
  12523. }
  12524. ).ToList();
  12525. if (content.Count > 0)
  12526. {
  12527. contentArr.Add(content);
  12528. }
  12529. }
  12530. //open excel
  12531. //set excel
  12532. //save excel
  12533. try
  12534. {
  12535. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  12536. IWorkbook workbook;
  12537. if (Path.GetExtension(filePath).ToLower() == ".xls")
  12538. {
  12539. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12540. }
  12541. else
  12542. {
  12543. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  12544. }
  12545. ISheet sheet = workbook.GetSheetAt(0);
  12546. var rowStartIndex = 2;
  12547. var clounmCount = 10;
  12548. var initStyleRow = sheet.GetRow(2);
  12549. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  12550. //var overspendArrDetail =
  12551. var existsId = new List<CarCompare>();
  12552. var lastElem = arr.Last();
  12553. var thisSid = -1;
  12554. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  12555. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  12556. {
  12557. Name = "未知币种!",
  12558. Remark = "未知币种!",
  12559. };
  12560. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  12561. Action cloneRowFn = () =>
  12562. {
  12563. rowStartIndex++;
  12564. var cloneRow = sheet.CreateRow(rowStartIndex);
  12565. // 复制样式
  12566. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  12567. {
  12568. ICell sourceCell = initStyleRow.GetCell(i);
  12569. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  12570. // 确保单元格存在样式
  12571. if (sourceCell.CellStyle != null)
  12572. {
  12573. targetCell.CellStyle = sourceCell.CellStyle;
  12574. }
  12575. }
  12576. };
  12577. var mergeRow = () =>
  12578. {
  12579. for (int i = 2; i < sheet.LastRowNum; i++)
  12580. {
  12581. var row = sheet.GetRow(i);
  12582. var cellFirst = row.GetCell(0);
  12583. var thisIndex = i + 1;
  12584. while (thisIndex < sheet.LastRowNum)
  12585. {
  12586. var nextRow = sheet.GetRow(thisIndex);
  12587. var nextCellFirst = nextRow.GetCell(0);
  12588. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  12589. {
  12590. thisIndex++;
  12591. }
  12592. else
  12593. {
  12594. break;
  12595. }
  12596. }
  12597. thisIndex--;
  12598. if (thisIndex != i)
  12599. {
  12600. //合并row
  12601. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12602. i, // 起始行索引(0-based)
  12603. thisIndex, // 结束行索引(0-based)
  12604. 0, // 起始列索引(0-based)
  12605. 0 // 结束列索引(0-based)
  12606. );
  12607. sheet.AddMergedRegion(cellRangeAddress);
  12608. i = thisIndex;
  12609. }
  12610. }
  12611. };
  12612. var chaoshiNumber = 0;
  12613. var totalNumber = 0.00M;
  12614. string lastStr = "";
  12615. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12616. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12617. {
  12618. b.IsAuditGM,
  12619. x.Id,
  12620. x.Area,
  12621. b.PayPercentage,
  12622. b.PayMoney,
  12623. }).ToList();
  12624. string yesPayment = "", noPayment = "";
  12625. foreach (var item in queryCarArrByCityAndDiid)
  12626. {
  12627. if (item.IsAuditGM == 1)
  12628. {
  12629. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12630. }
  12631. else
  12632. {
  12633. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12634. }
  12635. }
  12636. lastStr = yesPayment + noPayment;
  12637. foreach (var item in arr)
  12638. {
  12639. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12640. {
  12641. if (thisSid != item.SId)
  12642. {
  12643. if (thisSid == -1)
  12644. {
  12645. thisSid = item.SId;
  12646. }
  12647. else
  12648. {
  12649. //合并小计行
  12650. //创建合并区域的实例
  12651. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12652. rowStartIndex, // 起始行索引(0-based)
  12653. rowStartIndex, // 结束行索引(0-based)
  12654. 0, // 起始列索引(0-based)
  12655. 3 // 结束列索引(0-based)
  12656. );
  12657. sheet.AddMergedRegion(cellRangeAddress);
  12658. var CellStyle = workbook.CreateCellStyle();
  12659. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12660. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12661. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12662. for (int i = 0; i <= clounmCount; i++)
  12663. {
  12664. if (i > 6)
  12665. {
  12666. var CellStyle1 = workbook.CreateCellStyle();
  12667. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12668. IFont Font = workbook.CreateFont(); // 创建字体
  12669. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12670. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12671. CellStyle1.SetFont(Font);
  12672. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12673. }
  12674. else
  12675. {
  12676. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12677. }
  12678. }
  12679. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12680. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12681. //超时合计
  12682. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12683. //超时数
  12684. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12685. //超时合计费用
  12686. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12687. thisSid = item.SId;
  12688. cloneRowFn();
  12689. chaoshiNumber = 0;
  12690. totalNumber = 0;
  12691. }
  12692. }
  12693. IRow row = sheet.GetRow(rowStartIndex);
  12694. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12695. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12696. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12697. if (isOpenOverspendSoure)
  12698. {
  12699. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12700. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12701. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12702. }
  12703. for (int i = 0; i <= clounmCount; i++)
  12704. {
  12705. var cell = row.GetCell(i);
  12706. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12707. if (cell == null)
  12708. {
  12709. cell = row.CreateCell(i);
  12710. }
  12711. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12712. fontRed.CloneStyleFrom(cell.CellStyle);
  12713. IFont Font = workbook.CreateFont(); // 创建字体
  12714. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12715. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12716. fontRed.SetFont(Font);
  12717. byte[] rgb = new byte[3] { 255, 242, 204 };
  12718. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12719. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12720. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12721. if (workbook is XSSFWorkbook)
  12722. {
  12723. BackgroundColor255_242_204.FillForegroundColor = 0;
  12724. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12725. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12726. }
  12727. else
  12728. {
  12729. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12730. }
  12731. if (i == 1 || i > 6)
  12732. {
  12733. if (i > 6)
  12734. {
  12735. fontRed.FillForegroundColor = 0;
  12736. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12737. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12738. }
  12739. cell.CellStyle = fontRed;
  12740. }
  12741. if (i > 2 && i < 7)
  12742. {
  12743. cell.CellStyle = BackgroundColor255_242_204;
  12744. }
  12745. cell.SetCellValue(setCellValue); //写入单元格
  12746. }
  12747. if (overspendSoure.ContainsKey(thisSid))
  12748. {
  12749. var overspendId = overspendSoure[thisSid];
  12750. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12751. }
  12752. cloneRowFn();
  12753. existsId.Add(new CarCompare
  12754. {
  12755. DataPrice = item.DatePrice.ObjToDate(),
  12756. Sid = item.SId
  12757. });
  12758. }
  12759. if (item.Equals(lastElem))
  12760. {
  12761. //合并小计行
  12762. //创建合并区域的实例
  12763. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12764. rowStartIndex, // 起始行索引(0-based)
  12765. rowStartIndex, // 结束行索引(0-based)
  12766. 0, // 起始列索引(0-based)
  12767. 3 // 结束列索引(0-based)
  12768. );
  12769. sheet.AddMergedRegion(cellRangeAddress);
  12770. var CellStyle = workbook.CreateCellStyle();
  12771. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12772. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12773. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12774. for (int i = 0; i <= clounmCount; i++)
  12775. {
  12776. if (i > 6)
  12777. {
  12778. var CellStyle1 = workbook.CreateCellStyle();
  12779. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12780. IFont Font = workbook.CreateFont(); // 创建字体
  12781. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12782. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12783. CellStyle1.SetFont(Font);
  12784. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12785. }
  12786. else
  12787. {
  12788. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12789. }
  12790. }
  12791. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12792. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12793. //超时合计
  12794. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12795. //超时数
  12796. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12797. //超时合计费用
  12798. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12799. cloneRowFn();
  12800. // 创建合并区域的实例
  12801. cellRangeAddress = new CellRangeAddress(
  12802. rowStartIndex, // 起始行索引(0-based)
  12803. rowStartIndex, // 结束行索引(0-based)
  12804. 0, // 起始列索引(0-based)
  12805. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12806. );
  12807. // 添加合并区域
  12808. sheet.AddMergedRegion(cellRangeAddress);
  12809. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12810. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12811. }
  12812. }
  12813. mergeRow();
  12814. // 保存修改后的Excel文件到新文件
  12815. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12816. // new FileStream(newFilePath, FileMode.CreateNew)
  12817. using (var stream = new MemoryStream())
  12818. {
  12819. workbook.Write(stream, true);
  12820. stream.Flush();
  12821. stream.Seek(0, SeekOrigin.Begin);
  12822. MemoryStream memoryStream = new MemoryStream();
  12823. stream.CopyTo(memoryStream);
  12824. memoryStream.Seek(0, SeekOrigin.Begin);
  12825. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12826. }
  12827. workbook.Close();
  12828. workbook.Dispose();
  12829. }
  12830. catch (Exception ex)
  12831. {
  12832. jw.Msg = "出现异常!" + ex.Message;
  12833. return Ok(jw);
  12834. }
  12835. }
  12836. if (Zips.Count > 0)
  12837. {
  12838. IOOperatorHelper io = new IOOperatorHelper();
  12839. var byts = io.ConvertZipStream(Zips);
  12840. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12841. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12842. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12843. }
  12844. else
  12845. {
  12846. jw.Msg = "暂无生成文件!";
  12847. }
  12848. return Ok(jw);
  12849. }
  12850. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12851. {
  12852. string outStr = string.Empty;
  12853. switch (i)
  12854. {
  12855. case 0:
  12856. outStr = arr[0].SidName;
  12857. break;
  12858. case 1:
  12859. outStr = arr[0].DataPriceStr;
  12860. break;
  12861. case 2:
  12862. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  12863. break;
  12864. case 4:
  12865. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  12866. break;
  12867. case 7:
  12868. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12869. {
  12870. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  12871. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  12872. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  12873. }
  12874. break;
  12875. case 8:
  12876. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12877. {
  12878. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12879. }
  12880. break;
  12881. case 9:
  12882. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12883. {
  12884. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12885. }
  12886. break;
  12887. case 10:
  12888. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12889. {
  12890. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12891. }
  12892. break;
  12893. }
  12894. return outStr;
  12895. }
  12896. #region OP行程单
  12897. /// <summary>
  12898. /// OP行程单初始化
  12899. /// </summary>
  12900. /// <param name="dto"></param>
  12901. /// <returns></returns>
  12902. [HttpPost]
  12903. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12904. {
  12905. var jw = JsonView(false);
  12906. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12907. var group = groupList.First();
  12908. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12909. if (group == null)
  12910. {
  12911. jw.Msg = "暂无团组!";
  12912. return Ok(jw);
  12913. }
  12914. group = groupList.Find(x => x.Id == diid);
  12915. if (group == null)
  12916. {
  12917. jw.Msg = "请输入正确的团组ID!";
  12918. return Ok(jw);
  12919. }
  12920. string city = string.Empty;
  12921. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12922. if (blackCode.Count > 0)
  12923. {
  12924. var black = blackCode.First();
  12925. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12926. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12927. if (blackSp.Length > 0)
  12928. {
  12929. try
  12930. {
  12931. var cityArrCode = new List<string>(20);
  12932. foreach (var item in blackSp)
  12933. {
  12934. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12935. var IndexSelect = itemSp[2];
  12936. var cityArrCodeLength = cityArrCode.Count - 1;
  12937. var startCity = IndexSelect.Substring(0, 3);
  12938. if (cityArrCodeLength > 0)
  12939. {
  12940. var arrEndCity = cityArrCode[cityArrCodeLength];
  12941. if (arrEndCity != startCity)
  12942. {
  12943. cityArrCode.Add(startCity.ToUpper());
  12944. }
  12945. }
  12946. else
  12947. {
  12948. cityArrCode.Add(startCity.ToUpper());
  12949. }
  12950. var endCity = IndexSelect.Substring(3, 3);
  12951. cityArrCode.Add(endCity.ToUpper());
  12952. }
  12953. var cityThree = string.Empty;
  12954. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12955. cityThree = cityThree.TrimEnd(',');
  12956. if (string.IsNullOrWhiteSpace(cityThree))
  12957. {
  12958. throw new
  12959. Exception("error");
  12960. }
  12961. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12962. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12963. foreach (var item in cityArrCode)
  12964. {
  12965. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12966. if (find != null)
  12967. {
  12968. city += find.City + "/";
  12969. }
  12970. else
  12971. {
  12972. city += item + "三字码未收入/";
  12973. }
  12974. }
  12975. city = city.TrimEnd('/');
  12976. }
  12977. catch (Exception e)
  12978. {
  12979. city = "黑屏代码格式不正确!";
  12980. }
  12981. }
  12982. }
  12983. else
  12984. {
  12985. city = "未录入黑屏代码";
  12986. }
  12987. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12988. {
  12989. Date = x.Date,
  12990. Days = x.Days,
  12991. Diffgroup = x.Diffgroup,
  12992. Diid = x.Diid,
  12993. Traffic_First = x.Traffic_First,
  12994. Traffic_Second = x.Traffic_Second,
  12995. Trip = x.Trip,
  12996. WeekDay = x.WeekDay,
  12997. Id = x.Id
  12998. }).ToList();
  12999. jw.Data = new
  13000. {
  13001. groupList = groupList.Select(x => new
  13002. {
  13003. x.Id,
  13004. x.TeamName,
  13005. x.TourCode
  13006. }).ToList(),
  13007. groupInfo = new
  13008. {
  13009. group.VisitDays,
  13010. group.TourCode,
  13011. group.VisitPNumber,
  13012. group.TeamName,
  13013. city
  13014. },
  13015. OpTravelList
  13016. };
  13017. jw.Code = 200;
  13018. jw.Msg = "操作成功!";
  13019. return Ok(jw);
  13020. }
  13021. /// <summary>
  13022. /// 删除团组行程单
  13023. /// </summary>
  13024. /// <returns></returns>
  13025. [HttpPost]
  13026. public IActionResult DelTravel(DelOpTravelDto dto)
  13027. {
  13028. var jw = JsonView(false);
  13029. if (dto.UserId <= 0 || dto.Diid <= 0)
  13030. {
  13031. jw.Msg = "请输入正确的参数!";
  13032. return Ok(jw);
  13033. }
  13034. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13035. .SetColumns(x => new Grp_TravelList
  13036. {
  13037. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13038. DeleteUserId = dto.UserId,
  13039. IsDel = 1,
  13040. }).ExecuteCommand();
  13041. jw = JsonView(true);
  13042. return Ok(jw);
  13043. }
  13044. /// <summary>
  13045. /// 行程单保存
  13046. /// </summary>
  13047. /// <returns></returns>
  13048. [HttpPost]
  13049. public IActionResult TravelSave(TravelSaveDto dto)
  13050. {
  13051. var jw = JsonView(false);
  13052. if (dto.Arr.Count > 0)
  13053. {
  13054. try
  13055. {
  13056. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13057. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13058. .ToList();
  13059. _sqlSugar.BeginTran();
  13060. foreach (var item in dto.Arr)
  13061. {
  13062. if (item.Id == 0)
  13063. {
  13064. throw new Exception("请传入正确的Id");
  13065. }
  13066. //比较上一次的差异
  13067. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13068. if (findTravel != null)
  13069. {
  13070. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13071. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13072. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13073. }
  13074. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13075. .SetColumns(x => new Grp_TravelList
  13076. {
  13077. Trip = item.Trip
  13078. }).ExecuteCommand();
  13079. }
  13080. _sqlSugar.CommitTran();
  13081. jw = JsonView(true);
  13082. }
  13083. catch (Exception ex)
  13084. {
  13085. _sqlSugar.RollbackTran();
  13086. jw.Msg = "程序异常!" + ex.Message;
  13087. }
  13088. }
  13089. else
  13090. {
  13091. jw.Msg = "请传入正确的参数!";
  13092. }
  13093. return Ok(jw);
  13094. }
  13095. private string CheckStr(string original, string changed)
  13096. {
  13097. // 创建diff_match_patch对象
  13098. var dmp = new diff_match_patch();
  13099. // 计算差异
  13100. List<Diff> diffs = dmp.diff_main(original, changed);
  13101. // 清理和合并差异
  13102. dmp.diff_cleanupSemantic(diffs);
  13103. // 使用StringBuilder构建最终的字符串
  13104. StringBuilder finalString = new StringBuilder();
  13105. // 输出差异结果,并构建变动后的字符串
  13106. foreach (Diff diff in diffs)
  13107. {
  13108. switch (diff.operation)
  13109. {
  13110. case Operation.EQUAL:
  13111. // 相等的部分,直接添加到最终字符串
  13112. finalString.Append(diff.text);
  13113. break;
  13114. case Operation.INSERT:
  13115. // 插入的部分,添加标记并添加到最终字符串
  13116. finalString.Append("[++]" + diff.text + "[++]");
  13117. break;
  13118. case Operation.DELETE:
  13119. // 删除的部分,不添加到最终字符串
  13120. //finalString.Append("[++]" + diff.text + "[++]");
  13121. break;
  13122. }
  13123. }
  13124. // 输出变动后的字符串
  13125. return finalString.ToString();
  13126. }
  13127. private class tagContent
  13128. {
  13129. public DateTime Date { get; set; }
  13130. public string StartTag { get; set; }
  13131. public string EndTag { get; set; }
  13132. public string Content { get; set; }
  13133. public static int tagLength { get { return 3; } }
  13134. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13135. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13136. public bool IsFinally { get; set; }
  13137. }
  13138. private List<string> ExtractContentBetweenTags(string input, string tag)
  13139. {
  13140. List<string> results = new List<string>();
  13141. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13142. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13143. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13144. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13145. string[] strValueArr = new string[1];
  13146. foreach (System.Text.RegularExpressions.Match match in matches)
  13147. {
  13148. var strValue = match.Groups[1].Value;
  13149. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13150. }
  13151. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13152. return results;
  13153. }
  13154. /// <summary>
  13155. /// 导出行程单
  13156. /// </summary>
  13157. /// <param name="dto"></param>
  13158. /// <returns></returns>
  13159. [HttpPost]
  13160. public IActionResult ExportTravel(ExportTravelDto dto)
  13161. {
  13162. var jw = JsonView(false);
  13163. jw.Data = "";
  13164. int diid = 0;
  13165. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13166. if (Find == null)
  13167. {
  13168. jw.Msg = "请选择正确的团组!";
  13169. return Ok(jw);
  13170. }
  13171. else
  13172. {
  13173. diid = Find.Id;
  13174. }
  13175. //数据源
  13176. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13177. DataTable dtBlack = null;
  13178. try
  13179. {
  13180. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13181. }
  13182. catch (Exception)
  13183. {
  13184. jw.Msg = "机票黑屏代码有误!";
  13185. return Ok(jw);
  13186. }
  13187. string CityStr = string.Empty;
  13188. if (dtBlack.Rows.Count == 0)
  13189. {
  13190. jw.Msg = "机票黑屏代码有误!";
  13191. return Ok(jw);
  13192. }
  13193. else
  13194. {
  13195. foreach (DataRow row in dtBlack.Rows)
  13196. {
  13197. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13198. {
  13199. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13200. return Ok(jw);
  13201. }
  13202. }
  13203. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13204. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13205. }
  13206. // 指定的文字
  13207. var targetTextDic = new Dictionary<string, List<string>>();
  13208. //创建数据源Table
  13209. DataTable dtSource = new DataTable();
  13210. dtSource.Columns.Add("Days", typeof(string));
  13211. dtSource.Columns.Add("Date", typeof(string));
  13212. dtSource.Columns.Add("Week", typeof(string));
  13213. dtSource.Columns.Add("Traffic", typeof(string));
  13214. dtSource.Columns.Add("Trip", typeof(string));
  13215. //获取数据,放到datatable
  13216. foreach (var item in _travelList)
  13217. {
  13218. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13219. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13220. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13221. .Replace("[++]", string.Empty);
  13222. DataRow dr = dtSource.NewRow();
  13223. dr["Days"] = item.Days;
  13224. dr["Date"] = item.Date;
  13225. dr["Week"] = item.WeekDay;
  13226. dr["Traffic"] = item.Traffic_First
  13227. + "\r\n"
  13228. + item.Traffic_Second;
  13229. dr["Trip"] = item.Trip;
  13230. dtSource.Rows.Add(dr);
  13231. }
  13232. Dictionary<string, string> dic = new Dictionary<string, string>();
  13233. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13234. dic.Add("City", CityStr);
  13235. dic.Add("Days", Find.VisitDays.ToString());
  13236. dic.Add("DeleCode", Find.TourCode);
  13237. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13238. //模板路径
  13239. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13240. //载入模板
  13241. Document doc = null;
  13242. DocumentBuilder builder = null;
  13243. try
  13244. {
  13245. //载入模板
  13246. doc = new Document(tempPath);
  13247. builder = new DocumentBuilder(doc);
  13248. }
  13249. catch (Exception)
  13250. {
  13251. jw.Msg = "模板位置不存在!";
  13252. return Ok(jw);
  13253. }
  13254. foreach (var key in dic.Keys)
  13255. {
  13256. Bookmark bookmark = doc.Range.Bookmarks[key];
  13257. if (bookmark != null)
  13258. {
  13259. builder.MoveToBookmark(key);
  13260. builder.Write(dic[key]);
  13261. }
  13262. }
  13263. //获取word里所有表格
  13264. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13265. //获取所填表格的序数
  13266. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13267. try
  13268. {
  13269. //循环赋值
  13270. for (int i = 0; i < dtSource.Rows.Count; i++)
  13271. {
  13272. builder.MoveToCell(0, i + 1, 0, 0);
  13273. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13274. builder.MoveToCell(0, i + 1, 1, 0);
  13275. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13276. builder.MoveToCell(0, i + 1, 2, 0);
  13277. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13278. var trip = dtSource.Rows[i]["Trip"].ToString();
  13279. builder.MoveToCell(0, i + 1, 3, 0);
  13280. builder.Write(trip);
  13281. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13282. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13283. // 获取特定索引的段落
  13284. Paragraph paragraph = (Paragraph)paragraphs[0];
  13285. Run run = paragraph.Runs[0];
  13286. Aspose.Words.Font font = run.Font;
  13287. font.Name = "黑体";
  13288. //设置双休红色
  13289. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13290. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13291. paragraph = (Paragraph)paragraphs[1];
  13292. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13293. {
  13294. run = paragraph.Runs[0];
  13295. font = run.Font;
  13296. font.Color = Color.Red;
  13297. }
  13298. }
  13299. }
  13300. catch (Exception ex)
  13301. {
  13302. }
  13303. //删除多余行
  13304. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13305. {
  13306. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13307. }
  13308. var targetTextList = new List<string>();
  13309. // 遍历文档中的表格
  13310. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13311. {
  13312. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13313. {
  13314. var cellIndex = 0;
  13315. foreach (Cell cell in row.Cells)
  13316. {
  13317. if (cellIndex == 1 && row.Cells.Count == 4)
  13318. {
  13319. foreach (var target in targetTextDic.Keys)
  13320. {
  13321. if (cell.GetText().Contains(target))
  13322. {
  13323. targetTextList = targetTextDic[target];
  13324. break;
  13325. }
  13326. }
  13327. }
  13328. // 遍历单元格中的所有段落
  13329. foreach (Paragraph paragraph in cell.Paragraphs)
  13330. {
  13331. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13332. List<Run> runs = new List<Run>();
  13333. foreach (Run run in paragraph.Runs)
  13334. {
  13335. runs.Add(run);
  13336. }
  13337. foreach (Run run in runs)
  13338. {
  13339. foreach (var targetText in targetTextList)
  13340. {
  13341. // 检查文字是否包含指定文字
  13342. if (run.Text.Contains(targetText))
  13343. {
  13344. // 将包含的部分设置为红色
  13345. HighlightText(run, targetText, Color.Red);
  13346. }
  13347. }
  13348. }
  13349. }
  13350. cellIndex++;
  13351. }
  13352. }
  13353. }
  13354. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13355. if (!Directory.Exists(savePath))
  13356. {
  13357. try
  13358. {
  13359. Directory.CreateDirectory(savePath);
  13360. }
  13361. catch
  13362. {
  13363. }
  13364. }
  13365. string path = savePath + Find.TeamName + "出访日程";
  13366. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13367. try
  13368. {
  13369. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13370. string postfix = ".docx";
  13371. if (dto.IsPDF == 1)
  13372. {
  13373. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13374. postfix = ".pdf";
  13375. }
  13376. doc.Save(path + postfix, saveFormat);
  13377. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13378. }
  13379. catch (Exception)
  13380. {
  13381. jw = JsonView(false);
  13382. }
  13383. return Ok(jw);
  13384. }
  13385. /// <summary>
  13386. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13387. /// </summary>
  13388. /// <param name="num"></param>
  13389. /// <returns></returns>
  13390. string GetNum(string num)
  13391. {
  13392. string str = "";
  13393. switch (num)
  13394. {
  13395. case "1":
  13396. str = "一";
  13397. break;
  13398. case "2":
  13399. str = "二";
  13400. break;
  13401. case "3":
  13402. str = "三";
  13403. break;
  13404. case "4":
  13405. str = "四";
  13406. break;
  13407. case "5":
  13408. str = "五";
  13409. break;
  13410. case "6":
  13411. str = "六";
  13412. break;
  13413. case "7":
  13414. str = "七";
  13415. break;
  13416. case "8":
  13417. str = "八";
  13418. break;
  13419. case "9":
  13420. str = "九";
  13421. break;
  13422. case "10":
  13423. str = "十";
  13424. break;
  13425. case "11":
  13426. str = "十一";
  13427. break;
  13428. case "12":
  13429. str = "十二";
  13430. break;
  13431. case "一":
  13432. str = "1";
  13433. break;
  13434. case "二":
  13435. str = "2";
  13436. break;
  13437. case "三":
  13438. str = "3";
  13439. break;
  13440. case "四":
  13441. str = "4";
  13442. break;
  13443. case "五":
  13444. str = "5";
  13445. break;
  13446. case "六":
  13447. str = "6";
  13448. break;
  13449. case "七":
  13450. str = "7";
  13451. break;
  13452. case "八":
  13453. str = "8";
  13454. break;
  13455. case "九":
  13456. str = "9";
  13457. break;
  13458. case "十":
  13459. str = "10";
  13460. break;
  13461. case "十一":
  13462. str = "11";
  13463. break;
  13464. case "十二":
  13465. str = "12";
  13466. break;
  13467. }
  13468. return str;
  13469. }
  13470. // 高亮包含指定文字的部分
  13471. void HighlightText(Run run, string targetText, Color color)
  13472. {
  13473. string text = run.Text;
  13474. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13475. if (startIndex >= 0)
  13476. {
  13477. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13478. // 前部分
  13479. if (startIndex > 0)
  13480. {
  13481. Run beforeRun = (Run)run.Clone(true);
  13482. beforeRun.Text = text.Substring(0, startIndex);
  13483. parentParagraph.InsertBefore(beforeRun, run);
  13484. }
  13485. // 匹配部分
  13486. Run matchRun = (Run)run.Clone(true);
  13487. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13488. matchRun.Font.Color = color;
  13489. parentParagraph.InsertBefore(matchRun, run);
  13490. // 后部分
  13491. if (startIndex + targetText.Length < text.Length)
  13492. {
  13493. Run afterRun = (Run)run.Clone(true);
  13494. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13495. parentParagraph.InsertBefore(afterRun, run);
  13496. }
  13497. // 删除原始Run
  13498. run.Remove();
  13499. }
  13500. }
  13501. #endregion
  13502. #endregion
  13503. #region 团组成本
  13504. /// <summary>
  13505. /// 团组成本数据初始化
  13506. /// </summary>
  13507. /// <param name="dto"></param>
  13508. /// <returns></returns>
  13509. [HttpPost]
  13510. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  13511. {
  13512. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  13513. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  13514. WHEN COUNT(*) >= 0 THEN 'True'
  13515. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  13516. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  13517. ").ToList(); //团组列表
  13518. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  13519. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  13520. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  13521. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  13522. if (groupinfoValue != null)
  13523. {
  13524. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  13525. var spArr = new string[1] { countryArr };
  13526. if (countryArr.Contains("|"))
  13527. {
  13528. spArr = countryArr.Split("|");
  13529. }
  13530. else if (countryArr.Contains("、"))
  13531. {
  13532. spArr = countryArr.Split("、");
  13533. }
  13534. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  13535. {
  13536. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  13537. if (dbQueryCountry != null)
  13538. {
  13539. visaCountryInfoArr.Add(dbQueryCountry);
  13540. }
  13541. }
  13542. }
  13543. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  13544. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  13545. #region 屏蔽黑屏代码生成
  13546. //var create = _GroupCostRepository.
  13547. // CreateGroupCostByBlackCode(dto.Diid);
  13548. //if (groupCost.Count == 0 && create.Code == 0)
  13549. //{
  13550. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  13551. //}
  13552. #endregion
  13553. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  13554. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  13555. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  13556. groupCostMap = groupCostMap.Select(x =>
  13557. {
  13558. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  13559. {
  13560. x.Date = dataForamt.ToString("yyyy-MM-dd");
  13561. }
  13562. return x;
  13563. }).ToList();
  13564. //GroupCostParameter.Add(new
  13565. // Grp_GroupCostParameter());
  13566. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  13567. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  13568. return Ok(JsonView(new
  13569. {
  13570. groupList,
  13571. groupInfo,
  13572. groupChecks,
  13573. groupCost = groupCostMap,
  13574. hotelNumber,
  13575. GroupCostParameter = GroupCostParameterMap,
  13576. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  13577. {
  13578. x.VisaCountry,
  13579. x.VisaPrice,
  13580. x.Id,
  13581. }).ToList(),
  13582. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  13583. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  13584. hotelIsTrue = hotelIsTrue,
  13585. }));
  13586. }
  13587. /// <summary>
  13588. /// 团组成本信息保存
  13589. /// </summary>
  13590. /// <param name="dto"></param>
  13591. /// <returns></returns>
  13592. [HttpPost]
  13593. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13594. {
  13595. if (dto.Diid <= 0 || dto.Userid <= 0)
  13596. {
  13597. return Ok(JsonView(false));
  13598. }
  13599. JsonView jw = null;
  13600. bool isTrue = false;
  13601. #region 复制团组成本
  13602. //if (dto.Diid == 2581)
  13603. //{
  13604. // dto.Diid = 2599;
  13605. // dto.CheckBoxs.ForEach(x =>
  13606. // {
  13607. // x.Diid = 2599;
  13608. // });
  13609. // dto.GroupCosts.ForEach(x =>
  13610. // {
  13611. // x.Diid = 2599;
  13612. // });
  13613. // dto.CostTypeHotelNumbers.ForEach(x =>
  13614. // {
  13615. // x.Diid = 2599;
  13616. // });
  13617. // dto.GroupCostParameters.ForEach(x =>
  13618. // {
  13619. // x.DiId = 2599;
  13620. // });
  13621. //}
  13622. #endregion
  13623. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13624. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13625. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13626. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13627. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13628. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13629. try
  13630. {
  13631. _sqlSugar.BeginTran();
  13632. isTrue = await _GroupCostRepository.
  13633. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13634. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13635. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13636. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13637. _sqlSugar.CommitTran();
  13638. jw = JsonView(true, "保存成功!", isTrue);
  13639. }
  13640. catch (Exception)
  13641. {
  13642. _sqlSugar.RollbackTran();
  13643. jw = JsonView(false);
  13644. }
  13645. return Ok(jw);
  13646. }
  13647. /// <summary>
  13648. /// 司兼导数据
  13649. /// </summary>
  13650. /// <param name="dto"></param>
  13651. /// <returns></returns>
  13652. [HttpPost]
  13653. public IActionResult GetCarGuides(CarGuidesDto dto)
  13654. {
  13655. JsonView jw = null;
  13656. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13657. jw = JsonView(true, "获取成功!", Data);
  13658. return Ok(jw);
  13659. }
  13660. /// <summary>
  13661. /// 导游数据
  13662. /// </summary>
  13663. /// <param name="dto"></param>
  13664. /// <returns></returns>
  13665. [HttpPost]
  13666. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13667. {
  13668. JsonView jw = null;
  13669. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13670. // 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
  13671. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13672. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13673. jw = JsonView(true, "获取成功!", Data);
  13674. return Ok(jw);
  13675. }
  13676. /// <summary>
  13677. /// 成本车数据
  13678. /// </summary>
  13679. /// <param name="dto"></param>
  13680. /// <returns></returns>
  13681. [HttpPost]
  13682. public IActionResult GetCarInfo(CarGuidesDto dto)
  13683. {
  13684. JsonView jw = null;
  13685. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13686. jw = JsonView(true, "获取成功!", Data);
  13687. return Ok(jw);
  13688. }
  13689. /// <summary>
  13690. /// 景点数据
  13691. /// </summary>
  13692. /// <param name="dto"></param>
  13693. /// <returns></returns>
  13694. [HttpPost]
  13695. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13696. {
  13697. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13698. return Ok(JsonView(true, "获取成功!", Data));
  13699. }
  13700. /// <summary>
  13701. /// 成本通知
  13702. /// </summary>
  13703. /// <param name="dto"></param>
  13704. /// <returns></returns>
  13705. [HttpPost]
  13706. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13707. {
  13708. if (dto.Diid < 0)
  13709. {
  13710. return Ok(JsonView(false));
  13711. }
  13712. JsonView jw = null;
  13713. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13714. if (GroupCostParameter != null)
  13715. {
  13716. int IsShare = 0;
  13717. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13718. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13719. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13720. string msg = string.Empty;
  13721. if (isTrue)
  13722. {
  13723. if (IsShare == 0)
  13724. {
  13725. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13726. }
  13727. else
  13728. {
  13729. #region 企微通知对应岗位用户
  13730. try
  13731. {
  13732. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13733. }
  13734. catch (Exception ex)
  13735. {
  13736. }
  13737. #endregion
  13738. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13739. }
  13740. jw = JsonView(isTrue, msg, new { IsShare });
  13741. }
  13742. else
  13743. {
  13744. msg = "修改失败!";
  13745. jw = JsonView(isTrue, msg);
  13746. }
  13747. }
  13748. else
  13749. {
  13750. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13751. }
  13752. return Ok(jw);
  13753. }
  13754. /// <summary>
  13755. /// 导出报价单
  13756. /// </summary>
  13757. /// <param name="dto"></param>
  13758. /// <returns></returns>
  13759. [HttpPost]
  13760. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13761. {
  13762. if (dto.Diid == 0)
  13763. {
  13764. return Ok(JsonView(false, "请传递团组id"));
  13765. }
  13766. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13767. if (deleInfo.Code != 0)
  13768. {
  13769. return Ok(JsonView(false, "团组信息查询失败!"));
  13770. }
  13771. var di = deleInfo.Data as DelegationInfoWebView;
  13772. if (di != null)
  13773. {
  13774. di.TeamName = di.TeamName.Replace("|", "、");
  13775. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13776. //文件名
  13777. string strFileName = di.TeamName + "-收款账单.doc";
  13778. //获取模板
  13779. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13780. //载入模板
  13781. Document doc = new Document(tmppath);
  13782. decimal TotalPrice = 0.00M;
  13783. string itemStr = string.Empty;
  13784. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13785. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13786. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13787. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13788. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13789. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13790. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13791. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13792. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13793. foreach (var cost in groupCostType)
  13794. {
  13795. var List = cost.ToList();
  13796. if (cost.Key == "A")
  13797. {
  13798. foreach (var ListItem in List)
  13799. {
  13800. if (ListItem.number > 0)
  13801. {
  13802. if (ListItem.code.Contains("TBR"))
  13803. {
  13804. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13805. }
  13806. else
  13807. {
  13808. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13809. }
  13810. TotalPrice += (ListItem.number * ListItem.price);
  13811. }
  13812. }
  13813. }
  13814. else
  13815. {
  13816. itemStr = itemStr.Insert(0, "A段\r\n");
  13817. itemStr += "B段\r\n";
  13818. foreach (var ListItem in List)
  13819. {
  13820. if (ListItem.number > 0)
  13821. {
  13822. if (ListItem.code.Contains("TBR"))
  13823. {
  13824. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13825. }
  13826. else
  13827. {
  13828. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13829. }
  13830. TotalPrice += (ListItem.number * ListItem.price);
  13831. }
  13832. }
  13833. }
  13834. }
  13835. #region 替换Word模板书签内容
  13836. Dictionary<string, string> marks = new Dictionary<string, string>();
  13837. marks.Add("To", di.ClientUnit);//付款方
  13838. marks.Add("ToTel", di.TellPhone);//付款方电话
  13839. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13840. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13841. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13842. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13843. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13844. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13845. marks.Add("PayItemContent", itemStr);//详细信息
  13846. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13847. #endregion
  13848. ////注
  13849. //if (doc.Range.Bookmarks["Attention"] != null)
  13850. //{
  13851. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13852. // mark.Text = frList[0].Attention;
  13853. //}
  13854. foreach (var item in marks.Keys)
  13855. {
  13856. if (doc.Range.Bookmarks[item] != null)
  13857. {
  13858. Bookmark mark = doc.Range.Bookmarks[item];
  13859. mark.Text = marks[item];
  13860. }
  13861. }
  13862. byte[] bytes = null;
  13863. using (MemoryStream stream = new MemoryStream())
  13864. {
  13865. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13866. bytes = stream.ToArray();
  13867. }
  13868. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  13869. return Ok(JsonView(true, "", new
  13870. {
  13871. Data = bytes,
  13872. strFileName,
  13873. }));
  13874. }
  13875. else
  13876. {
  13877. return Ok(JsonView(false, "团组信息不存在!"));
  13878. }
  13879. }
  13880. /// <summary>
  13881. /// 导出团组成本
  13882. /// </summary>
  13883. /// <param name="dto"></param>
  13884. /// <returns></returns>
  13885. [HttpPost]
  13886. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13887. {
  13888. var jw = JsonView(false);
  13889. if (dto.Diid == 0)
  13890. {
  13891. return Ok(JsonView(false, "请传递团组id"));
  13892. }
  13893. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13894. if (deleInfo.Code != 0)
  13895. {
  13896. return Ok(JsonView(false, "团组信息查询失败!"));
  13897. }
  13898. var di = deleInfo.Data as DelegationInfoWebView;
  13899. if (di == null)
  13900. {
  13901. return Ok(JsonView(false, "团组信息查询失败!"));
  13902. }
  13903. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13904. WorkbookDesigner designer = new WorkbookDesigner();
  13905. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13906. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13907. for (int i = 0; i < List_GC.Count; i++)
  13908. {
  13909. GroupCost_Excel gc = new GroupCost_Excel();
  13910. gc.Id = List_GC[i].Id;
  13911. gc.Diid = List_GC[i].Diid.ToString();
  13912. gc.DAY = List_GC[i].DAY;
  13913. string week = "";
  13914. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13915. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13916. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13917. gc.ITIN = List_GC[i].ITIN;
  13918. gc.CarType = List_GC[i].CarType;
  13919. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13920. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13921. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13922. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13923. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13924. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13925. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13926. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13927. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13928. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13929. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13930. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13931. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13932. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13933. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13934. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13935. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13936. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13937. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13938. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13939. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13940. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13941. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13942. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13943. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13944. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13945. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13946. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13947. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13948. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13949. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13950. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13951. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13952. List_GC1.Add(gc);
  13953. }
  13954. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13955. dt.TableName = "TB";
  13956. //报表标题等不用dt的值
  13957. designer.SetDataSource("TeamName", dto.title.TeamName);
  13958. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13959. designer.SetDataSource("Tax", dto.title.Tax);
  13960. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13961. designer.SetDataSource("Currency", dto.title.Currency);
  13962. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13963. designer.SetDataSource("Rate", dto.title.Rate);
  13964. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13965. var Aparams = hotels.Find(x => x.Type == "Default");
  13966. if (Aparams == null)
  13967. {
  13968. return Ok(jw);
  13969. }
  13970. //酒店数量
  13971. var txtSGRNumber = Aparams.SGR.ToString();
  13972. var txtTBRNumber = Aparams.TBR.ToString();
  13973. var txtJSESNumber = Aparams.JSES.ToString();
  13974. var txtSUITENumbe = Aparams.SUITE.ToString();
  13975. if (dto.costType == "B")
  13976. {
  13977. Aparams = hotels.Find(x => x.Type == "A");
  13978. var Bparams = hotels.Find(x => x.Type == "B");
  13979. if (Aparams == null || Bparams == null)
  13980. {
  13981. return Ok(jw);
  13982. }
  13983. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13984. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13985. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13986. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13987. }
  13988. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13989. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13990. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13991. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13992. var ws = designer.Workbook.Worksheets[0];
  13993. int Row = List_GC.Count;
  13994. int startIndex = 11;
  13995. int HideRows = 0;
  13996. List<int> hideRowsList = new List<int>();
  13997. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13998. #region A段left数据
  13999. var left = dto.leftInfo.Find(x => x.Type == "A");
  14000. if (left == null)
  14001. {
  14002. return Ok(jw);
  14003. }
  14004. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14005. if (leftBindData != null)
  14006. {
  14007. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14008. designer.SetDataSource("VisaRS", leftBindData.rs);
  14009. designer.SetDataSource("VisaXS", leftBindData.xs);
  14010. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14011. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14012. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14013. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14014. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14015. }
  14016. else
  14017. {
  14018. hideRowsList.Add(Row + startIndex + HideRows);
  14019. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14020. }
  14021. HideRows += 2;
  14022. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14023. if (leftBindData != null)
  14024. {
  14025. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14026. designer.SetDataSource("BXRS", leftBindData.rs);
  14027. designer.SetDataSource("BXXS", leftBindData.xs);
  14028. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14029. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14030. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14031. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14032. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14033. }
  14034. else
  14035. {
  14036. hideRowsList.Add(Row + startIndex + HideRows);
  14037. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14038. }
  14039. HideRows += 2;
  14040. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14041. if (leftBindData != null)
  14042. {
  14043. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14044. designer.SetDataSource("HSRS", leftBindData.rs);
  14045. designer.SetDataSource("HSXS", leftBindData.xs);
  14046. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14047. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14048. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14049. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14050. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14051. }
  14052. else
  14053. {
  14054. hideRowsList.Add(Row + startIndex + HideRows);
  14055. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14056. }
  14057. HideRows += 2;
  14058. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14059. if (leftBindData != null)
  14060. {
  14061. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14062. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14063. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14064. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14065. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14066. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14067. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14068. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14069. }
  14070. else
  14071. {
  14072. hideRowsList.Add(Row + startIndex + HideRows);
  14073. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14074. }
  14075. HideRows += 2;
  14076. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14077. if (leftBindData != null)
  14078. {
  14079. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14080. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14081. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14082. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14083. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14084. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14085. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14086. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14087. }
  14088. else
  14089. {
  14090. hideRowsList.Add(Row + startIndex + HideRows);
  14091. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14092. }
  14093. HideRows += 2;
  14094. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14095. if (leftBindData != null)
  14096. {
  14097. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14098. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14099. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14100. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14101. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14102. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14103. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14104. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14105. }
  14106. else
  14107. {
  14108. hideRowsList.Add(Row + startIndex + HideRows);
  14109. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14110. }
  14111. HideRows += 2;
  14112. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14113. if (leftBindData != null)
  14114. {
  14115. ////TBR
  14116. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14117. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14118. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14119. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14120. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14121. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14122. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14123. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14124. }
  14125. else
  14126. {
  14127. hideRowsList.Add(Row + startIndex + HideRows);
  14128. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14129. }
  14130. HideRows += 2;
  14131. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14132. if (leftBindData != null)
  14133. {
  14134. ////SGR
  14135. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14136. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14137. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14138. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14139. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14140. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14141. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14142. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14143. }
  14144. else
  14145. {
  14146. hideRowsList.Add(Row + startIndex + HideRows);
  14147. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14148. }
  14149. HideRows += 2;
  14150. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14151. if (leftBindData != null)
  14152. {
  14153. ////JS/ES
  14154. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14155. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14156. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14157. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14158. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14159. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14160. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14161. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14162. }
  14163. else
  14164. {
  14165. hideRowsList.Add(Row + startIndex + HideRows);
  14166. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14167. }
  14168. HideRows += 2;
  14169. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14170. if (leftBindData != null)
  14171. {
  14172. ////SUITE
  14173. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14174. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14175. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14176. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14177. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14178. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14179. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14180. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14181. }
  14182. else
  14183. {
  14184. hideRowsList.Add(Row + startIndex + HideRows);
  14185. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14186. }
  14187. HideRows += 2;
  14188. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14189. if (leftBindData != null)
  14190. {
  14191. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14192. designer.SetDataSource("DJRS", leftBindData.rs);
  14193. designer.SetDataSource("DJXS", leftBindData.xs);
  14194. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14195. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14196. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14197. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14198. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14199. }
  14200. else
  14201. {
  14202. hideRowsList.Add(Row + startIndex + HideRows);
  14203. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14204. }
  14205. HideRows += 2;
  14206. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14207. if (leftBindData != null)
  14208. {
  14209. designer.SetDataSource("HCPCB", leftBindData.cb);
  14210. designer.SetDataSource("HCPRS", leftBindData.rs);
  14211. designer.SetDataSource("HCPXS", leftBindData.xs);
  14212. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14213. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14214. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14215. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14216. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14217. }
  14218. else
  14219. {
  14220. hideRowsList.Add(Row + startIndex + HideRows);
  14221. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14222. }
  14223. HideRows += 2;
  14224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14225. if (leftBindData != null)
  14226. {
  14227. designer.SetDataSource("CPCB", leftBindData.cb);
  14228. designer.SetDataSource("CPRS", leftBindData.rs);
  14229. designer.SetDataSource("CPXS", leftBindData.xs);
  14230. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14231. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14232. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14233. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14234. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14235. }
  14236. else
  14237. {
  14238. hideRowsList.Add(Row + startIndex + HideRows);
  14239. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14240. }
  14241. HideRows += 2;
  14242. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14243. if (leftBindData != null)
  14244. {
  14245. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14246. designer.SetDataSource("GWRS", leftBindData.rs);
  14247. designer.SetDataSource("GWXS", leftBindData.xs);
  14248. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14249. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14250. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14251. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14252. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14253. }
  14254. else
  14255. {
  14256. hideRowsList.Add(Row + startIndex + HideRows);
  14257. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14258. }
  14259. HideRows += 2;
  14260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14261. if (leftBindData != null)
  14262. {
  14263. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14264. designer.SetDataSource("LYJRS", leftBindData.rs);
  14265. designer.SetDataSource("LYJXS", leftBindData.xs);
  14266. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14267. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14268. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14269. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14270. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14271. }
  14272. else
  14273. {
  14274. hideRowsList.Add(Row + startIndex + HideRows);
  14275. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14276. }
  14277. #endregion
  14278. #region A段Right信息
  14279. var right = dto.rightInfo.Find(x => x.Type == "A");
  14280. if (right == null)
  14281. {
  14282. return Ok(jw);
  14283. }
  14284. HideRows += 4;
  14285. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14286. if (rightBindData != null)
  14287. {
  14288. //经济舱 + 双人间 TBR
  14289. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14290. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14291. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14292. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14293. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14294. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14295. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14296. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14297. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14298. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14299. }
  14300. else
  14301. {
  14302. hideRowsList.Add(Row + startIndex + HideRows);
  14303. }
  14304. HideRows += 2;
  14305. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14306. if (rightBindData != null)
  14307. {
  14308. //经济舱 + 单人间 SGR
  14309. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14310. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14311. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14312. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14313. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14314. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14315. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14316. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14317. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14318. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14319. }
  14320. else
  14321. {
  14322. hideRowsList.Add(Row + startIndex + HideRows);
  14323. }
  14324. HideRows += 2;
  14325. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14326. if (rightBindData != null)
  14327. {
  14328. //公务舱 + 单人间 SGR
  14329. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14330. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14331. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14332. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14333. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14334. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14335. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14336. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14337. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14338. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14339. }
  14340. else
  14341. {
  14342. hideRowsList.Add(Row + startIndex + HideRows);
  14343. }
  14344. HideRows += 2;
  14345. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14346. if (rightBindData != null)
  14347. {
  14348. //公务舱 + 小套房 JSES
  14349. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14350. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14351. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14352. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14353. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14354. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14355. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14356. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14357. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14358. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14359. }
  14360. else
  14361. {
  14362. hideRowsList.Add(Row + startIndex + HideRows);
  14363. }
  14364. HideRows += 2;
  14365. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14366. if (rightBindData != null)
  14367. {
  14368. //公务舱 + 小套房 JSES
  14369. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14370. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14371. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14372. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14373. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14374. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14375. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14376. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14377. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14378. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14379. }
  14380. else
  14381. {
  14382. hideRowsList.Add(Row + startIndex + HideRows);
  14383. }
  14384. HideRows += 2;
  14385. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14386. if (rightBindData != null)
  14387. {
  14388. //经济舱 + 大套房
  14389. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14390. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14391. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14392. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14393. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14394. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14395. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14396. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14397. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14398. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14399. }
  14400. else
  14401. {
  14402. hideRowsList.Add(Row + startIndex + HideRows);
  14403. }
  14404. HideRows += 2;
  14405. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14406. if (rightBindData != null)
  14407. {
  14408. //头等舱 + 小套房 JSES
  14409. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14410. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14411. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14412. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14413. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14414. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14415. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14416. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14417. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14418. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14419. }
  14420. else
  14421. {
  14422. hideRowsList.Add(Row + startIndex + HideRows);
  14423. }
  14424. HideRows += 2;
  14425. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14426. if (rightBindData != null)
  14427. {
  14428. //头等舱 + 大套房
  14429. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14430. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14431. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14432. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14433. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14434. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14435. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14436. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14437. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14438. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14439. }
  14440. else
  14441. {
  14442. hideRowsList.Add(Row + startIndex + HideRows);
  14443. }
  14444. #endregion
  14445. #region B段标题清空
  14446. designer.SetDataSource("CostBDRCB", "");
  14447. designer.SetDataSource("CostBRS", "");
  14448. designer.SetDataSource("CostBXS", "");
  14449. designer.SetDataSource("CostBZCB", "");
  14450. designer.SetDataSource("CostBDRBJ", "");
  14451. designer.SetDataSource("CostBZBJ", "");
  14452. designer.SetDataSource("CostBDRLR", "");
  14453. designer.SetDataSource("CostBZLR", "");
  14454. designer.SetDataSource("CostBDRCBOM", "");
  14455. designer.SetDataSource("CostBRSOM", "");
  14456. designer.SetDataSource("CostBZCBOM", "");
  14457. designer.SetDataSource("CostBDRBJOM", "");
  14458. designer.SetDataSource("CostBZBJOM", "");
  14459. designer.SetDataSource("CostBDRLROM", "");
  14460. designer.SetDataSource("CostBZLROM", "");
  14461. #endregion
  14462. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  14463. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  14464. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  14465. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  14466. designer.SetDataSource("DJName", "地接(CNY)");
  14467. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  14468. designer.SetDataSource("CPName", "地接-船票(CNY)");
  14469. designer.SetDataSource("GWName", "公务(CNY)");
  14470. designer.SetDataSource("YQHName", "邀请函(CNY)");
  14471. designer.SetDataSource("LYJName", "零用金(CNY)");
  14472. designer.SetDataSource("HSName", "核酸检测(CNY)");
  14473. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  14474. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  14475. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  14476. designer.SetDataSource("BXName", "保险(CNY)");
  14477. designer.SetDataSource("VisaName", "签证(CNY)");
  14478. #region B段基本数据
  14479. if (dto.costType == "B")
  14480. {
  14481. left = dto.leftInfo.Find(x => x.Type == "B");
  14482. if (left == null)
  14483. {
  14484. return Ok(jw);
  14485. }
  14486. #region B段left数据
  14487. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14488. if (leftBindData != null)
  14489. {
  14490. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  14491. designer.SetDataSource("BHSRS", leftBindData.rs);
  14492. designer.SetDataSource("BHSXS", leftBindData.xs);
  14493. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14494. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14495. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14496. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14497. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14498. }
  14499. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14500. if (leftBindData != null)
  14501. {
  14502. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  14503. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  14504. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  14505. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14506. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14507. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14508. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14509. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14510. }
  14511. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14512. if (leftBindData != null)
  14513. {
  14514. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  14515. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  14516. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  14517. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14518. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14519. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14520. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14521. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14522. }
  14523. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14524. if (leftBindData != null)
  14525. {
  14526. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  14527. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  14528. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  14529. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14530. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14531. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14532. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14533. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14534. }
  14535. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14536. if (leftBindData != null)
  14537. {
  14538. designer.SetDataSource("BHCPCB", leftBindData.cb);
  14539. designer.SetDataSource("BHCPRS", leftBindData.rs);
  14540. designer.SetDataSource("BHCPXS", leftBindData.xs);
  14541. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14542. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14543. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14544. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14545. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14546. }
  14547. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14548. if (leftBindData != null)
  14549. {
  14550. designer.SetDataSource("BCPCB", leftBindData.cb);
  14551. designer.SetDataSource("BCPRS", leftBindData.rs);
  14552. designer.SetDataSource("BCPXS", leftBindData.xs);
  14553. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14554. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14555. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14556. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14557. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14558. }
  14559. //TBR
  14560. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14561. if (leftBindData != null)
  14562. {
  14563. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  14564. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  14565. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  14566. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14567. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14568. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14569. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14570. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14571. }
  14572. //SGR
  14573. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14574. if (leftBindData != null)
  14575. {
  14576. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  14577. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  14578. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  14579. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14580. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14581. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14582. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14583. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14584. }
  14585. //JS/ES
  14586. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14587. if (leftBindData != null)
  14588. {
  14589. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  14590. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14591. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14592. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14593. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14594. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14595. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14596. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14597. }
  14598. //SUITE
  14599. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14600. if (leftBindData != null)
  14601. {
  14602. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14603. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14604. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14605. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14606. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14607. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14608. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14609. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14610. }
  14611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14612. if (leftBindData != null)
  14613. {
  14614. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14615. designer.SetDataSource("BDJRS", leftBindData.rs);
  14616. designer.SetDataSource("BDJXS", leftBindData.xs);
  14617. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14618. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14619. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14620. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14621. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14622. }
  14623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14624. if (leftBindData != null)
  14625. {
  14626. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14627. designer.SetDataSource("BGWRS", leftBindData.rs);
  14628. designer.SetDataSource("BGWXS", leftBindData.xs);
  14629. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14630. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14631. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14632. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14633. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14634. }
  14635. #region 优化方案
  14636. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14637. //excelBind.Add("零用金", new {
  14638. //cb="",
  14639. //rs="",
  14640. //xs ="",
  14641. //zcb = "",
  14642. //});
  14643. #endregion
  14644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14645. if (leftBindData != null)
  14646. {
  14647. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14648. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14649. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14650. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14651. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14652. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14653. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14654. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14655. }
  14656. #endregion
  14657. #region B段Right信息
  14658. right = dto.rightInfo.Find(x => x.Type == "B");
  14659. if (right == null)
  14660. {
  14661. return Ok(jw);
  14662. }
  14663. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14664. if (rightBindData != null)
  14665. {
  14666. //经济舱 + 双人间 TBR
  14667. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14668. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14669. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14670. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14671. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14672. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14673. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14674. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14675. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14676. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14677. }
  14678. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14679. if (rightBindData != null)
  14680. {
  14681. //经济舱 + 单人间 SGR
  14682. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14683. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14684. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14685. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14686. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14687. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14688. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14689. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14690. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14691. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14692. }
  14693. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14694. if (rightBindData != null)
  14695. {
  14696. //公务舱 + 单人间 SGR
  14697. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14698. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14699. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14700. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14701. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14702. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14703. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14704. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14705. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14706. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14707. }
  14708. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14709. if (rightBindData != null)
  14710. {
  14711. //公务舱 + 小套房 JSES
  14712. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14713. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14714. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14715. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14716. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14717. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14718. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14719. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14720. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14721. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14722. }
  14723. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14724. if (rightBindData != null)
  14725. {
  14726. //公务舱 + 小套房 JSES
  14727. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14728. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14729. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14730. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14731. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14732. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14733. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14734. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14735. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14736. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14737. }
  14738. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14739. if (rightBindData != null)
  14740. {
  14741. //经济舱 + 大套房
  14742. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14743. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14744. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14745. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14746. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14747. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14748. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14749. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14750. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14751. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14752. }
  14753. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14754. if (rightBindData != null)
  14755. {
  14756. //头等舱 + 小套房 JSES
  14757. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14758. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14759. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14760. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14761. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14762. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14763. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14764. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14765. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14766. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14767. }
  14768. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14769. if (rightBindData != null)
  14770. {
  14771. //头等舱 + 大套房
  14772. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  14773. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14774. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14775. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14776. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14777. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14778. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14779. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14780. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14781. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14782. }
  14783. #endregion
  14784. #region 标题
  14785. designer.SetDataSource("CostBDRCB", "单人成本");
  14786. designer.SetDataSource("CostBRS", "人数");
  14787. designer.SetDataSource("CostBXS", "系数");
  14788. designer.SetDataSource("CostBZCB", "总成本");
  14789. designer.SetDataSource("CostBDRBJ", "单人报价");
  14790. designer.SetDataSource("CostBZBJ", "总报价");
  14791. designer.SetDataSource("CostBDRLR", "单人利润");
  14792. designer.SetDataSource("CostBZLR", "总利润");
  14793. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14794. designer.SetDataSource("CostBRSOM", "人数");
  14795. designer.SetDataSource("CostBZCBOM", "总成本");
  14796. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14797. designer.SetDataSource("CostBZBJOM", "总报价");
  14798. designer.SetDataSource("CostBDRLROM", "单人利润");
  14799. designer.SetDataSource("CostBZLROM", "总利润");
  14800. #endregion
  14801. }
  14802. #endregion
  14803. designer.SetDataSource("TzZCB2", TzZCB2);
  14804. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14805. designer.SetDataSource("TzZLR2", TzZLR2);
  14806. string[] dataSourceKeys = new string[]
  14807. {
  14808. "VF",
  14809. "TGS",
  14810. "TGOF",
  14811. "TGM",
  14812. "TGA",
  14813. "TGTF",
  14814. "TGEF",
  14815. "CFM",
  14816. "CFOF",
  14817. "B",
  14818. "L",
  14819. "D",
  14820. "TBR",
  14821. "SGR",
  14822. "JSES",
  14823. "Suite",
  14824. "TV",
  14825. "1L",
  14826. "IF",
  14827. "EF",
  14828. "BRF",
  14829. "TE",
  14830. "TGT",
  14831. "DRVT",
  14832. "PC",
  14833. "TLF",
  14834. "ECT"
  14835. };
  14836. foreach (var item in dataSourceKeys)
  14837. {
  14838. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14839. if (find != null)
  14840. {
  14841. designer.SetDataSource(item, find.text);
  14842. }
  14843. else
  14844. {
  14845. designer.SetDataSource(item, 0);
  14846. }
  14847. }
  14848. designer.SetDataSource(dt);
  14849. //根据数据源处理生成报表内容
  14850. designer.Process();
  14851. designer.Workbook.Worksheets[0].Name = "清单";
  14852. Worksheet sheet = designer.Workbook.Worksheets[0];
  14853. foreach (var Rowindex in hideRowsList)
  14854. {
  14855. ws.Cells.HideRows(Rowindex, 2);
  14856. }
  14857. byte[] bytes = null;
  14858. string strFileName = di.TeamName + "-团组-成本.xls";
  14859. using (MemoryStream stream = new MemoryStream())
  14860. {
  14861. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  14862. bytes = stream.ToArray();
  14863. }
  14864. return Ok(JsonView(true, "", new
  14865. {
  14866. Data = bytes,
  14867. strFileName,
  14868. }));
  14869. }
  14870. /// <summary>
  14871. /// 导出客户报表
  14872. /// </summary>
  14873. /// <returns></returns>
  14874. [HttpPost]
  14875. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14876. {
  14877. var jw = JsonView(false);
  14878. if (dto.Diid == 0)
  14879. {
  14880. return Ok(JsonView(false, "请传递团组id"));
  14881. }
  14882. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14883. if (deleInfo.Code != 0)
  14884. {
  14885. return Ok(JsonView(false, "团组信息查询失败!"));
  14886. }
  14887. var di = deleInfo.Data as DelegationInfoWebView;
  14888. if (di == null)
  14889. {
  14890. return Ok(JsonView(false, "团组信息查询失败!"));
  14891. }
  14892. //文件名
  14893. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14894. //获取模板
  14895. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14896. //载入模板
  14897. Document doc = new Document(tmppath);
  14898. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14899. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14900. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14901. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14902. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14903. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14904. if (AParameter == null)
  14905. {
  14906. return Ok(JsonView(false, "系数不存在!"));
  14907. }
  14908. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14909. , TzAirDesc, TzZCost;
  14910. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14911. = TzAirDesc = TzZCost = string.Empty;
  14912. TzNumber = AParameter.CostTypenumber.ToString();
  14913. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14914. CarGuides1 = dto.CarGuides1;
  14915. Meal = dto.Meal;
  14916. SubsidizedMeals = dto.SubsidizedMeals;
  14917. NightRepair = dto.NightRepair;
  14918. AttractionsTickets = dto.AttractionsTickets;
  14919. MiscellaneousFees = dto.MiscellaneousFees;
  14920. ATip = dto.ATip;
  14921. TzHotelDesc = "";
  14922. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14923. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14924. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14925. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14926. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14927. TzAirDesc = "";
  14928. TzZCost = dto.TzZCost;
  14929. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14930. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14931. var index = 1;
  14932. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14933. foreach (var item in TzHotelDescArr)
  14934. {
  14935. if (AinfoArr != null)
  14936. {
  14937. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14938. if (Ainfo != null)
  14939. {
  14940. if (int.Parse(Ainfo.rs) <= 0)
  14941. {
  14942. continue;
  14943. }
  14944. var hotelText = string.Empty;
  14945. switch (item)
  14946. {
  14947. case "SGR":
  14948. hotelText = "单人间";
  14949. break;
  14950. case "JSES":
  14951. hotelText = "小套房";
  14952. break;
  14953. case "SUITE":
  14954. hotelText = "套房";
  14955. break;
  14956. case "TBR":
  14957. hotelText = "双人间";
  14958. break;
  14959. }
  14960. if (item != "TBR")
  14961. {
  14962. 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";
  14963. }
  14964. else
  14965. {
  14966. 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";
  14967. }
  14968. index++;
  14969. }
  14970. }
  14971. }
  14972. index = 1;
  14973. foreach (var item in TzAirDescArr)
  14974. {
  14975. if (AinfoArr != null)
  14976. {
  14977. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14978. if (Ainfo != null)
  14979. {
  14980. if (int.Parse(Ainfo.rs) <= 0)
  14981. {
  14982. continue;
  14983. }
  14984. 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";
  14985. index++;
  14986. }
  14987. }
  14988. }
  14989. if (dto.costType == "B")
  14990. {
  14991. if (BParameter == null)
  14992. {
  14993. return Ok(JsonView(false, "B段系数不存在!"));
  14994. }
  14995. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14996. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14997. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14998. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14999. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15000. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15001. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15002. foreach (var item in TzHotelDescArr)
  15003. {
  15004. if (AinfoArr != null)
  15005. {
  15006. TzHotelDesc += "B段信息 \r\n";
  15007. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15008. if (Ainfo != null)
  15009. {
  15010. if (int.Parse(Ainfo.rs) <= 0)
  15011. {
  15012. continue;
  15013. }
  15014. var hotelText = string.Empty;
  15015. switch (item)
  15016. {
  15017. case "SGR":
  15018. hotelText = "单人间";
  15019. break;
  15020. case "JSES":
  15021. hotelText = "小套房";
  15022. break;
  15023. case "SUITE":
  15024. hotelText = "套房";
  15025. break;
  15026. case "TBR":
  15027. hotelText = "双人间";
  15028. break;
  15029. }
  15030. if (item != "TBR")
  15031. {
  15032. 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";
  15033. }
  15034. else
  15035. {
  15036. 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";
  15037. }
  15038. index++;
  15039. }
  15040. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15041. }
  15042. }
  15043. index = 1;
  15044. foreach (var item in TzAirDescArr)
  15045. {
  15046. if (AinfoArr != null)
  15047. {
  15048. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15049. if (Ainfo != null)
  15050. {
  15051. if (int.Parse(Ainfo.rs) <= 0)
  15052. {
  15053. continue;
  15054. }
  15055. 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";
  15056. index++;
  15057. }
  15058. }
  15059. }
  15060. }
  15061. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15062. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15063. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15064. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15065. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15066. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15067. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15068. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15069. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15070. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15071. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15072. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15073. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15074. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15075. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15076. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15077. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15078. DickeyValue.Add("TzZCost", TzZCost);
  15079. foreach (var key in DickeyValue.Keys)
  15080. {
  15081. if (doc.Range.Bookmarks[key] != null)
  15082. {
  15083. Bookmark mark = doc.Range.Bookmarks[key];
  15084. mark.Text = DickeyValue[key];
  15085. }
  15086. }
  15087. byte[] bytes = null;
  15088. string strFileName = di.TeamName + "-客户报价.doc";
  15089. using (MemoryStream stream = new MemoryStream())
  15090. {
  15091. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15092. bytes = stream.ToArray();
  15093. }
  15094. return Ok(JsonView(true, "", new
  15095. {
  15096. Data = bytes,
  15097. strFileName,
  15098. }));
  15099. }
  15100. /// <summary>
  15101. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15102. /// </summary>
  15103. /// <param name="dto"></param>
  15104. /// <returns></returns>
  15105. [HttpPost]
  15106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15107. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15108. {
  15109. try
  15110. {
  15111. #region 参数验证
  15112. if (dto.DiId < 0)
  15113. {
  15114. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15115. }
  15116. List<int> cTableIds = new List<int>() {
  15117. 76 ,//酒店预订
  15118. 77 ,//行程
  15119. 79 ,//车/导游地接
  15120. 80 ,//签证
  15121. 81 ,//邀请/公务活
  15122. 82 ,//团组客户保险
  15123. 85 ,//机票预订
  15124. 98 ,//其他款项
  15125. 285 ,//收款退还
  15126. 751 ,//酒店早餐
  15127. 1015 // 超支费用
  15128. };
  15129. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15130. {
  15131. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15132. }
  15133. #endregion
  15134. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15135. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15136. if (_GroupCostParameters.Count <= 0)
  15137. {
  15138. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15139. }
  15140. if (_GroupCostParameters[0].IsShare == 0)
  15141. {
  15142. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15143. }
  15144. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15145. //处理date为空问题
  15146. if (_GroupCosts.Count > 0)
  15147. {
  15148. for (int i = 0; i < _GroupCosts.Count; i++)
  15149. {
  15150. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15151. {
  15152. if (i > 0)
  15153. {
  15154. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15155. }
  15156. }
  15157. }
  15158. }
  15159. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15160. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15161. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15162. string currCode = "";
  15163. #region currCode 验证
  15164. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15165. if (isInt)
  15166. {
  15167. var currData = currDatas.Find(it => it.Id == intCurrency);
  15168. if (currData != null)
  15169. {
  15170. currCode = currData.Name;
  15171. }
  15172. }
  15173. else
  15174. {
  15175. currCode = _GroupCostParameters[0].Currency.Trim();
  15176. }
  15177. #endregion
  15178. //op,酒店单段模式存储
  15179. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15180. {
  15181. CurrencyCode = currCode,
  15182. Rate = _GroupCostParameters[0].Rate,
  15183. CostType = _GroupCostParameters[0].CostType,
  15184. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15185. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15186. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15187. };
  15188. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15189. if (_GroupCostParameters.Count == 2)
  15190. {
  15191. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15192. }
  15193. foreach (var item in _GroupCostParameters)
  15194. {
  15195. decimal _rate = 1;
  15196. decimal _rate1 = item.Rate;
  15197. decimal _scale = 1;
  15198. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15199. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15200. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15201. //if (userInfo != null)
  15202. //{
  15203. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15204. // {
  15205. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15206. // {
  15207. // _scale = 1.00M;
  15208. // }
  15209. // }
  15210. //}
  15211. #endregion
  15212. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15213. {
  15214. CurrencyCode = currCode,
  15215. Rate = _rate1,
  15216. CostType = item.CostType,
  15217. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15218. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15219. CostTypeNumber = item.CostTypenumber
  15220. };
  15221. if (_GroupCostParameters.Count > 1)
  15222. {
  15223. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15224. }
  15225. else
  15226. {
  15227. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15228. }
  15229. if (dto.CTable == 79)//
  15230. {
  15231. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15232. modulePromptInfo.TotalCost = item.DJCB;
  15233. }
  15234. List<string> costTypes = new List<string>() { "A", "B" };
  15235. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15236. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15237. if (_GroupCostsDuplicates.Count() == 1)
  15238. {
  15239. _GroupCostsTypeData = _GroupCosts;
  15240. }
  15241. else
  15242. {
  15243. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15244. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15245. }
  15246. /*
  15247. * 76 酒店预订
  15248. * 77 行程
  15249. * 79 车/导游地接
  15250. * 80 签证
  15251. * 81 邀请/公务活动
  15252. * 82 团组客户保险
  15253. * 85 机票预订
  15254. * 98 其他款项
  15255. * 285 收款退还
  15256. * 751 酒店早餐
  15257. * 1015 超支费用
  15258. */
  15259. switch (dto.CTable)
  15260. {
  15261. case 76: // 酒店预订
  15262. _ModuleSubPromptInfo.AddRange(
  15263. _GroupCostsTypeData.Select(it => new
  15264. {
  15265. it.DAY,
  15266. it.Date,
  15267. it.ACCON,
  15268. it.ITIN,
  15269. it.SGR,
  15270. it.TBR,
  15271. it.JS_ES,
  15272. it.Suite
  15273. })
  15274. );
  15275. break;
  15276. case 79: // 车/导游地接
  15277. _ModuleSubPromptInfo.AddRange(
  15278. _GroupCostsTypeData.Select(it => new
  15279. {
  15280. Date = it.Date, //日期
  15281. CarFee = it.CarCost * _rate * _scale, //车费用
  15282. CarType = it.CarType, //车型
  15283. DriverFee = it.CFS * _rate * _scale, //司机工资
  15284. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15285. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15286. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15287. GuideFee = it.TGS * _rate * _scale, //导游费用
  15288. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15289. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15290. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15291. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15292. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15293. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15294. Breakfast = it.B * _rate * _scale, //早餐费
  15295. Lunch = it.L * _rate * _scale, //午餐费
  15296. Dinner = it.D * _rate * _scale, //晚餐费
  15297. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15298. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15299. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15300. TicketFee = it.EF * _rate * _scale, //门票费
  15301. TicketRemark = it.EFR, //门票费描述
  15302. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15303. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15304. SpentCash = it.PC * _rate * _scale, //零用金
  15305. LeadersFee = it.TLF * _rate * _scale, //领队费
  15306. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15307. })
  15308. );
  15309. break;
  15310. case 85: // 机票
  15311. List<dynamic> datas = new List<dynamic>();
  15312. datas.Add(
  15313. new
  15314. {
  15315. AirType = "经济舱",
  15316. AirNum = item.JJCRS,
  15317. AirDRCB = item.JJCCB,
  15318. AirZCB = (item.JJCRS * item.JJCCB)
  15319. }
  15320. );
  15321. datas.Add(
  15322. new
  15323. {
  15324. AirType = "公务舱",
  15325. AirNum = item.GWCRS,
  15326. AirDRCB = item.GWCCB,
  15327. AirZCB = (item.GWCRS * item.GWCCB)
  15328. }
  15329. );
  15330. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15331. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15332. modulePromptInfo.Data = new
  15333. {
  15334. airFeeData = datas,
  15335. airInitData = initDatas
  15336. };
  15337. _ModulePromptInfos.Add(modulePromptInfo);
  15338. break;
  15339. default:
  15340. break;
  15341. }
  15342. }
  15343. if (dto.CTable != 85)
  15344. {
  15345. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15346. _ModulePromptInfos.Add(_ModulePromptInfo);
  15347. }
  15348. _view.ModulePromptInfos = _ModulePromptInfos;
  15349. return Ok(JsonView(true, "操作成功!", _view));
  15350. }
  15351. catch (Exception ex)
  15352. {
  15353. return Ok(JsonView(false, ex.Message));
  15354. }
  15355. }
  15356. /// <summary>
  15357. /// 根据黑屏代码重新生成行程
  15358. /// </summary>
  15359. /// <param name="dto"></param>
  15360. /// <returns></returns>
  15361. [HttpPost]
  15362. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15363. {
  15364. var jw = JsonView(false,"Error");
  15365. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15366. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15367. .Select(x=> new
  15368. {
  15369. x.Id,
  15370. x.Title
  15371. })
  15372. .ToList();
  15373. if (Create.Any())
  15374. {
  15375. jw.Msg = "获取成功!";
  15376. jw.Code = 200;
  15377. jw.Data = new
  15378. {
  15379. BlackCodeListSelect = Create,
  15380. blackCodeIsTrue = true
  15381. };
  15382. }
  15383. else
  15384. {
  15385. jw.Code = 400;
  15386. jw.Data = new
  15387. {
  15388. BlackCodeListSelect = Create,
  15389. blackCodeIsTrue = false,
  15390. };
  15391. }
  15392. return Ok(jw);
  15393. }
  15394. /// <summary>
  15395. /// 根据黑屏代码Id重新生成行程
  15396. /// </summary>
  15397. /// <param name="dto"></param>
  15398. /// <returns></returns>
  15399. [HttpPost]
  15400. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15401. {
  15402. var jw = JsonView(false, "Error");
  15403. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15404. if (result.Code == 0)
  15405. {
  15406. jw.Msg = "获取成功!";
  15407. jw.Code = 200;
  15408. jw.Data = new
  15409. {
  15410. groupCost = result.Data,
  15411. blackCodeIsTrue = true
  15412. };
  15413. }
  15414. else
  15415. {
  15416. jw.Code = 400;
  15417. jw.Data = new
  15418. {
  15419. groupCost = result.Data,
  15420. blackCodeIsTrue = false,
  15421. };
  15422. }
  15423. return Ok(jw);
  15424. }
  15425. /// <summary>
  15426. /// 成本获取OP历史车费用
  15427. /// </summary>
  15428. /// <param name="dto"></param>
  15429. /// <returns></returns>
  15430. [HttpPost]
  15431. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15432. {
  15433. var jw = JsonView(false);
  15434. try
  15435. {
  15436. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15437. //获取现有所有车的数据
  15438. if (!dto.Param.IsNullOrWhiteSpace())
  15439. {
  15440. string sql = $@"
  15441. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15442. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15443. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15444. 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
  15445. AND gctggr.ServiceEndTime is not NULL
  15446. ORDER by gctggrc.id DESC
  15447. ";
  15448. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  15449. var numeberResult = await Task.Run(() =>
  15450. {
  15451. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  15452. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  15453. return numberArr;
  15454. });
  15455. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  15456. foreach (var item in numeberResult)
  15457. {
  15458. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  15459. {
  15460. Country = "数据异常!",
  15461. City = string.Empty,
  15462. };
  15463. item.Area = find.Country + " " + find.City;
  15464. }
  15465. dbResult.AddRange(numeberResult);
  15466. if (dto.Param.Contains("、"))
  15467. {
  15468. var sp = dto.Param.Split("、");
  15469. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15470. .Where(x =>
  15471. {
  15472. return System.Array.Exists(sp, e =>
  15473. {
  15474. bool where = false;
  15475. if (x.Area != null)
  15476. {
  15477. where = x.Area.Contains(e);
  15478. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15479. {
  15480. return false;
  15481. }
  15482. }
  15483. if (x.PriceName != null && !where)
  15484. {
  15485. where = x.PriceName.Contains(e);
  15486. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15487. {
  15488. return false;
  15489. }
  15490. }
  15491. return where;
  15492. });
  15493. }).ToList();
  15494. }
  15495. else
  15496. {
  15497. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  15498. .Where(x =>
  15499. {
  15500. bool where = false;
  15501. if (x.Area != null)
  15502. {
  15503. where = x.Area.Contains(dto.Param);
  15504. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  15505. {
  15506. return false;
  15507. }
  15508. }
  15509. if (x.PriceName != null && !where)
  15510. {
  15511. where = x.PriceName.Contains(dto.Param);
  15512. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  15513. {
  15514. return false;
  15515. }
  15516. }
  15517. return where;
  15518. }
  15519. )
  15520. .ToList();
  15521. }
  15522. }
  15523. var view = dbResult.Select(x =>
  15524. {
  15525. decimal dp = 0.00M;
  15526. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  15527. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  15528. if (string.IsNullOrWhiteSpace(x.DatePrice))
  15529. {
  15530. if (startB && endB)
  15531. {
  15532. var timesp = endD.Subtract(startD);
  15533. if ((timesp.Days + 1) != 0)
  15534. {
  15535. dp = x.Price / (timesp.Days + 1);
  15536. }
  15537. }
  15538. }
  15539. else
  15540. {
  15541. dp = x.Price;
  15542. }
  15543. return new
  15544. {
  15545. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  15546. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  15547. x.Area,
  15548. x.id,
  15549. price = x.Price.ToString("F2"),
  15550. x.PriceName,
  15551. x.PriceContent,
  15552. x.TeamName,
  15553. x.DatePrice,
  15554. dayPrice = dp.ToString("F2"),
  15555. };
  15556. }).OrderByDescending(x => x.id).ToList();
  15557. jw = JsonView(true, "获取成功!", view);
  15558. }
  15559. catch (Exception e)
  15560. {
  15561. jw = JsonView(false, e.Message);
  15562. }
  15563. return Ok(jw);
  15564. }
  15565. [HttpPost]
  15566. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  15567. {
  15568. var jw = JsonView(true);
  15569. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  15570. if (string.IsNullOrWhiteSpace(dto.Keyword))
  15571. {
  15572. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15573. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15574. WHEN COUNT(*) >= 0 THEN 'True'
  15575. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15576. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15577. ")
  15578. .ToList();
  15579. }
  15580. else
  15581. {
  15582. string likeKey = string.Empty;
  15583. foreach (var item in dto.Keyword)
  15584. {
  15585. likeKey += "%" + item;
  15586. }
  15587. likeKey += "%";
  15588. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15589. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15590. WHEN COUNT(*) >= 0 THEN 'True'
  15591. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15592. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15593. ")
  15594. .ToList();
  15595. }
  15596. if (matches.Any())
  15597. {
  15598. jw.Data = matches;
  15599. }
  15600. else
  15601. {
  15602. jw.Code = 201;
  15603. jw.Msg = "empty list";
  15604. jw.Data = new List<string>(1);
  15605. }
  15606. return Ok(jw);
  15607. }
  15608. #endregion
  15609. #region 酒店预订 新 雷怡 2023-12-28 17:45
  15610. /// <summary>
  15611. /// 酒店预订
  15612. /// 酒店费用列表 根据团组Id查询
  15613. /// </summary>
  15614. /// <param name="_dto"></param>
  15615. /// <returns></returns>
  15616. [HttpPost]
  15617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15618. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  15619. {
  15620. #region 参数验证
  15621. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15622. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15623. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15624. #region 团组操作权限验证 76 酒店预定模块
  15625. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15626. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15627. #endregion
  15628. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15629. #region 页面操作权限验证
  15630. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15631. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15632. #endregion
  15633. #endregion
  15634. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  15635. }
  15636. /// <summary>
  15637. /// 酒店预订
  15638. /// 基础数据
  15639. /// </summary>
  15640. /// <param name="_dto"></param>
  15641. /// <returns></returns>
  15642. [HttpPost]
  15643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15644. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  15645. {
  15646. #region 参数验证
  15647. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15648. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15649. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15650. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15651. #region 页面操作权限验证
  15652. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15653. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15654. #endregion
  15655. #region 团组操作权限验证 76 酒店预定模块
  15656. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15657. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15658. #endregion
  15659. #endregion
  15660. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  15661. }
  15662. /// <summary>
  15663. /// 酒店预订
  15664. /// 创建 入住卷号码
  15665. /// </summary>
  15666. /// <param name="_dto"></param>
  15667. /// <returns></returns>
  15668. [HttpPost]
  15669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15670. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  15671. {
  15672. #region 参数验证
  15673. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15674. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15675. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15677. #region 页面操作权限验证
  15678. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15679. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15680. #endregion
  15681. #region 团组操作权限验证 76 酒店预定模块
  15682. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15683. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15684. #endregion
  15685. #endregion
  15686. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  15687. if (data.Code != 0)
  15688. {
  15689. return Ok(JsonView(false, data.Msg));
  15690. }
  15691. return Ok(JsonView(true, data.Msg, data.Data));
  15692. }
  15693. /// <summary>
  15694. /// 酒店预订
  15695. /// 详情
  15696. /// </summary>
  15697. /// <param name="_dto"></param>
  15698. /// <returns></returns>
  15699. [HttpPost]
  15700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15701. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  15702. {
  15703. #region 参数验证
  15704. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  15705. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15706. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  15707. #region 团组操作权限验证 76 酒店预定模块
  15708. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15709. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15710. #endregion
  15711. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15712. #region 页面操作权限验证
  15713. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15714. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15715. #endregion
  15716. #endregion
  15717. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  15718. }
  15719. /// <summary>
  15720. /// 酒店预订
  15721. /// Add Or Edit
  15722. /// </summary>
  15723. /// <param name="_dto"></param>
  15724. /// <returns></returns>
  15725. [HttpPost]
  15726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15727. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  15728. {
  15729. #region 参数验证
  15730. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15731. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15732. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15733. #region 团组操作权限验证 76 酒店预定模块
  15734. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15735. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15736. #endregion
  15737. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15738. #region 页面操作权限验证
  15739. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15740. if (_dto.Id == 0) // Add
  15741. {
  15742. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  15743. }
  15744. else if (_dto.Id > 1) // Edit
  15745. {
  15746. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  15747. }
  15748. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  15749. #endregion
  15750. #endregion
  15751. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  15752. if (_view.Code != 200)
  15753. {
  15754. return Ok(_view);
  15755. }
  15756. #region 成本无酒店价格数据进入超支
  15757. _sqlSugar.BeginTran();
  15758. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  15759. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  15760. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  15761. for (int i = 0; i < groupCost.Count; i++)
  15762. {
  15763. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  15764. {
  15765. groupCost[i].Date = groupCost[i - 1].Date;
  15766. }
  15767. }
  15768. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  15769. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  15770. List<Fin_GroupExtraCostDto_OP>();
  15771. if (start_Bool && end_Bool)
  15772. {
  15773. while (start_Time < end_Time)
  15774. {
  15775. foreach (var item in groupCost_Grp)
  15776. {
  15777. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  15778. {
  15779. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  15780. {
  15781. extraCostList.Add(new
  15782. Fin_GroupExtraCostDto_OP
  15783. {
  15784. Area = _dto.AreaId,
  15785. coefficient = 1.5M,
  15786. createUser = _dto.UserId,
  15787. currency = _dto.CardPriceCurrency,
  15788. diId = _dto.DiId,
  15789. ManagerConfirm = 0,
  15790. SupervisorConfirm = 0,
  15791. SYsupervisorConfirm = 0,
  15792. editType = 1,
  15793. PortType = 1,
  15794. price = _dto.CardPrice,
  15795. PriceCount = 1,
  15796. priceType = 1027,
  15797. priceDetailType = 1044,
  15798. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  15799. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  15800. });
  15801. }
  15802. }
  15803. }
  15804. start_Time = start_Time.AddDays(1);
  15805. }
  15806. }
  15807. if (extraCostList.Any())
  15808. {
  15809. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  15810. }
  15811. _sqlSugar.CommitTran();
  15812. #endregion
  15813. #region 应用推送
  15814. try
  15815. {
  15816. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15817. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15818. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15819. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15820. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15821. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15822. var diId = _dto.DiId;
  15823. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15824. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15825. #region 操作记录
  15826. var opInfo = new Crm_TableOperationRecord()
  15827. {
  15828. TableName = "Grp_HotelReservations",
  15829. PortType = _dto.PortType,
  15830. DataId = hotelId,
  15831. CreateUserId = _dto.UserId
  15832. };
  15833. //var opStatus = OperationEnum.NoOperation;
  15834. if (_dto.Id < 1) //添加操作
  15835. {
  15836. opInfo.OperationItem = OperationEnum.Add;
  15837. }
  15838. else if (_dto.Id > 0)
  15839. {
  15840. opInfo.OperationItem = OperationEnum.Edit;
  15841. }
  15842. string opRemark = string.Empty;
  15843. if (ccpInfo != null)
  15844. {
  15845. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  15846. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  15847. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  15848. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  15849. }
  15850. opInfo.Remark = opRemark;
  15851. await _tableorRep.AddAsync(opInfo);
  15852. #endregion
  15853. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  15854. //2024-10-21 新增LZ UID
  15855. var userIds = new List<int>() { 21 };
  15856. string title = $"费用审核";
  15857. string content = "";
  15858. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15859. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15860. try
  15861. {
  15862. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15863. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  15864. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  15865. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  15866. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  15867. }
  15868. catch (Exception ex)
  15869. {
  15870. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  15871. }
  15872. }
  15873. catch (Exception ex)
  15874. {
  15875. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  15876. }
  15877. try
  15878. {
  15879. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15880. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15881. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15882. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15883. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15884. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15885. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15886. //自动审核
  15887. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  15888. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  15889. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  15890. //2024-10-21 新增LZ UID
  15891. var userIds = new List<int>() { 21 };
  15892. string title = $"系统通知";
  15893. var diId = _dto.DiId;
  15894. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15895. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15896. string content = "";
  15897. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15898. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15899. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15900. }
  15901. catch (Exception ex)
  15902. {
  15903. }
  15904. #endregion
  15905. return Ok(_view);
  15906. }
  15907. /// <summary>
  15908. /// 酒店自动审核测试
  15909. /// Add Or Edit
  15910. /// </summary>
  15911. /// <param name="diid"></param>
  15912. /// <param name="dataId"></param>
  15913. /// <returns></returns>
  15914. [HttpPost]
  15915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15916. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  15917. {
  15918. #region 应用推送
  15919. try
  15920. {
  15921. //自动审核
  15922. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  15923. }
  15924. catch (Exception ex)
  15925. {
  15926. return Ok(JsonView(false, "操作失败"));
  15927. }
  15928. #endregion
  15929. return Ok(JsonView(false, "操作成功"));
  15930. }
  15931. /// <summary>
  15932. /// 酒店预订
  15933. /// Del
  15934. /// </summary>
  15935. /// <param name="_dto"></param>
  15936. /// <returns></returns>
  15937. [HttpPost]
  15938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15939. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  15940. {
  15941. #region 参数验证
  15942. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15943. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15944. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15945. #region 团组操作权限验证 76 酒店预定模块
  15946. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15947. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15948. #endregion
  15949. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15950. #region 页面操作权限验证
  15951. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15952. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  15953. #endregion
  15954. #endregion
  15955. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15956. #region 操作记录
  15957. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15958. {
  15959. TableName = "Grp_HotelReservations",
  15960. PortType = _dto.PortType,
  15961. OperationItem = OperationEnum.Del,
  15962. DataId = _dto.Id,
  15963. CreateUserId = _dto.UserId
  15964. });
  15965. #endregion
  15966. return Ok(data);
  15967. }
  15968. /// <summary>
  15969. /// 酒店预订
  15970. /// 生成VOUCHER
  15971. /// 2024.05.06 之前版本
  15972. /// </summary>
  15973. /// <param name="_dto"></param>
  15974. /// <returns></returns>
  15975. [HttpPost]
  15976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15977. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15978. {
  15979. try
  15980. {
  15981. #region 参数验证
  15982. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15983. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15984. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15985. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15986. #region 团组操作权限验证 76 酒店预定模块
  15987. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15988. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15989. #endregion
  15990. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15991. #region 页面操作权限验证
  15992. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15993. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15994. #endregion
  15995. #endregion
  15996. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15997. //判断数据是否完整
  15998. if (hr != null)
  15999. {
  16000. if (!string.IsNullOrEmpty(hr.DetermineNo))
  16001. {
  16002. string strFileName = "HotelStatement/";
  16003. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16004. if (dele != null)
  16005. strFileName += dele.TourCode;
  16006. //载入模板
  16007. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  16008. Document doc = new Document(sss);
  16009. DocumentBuilder builder = new DocumentBuilder(doc);
  16010. #region 替换Word模板书签内容
  16011. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  16012. //入住卷预定号码
  16013. if (doc.Range.Bookmarks["VNO"] != null)
  16014. {
  16015. Bookmark mark = doc.Range.Bookmarks["VNO"];
  16016. mark.Text = hr.CheckNumber;
  16017. }
  16018. //酒店时间
  16019. if (doc.Range.Bookmarks["Date"] != null)
  16020. {
  16021. Bookmark mark = doc.Range.Bookmarks["Date"];
  16022. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16023. }
  16024. //团号
  16025. if (doc.Range.Bookmarks["TNo"] != null)
  16026. {
  16027. Bookmark mark = doc.Range.Bookmarks["TNo"];
  16028. mark.Text = dele.TourCode;
  16029. }
  16030. //预定号码
  16031. if (doc.Range.Bookmarks["BookingId"] != null)
  16032. {
  16033. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  16034. mark.Text = hr.ReservationsNo;
  16035. }
  16036. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  16037. {
  16038. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  16039. mark.Text = hr.DetermineNo;
  16040. }
  16041. //酒店城市
  16042. if (doc.Range.Bookmarks["City"] != null)
  16043. {
  16044. Bookmark mark = doc.Range.Bookmarks["City"];
  16045. mark.Text = hr.City;
  16046. }
  16047. //酒店名称
  16048. if (doc.Range.Bookmarks["HName"] != null)
  16049. {
  16050. Bookmark mark = doc.Range.Bookmarks["HName"];
  16051. mark.Text = hr.HotelName;
  16052. }
  16053. //酒店地址
  16054. if (doc.Range.Bookmarks["Address"] != null)
  16055. {
  16056. Bookmark mark = doc.Range.Bookmarks["Address"];
  16057. mark.Text = hr.HotelAddress;
  16058. }
  16059. //酒店电话
  16060. if (doc.Range.Bookmarks["Tel"] != null)
  16061. {
  16062. Bookmark mark = doc.Range.Bookmarks["Tel"];
  16063. mark.Text = hr.HotelTel;
  16064. }
  16065. //酒店传真
  16066. if (doc.Range.Bookmarks["Fax"] != null)
  16067. {
  16068. Bookmark mark = doc.Range.Bookmarks["Fax"];
  16069. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  16070. {
  16071. mark.Text = hr.HotelFax;
  16072. }
  16073. }
  16074. //入住时间
  16075. if (doc.Range.Bookmarks["CIn"] != null)
  16076. {
  16077. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16078. Bookmark mark = doc.Range.Bookmarks["CIn"];
  16079. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  16080. }
  16081. //退房时间
  16082. if (doc.Range.Bookmarks["COut"] != null)
  16083. {
  16084. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16085. Bookmark mark = doc.Range.Bookmarks["COut"];
  16086. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16087. }
  16088. //客户名称
  16089. if (doc.Range.Bookmarks["GName"] != null)
  16090. {
  16091. string guestName = "";
  16092. string[] clients = new string[] { };
  16093. if (hr.GuestName.Contains(","))
  16094. {
  16095. clients = hr.GuestName.Split(",");
  16096. }
  16097. else
  16098. {
  16099. clients = new string[] { hr.GuestName };
  16100. }
  16101. List<int> clientIds_int = new List<int>();
  16102. if (clients.Length > 0)
  16103. {
  16104. foreach (var item in clients)
  16105. {
  16106. if (item.IsNumeric())
  16107. {
  16108. clientIds_int.Add(int.Parse(item));
  16109. }
  16110. }
  16111. }
  16112. if (clientIds_int.Count > 0)
  16113. {
  16114. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  16115. foreach (var client in _clientDatas)
  16116. {
  16117. //男
  16118. if (client.Sex == 0) guestName += $"Mr.";
  16119. //女
  16120. else if (client.Sex == 1) guestName += $"Ms.";
  16121. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  16122. {
  16123. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  16124. }
  16125. //guestName += $"{client.Pinyin},";
  16126. }
  16127. if (guestName.Length > 0)
  16128. {
  16129. guestName = guestName.Substring(0, guestName.Length - 1);
  16130. }
  16131. }
  16132. else
  16133. {
  16134. guestName = hr.GuestName;
  16135. }
  16136. Bookmark mark = doc.Range.Bookmarks["GName"];
  16137. mark.Text = guestName;
  16138. }
  16139. //房间介绍
  16140. if (doc.Range.Bookmarks["ROOM"] != null)
  16141. {
  16142. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  16143. mark.Text = hr.RoomExplanation;
  16144. }
  16145. //报价描述
  16146. if (doc.Range.Bookmarks["NOTE"] != null)
  16147. {
  16148. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  16149. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  16150. if (ss != null)
  16151. mark.Text = ss.Name;
  16152. }
  16153. //入住时间
  16154. if (doc.Range.Bookmarks["CheckIn"] != null)
  16155. {
  16156. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  16157. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  16158. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16159. }
  16160. //退房时间
  16161. if (doc.Range.Bookmarks["CheckOut"] != null)
  16162. {
  16163. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  16164. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  16165. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  16166. }
  16167. //日期
  16168. if (doc.Range.Bookmarks["DT"] != null)
  16169. {
  16170. Bookmark mark = doc.Range.Bookmarks["DT"];
  16171. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  16172. }
  16173. //名称
  16174. if (doc.Range.Bookmarks["VName"] != null)
  16175. {
  16176. Bookmark mark = doc.Range.Bookmarks["VName"];
  16177. mark.Text = hr.HotelName;
  16178. }
  16179. //号码
  16180. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  16181. {
  16182. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  16183. mark.Text = hr.CheckNumber;
  16184. }
  16185. #endregion
  16186. strFileName += "VOUCHER.doc";
  16187. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16188. doc.Save(fileDir);
  16189. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16190. return Ok(JsonView(true, "操作成功!", Url));
  16191. }
  16192. else
  16193. {
  16194. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  16195. }
  16196. }
  16197. else
  16198. {
  16199. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  16200. }
  16201. }
  16202. catch (Exception ex)
  16203. {
  16204. return Ok(JsonView(false, ex.Message));
  16205. }
  16206. }
  16207. /// <summary>
  16208. /// 酒店预订
  16209. /// 生成VOUCHER
  16210. /// 2024.05.06 之后版本
  16211. /// </summary>
  16212. /// <param name="_dto"></param>
  16213. /// <returns></returns>
  16214. [HttpPost]
  16215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16216. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  16217. {
  16218. #region 参数验证
  16219. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16220. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16221. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16222. #region 团组操作权限验证 76 酒店预定模块
  16223. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16224. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16225. #endregion
  16226. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16227. #region 页面操作权限验证
  16228. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16229. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16230. #endregion
  16231. #endregion
  16232. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  16233. //判断数据是否完整
  16234. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16235. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16236. string strFileName = "HotelStatement/";
  16237. string guestNames = ""; //格式Mr.xxx Ms.xxx
  16238. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  16239. #region 数据处理
  16240. List<int> guestIds = new List<int>();
  16241. //int index = 0;
  16242. foreach (var item in hrDtas)
  16243. {
  16244. if (item.GuestName.Contains(","))
  16245. {
  16246. string[] guestIdArr = item.GuestName.Split(',');
  16247. foreach (var guestIdStr in guestIdArr)
  16248. {
  16249. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  16250. if (guestBool)
  16251. {
  16252. guestIds.Add(guestId);
  16253. }
  16254. }
  16255. }
  16256. else guestNames += item.GuestName;
  16257. var voucherInfo = new HotelVoucherInfoView()
  16258. {
  16259. HotelName = item.HotelName,
  16260. CheckInDate = item.CheckInDate,
  16261. CheckOutDate = item.CheckOutDate,
  16262. ConfirmationNumber = item.DetermineNo.Trim(),
  16263. RoomType = item.RoomExplanation
  16264. };
  16265. vouchers.Add(voucherInfo);
  16266. }
  16267. if (guestIds.Count > 0)
  16268. {
  16269. guestIds = guestIds.Distinct().ToList();
  16270. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  16271. if (guestDatas.Count > 0)
  16272. {
  16273. guestNames = "";
  16274. foreach (var guest in guestDatas)
  16275. {
  16276. string guestName = "";
  16277. if (guest.Sex == 0) guestName += @"MR.";
  16278. else if (guest.Sex == 1) guestName += @"MS.";
  16279. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16280. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16281. guestNames += @$"{guestName.Trim()}、";
  16282. }
  16283. if (guestNames.Length > 0)
  16284. {
  16285. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16286. }
  16287. }
  16288. }
  16289. #endregion
  16290. //载入模板
  16291. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  16292. Document doc = new Document(sss);
  16293. DocumentBuilder builder = new DocumentBuilder(doc);
  16294. if (doc.Range.Bookmarks["GuestName"] != null)
  16295. {
  16296. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  16297. mark.Text = guestNames;
  16298. }
  16299. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16300. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  16301. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  16302. for (int i = 1; i <= vouchers.Count; i++)
  16303. {
  16304. HotelVoucherInfoView hviv = vouchers[i - 1];
  16305. builder.MoveToCell(0, i, 0, 0);
  16306. builder.Write(hviv.HotelName);
  16307. builder.MoveToCell(0, i, 1, 0);
  16308. builder.Write(hviv.CheckInDate);
  16309. builder.MoveToCell(0, i, 2, 0);
  16310. builder.Write(hviv.CheckOutDate);
  16311. builder.MoveToCell(0, i, 3, 0);
  16312. builder.Write(hviv.RoomType);
  16313. builder.MoveToCell(0, i, 4, 0);
  16314. builder.Write(hviv.ConfirmationNumber);
  16315. }
  16316. //删除多余行
  16317. int currRowIndex = vouchers.Count + 1;
  16318. int delRows = 21 - currRowIndex;
  16319. if (delRows > 0)
  16320. {
  16321. for (int i = 0; i < delRows; i++)
  16322. {
  16323. table.Rows.RemoveAt(currRowIndex);
  16324. //cultivateRowIndex++;
  16325. }
  16326. }
  16327. strFileName += "VOUCHER.docx";
  16328. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16329. doc.Save(fileDir);
  16330. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16331. return Ok(JsonView(true, "操作成功!", Url));
  16332. }
  16333. /// <summary>
  16334. /// 酒店预订
  16335. /// 生成VOUCHER 批量生成
  16336. /// New
  16337. /// </summary>
  16338. /// <param name="_dto"></param>
  16339. /// <returns></returns>
  16340. [HttpPost]
  16341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16342. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  16343. {
  16344. #region 参数验证
  16345. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16346. if (_dto.PageId < 1) _dto.PageId = 28;
  16347. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16348. #region 团组操作权限验证 76 酒店预定模块
  16349. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16350. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16351. #endregion
  16352. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16353. #region 页面操作权限验证
  16354. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16355. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16356. #endregion
  16357. #endregion
  16358. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  16359. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  16360. .OrderBy(x => x.CheckInDate)
  16361. .ToListAsync();
  16362. //判断数据是否完整
  16363. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  16364. string strFileName = "HotelStatement/";
  16365. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  16366. if (dele != null)
  16367. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  16368. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  16369. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  16370. .Where(it => it.IsDel == 0)
  16371. .ToListAsync();
  16372. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  16373. for (int i = 0; i < hrDtas.Count; i++)
  16374. {
  16375. string guestNames = string.Empty;
  16376. List<int> guestIds = new List<int>();
  16377. var item = hrDtas[i];
  16378. //处理客户姓名
  16379. if (item.GuestName.Contains(","))
  16380. {
  16381. string[] guestIdArr = item.GuestName.Split(',');
  16382. foreach (var guestIdStr in guestIdArr)
  16383. if (int.TryParse(guestIdStr, out int guestId))
  16384. guestIds.Add(guestId);
  16385. }
  16386. else
  16387. {
  16388. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  16389. if (guestIdBool)
  16390. {
  16391. guestIds.Add(guestId);
  16392. }
  16393. //NaN
  16394. if (item.GuestName.Contains("NaN"))
  16395. {
  16396. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  16397. }
  16398. }
  16399. if (guestIds.Count > 0)
  16400. {
  16401. guestIds = guestIds.Distinct().ToList();
  16402. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  16403. if (guestDatas1.Count > 0)
  16404. {
  16405. guestNames = "";
  16406. foreach (var guest in guestDatas1)
  16407. {
  16408. string guestName = "";
  16409. if (guest.Sex == 0) guestName += @"MR.";
  16410. else if (guest.Sex == 1) guestName += @"MS.";
  16411. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  16412. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  16413. guestNames += @$"{guestName.Trim()}、";
  16414. }
  16415. if (guestNames.Length > 0)
  16416. {
  16417. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  16418. }
  16419. }
  16420. }
  16421. //if (!string.IsNullOrEmpty(guestNames))
  16422. //{
  16423. hrDtas[i].GuestName = guestNames;
  16424. //}
  16425. }
  16426. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  16427. Document doc = new Document();
  16428. DocumentBuilder builder = new DocumentBuilder(doc);
  16429. try
  16430. {
  16431. builder.MoveToDocumentStart();
  16432. foreach (var item in hrDtas)
  16433. {
  16434. //标题
  16435. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16436. builder.ParagraphFormat.LineSpacing = 1;
  16437. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16438. builder.ParagraphFormat.Style.Font.Size = 9;
  16439. builder.ParagraphFormat.Style.Font.Bold = true;
  16440. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16441. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  16442. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  16443. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16444. builder.ParagraphFormat.LineSpacing = 1;
  16445. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16446. builder.ParagraphFormat.Style.Font.Size = 9;
  16447. builder.ParagraphFormat.Style.Font.Bold = true;
  16448. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  16449. builder.StartTable();
  16450. // 设置边框颜色
  16451. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  16452. //设置边框样式
  16453. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  16454. //表格
  16455. #region 第一行
  16456. builder.InsertCell();
  16457. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16458. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16459. //builder.CellFormat.AllowAutoFit = false;
  16460. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16461. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16462. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16463. builder.CellFormat.WrapText = true; //自动换行
  16464. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16465. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  16466. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16467. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16468. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16469. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16470. builder.Write("TOUR NO:");
  16471. builder.InsertCell();
  16472. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16473. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16474. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16475. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16476. builder.ParagraphFormat.Style.Font.Bold = false;
  16477. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16478. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16479. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16480. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16481. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16482. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16483. builder.Write($"{dele?.TourCode ?? "-"}");
  16484. builder.InsertCell();
  16485. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16486. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16487. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16488. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16489. builder.ParagraphFormat.Style.Font.Bold = false;
  16490. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16491. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16492. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16493. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16494. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16495. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16496. builder.Write($"CITY:");
  16497. builder.InsertCell();
  16498. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16499. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16500. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16501. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16502. builder.ParagraphFormat.Style.Font.Bold = false;
  16503. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16504. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16505. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16506. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16507. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16508. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16509. builder.Write($"{item.City}");
  16510. builder.EndRow();
  16511. #endregion
  16512. #region 第二行
  16513. builder.InsertCell();
  16514. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16515. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16516. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16517. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16518. builder.ParagraphFormat.Style.Font.Bold = false;
  16519. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16520. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16521. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16522. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16523. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16524. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16525. builder.Write("CONFIRMATION NO:");
  16526. builder.InsertCell();
  16527. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16528. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16529. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16530. builder.ParagraphFormat.Style.Font.Bold = false;
  16531. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16532. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16533. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16534. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16535. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16536. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16537. builder.CellFormat.VerticalMerge = CellMerge.None;
  16538. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16539. builder.Write($"{item.DetermineNo}");
  16540. builder.InsertCell();
  16541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16542. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16543. builder.InsertCell();
  16544. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16545. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16546. builder.EndRow();
  16547. #endregion
  16548. #region 第三行
  16549. builder.InsertCell();
  16550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16551. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16552. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16553. builder.ParagraphFormat.Style.Font.Bold = false;
  16554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16557. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16558. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16559. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16560. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16561. builder.Write($"HOTEL NAME:");
  16562. builder.InsertCell();
  16563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16564. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16565. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16566. builder.ParagraphFormat.Style.Font.Bold = false;
  16567. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16568. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16569. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16570. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16571. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16572. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16573. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16574. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16575. builder.Write($"{item.HotelName}");
  16576. builder.InsertCell();
  16577. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16578. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16579. builder.InsertCell();
  16580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16581. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16582. builder.EndRow();
  16583. #endregion
  16584. #region 第四行
  16585. builder.InsertCell();
  16586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16587. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16588. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16589. builder.ParagraphFormat.Style.Font.Bold = false;
  16590. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16591. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16593. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16594. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16595. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16596. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16597. builder.Write($"HOTEL ADDRESS:");
  16598. builder.InsertCell();
  16599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16600. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16601. builder.ParagraphFormat.Style.Font.Size = 8;
  16602. builder.ParagraphFormat.Style.Font.Bold = false;
  16603. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16604. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16605. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16606. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16607. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16608. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16609. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16610. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16611. builder.Write($"{item.HotelAddress}");
  16612. builder.InsertCell();
  16613. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16614. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16615. builder.InsertCell();
  16616. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16617. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16618. builder.EndRow();
  16619. #endregion
  16620. #region 第五行
  16621. builder.InsertCell();
  16622. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16623. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16624. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16625. builder.ParagraphFormat.Style.Font.Bold = false;
  16626. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16627. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16628. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16629. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16630. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16631. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16632. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16633. builder.Write("TEL:");
  16634. builder.InsertCell();
  16635. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16636. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16637. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16638. builder.ParagraphFormat.Style.Font.Bold = false;
  16639. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16640. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16641. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16642. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16643. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16644. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16645. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16646. builder.Write($"{item.HotelTel}");
  16647. builder.InsertCell();
  16648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16649. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16650. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16651. builder.ParagraphFormat.Style.Font.Bold = false;
  16652. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16653. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16654. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16655. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16656. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16657. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16658. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16659. builder.Write($"FAX:");
  16660. builder.InsertCell();
  16661. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16662. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16663. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16664. builder.ParagraphFormat.Style.Font.Bold = false;
  16665. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16666. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16667. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16668. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16669. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16670. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16671. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16672. builder.Write($"{item.HotelFax}");
  16673. builder.EndRow();
  16674. #endregion
  16675. #region 第六行
  16676. builder.InsertCell();
  16677. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16678. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16679. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16680. builder.ParagraphFormat.Style.Font.Bold = false;
  16681. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16682. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16683. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16684. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16685. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16686. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16687. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16688. builder.Write("CHECK IN:");
  16689. builder.InsertCell();
  16690. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16691. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16692. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16693. builder.ParagraphFormat.Style.Font.Bold = false;
  16694. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16695. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16696. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16697. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16698. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16699. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16700. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16701. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  16702. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16703. builder.Write($"{checkInStr}");
  16704. builder.InsertCell();
  16705. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16706. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16707. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16708. builder.ParagraphFormat.Style.Font.Bold = false;
  16709. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16710. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16712. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16713. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16714. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16715. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16716. builder.Write($"CHECK OUT:");
  16717. builder.InsertCell();
  16718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16719. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16720. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16721. builder.ParagraphFormat.Style.Font.Bold = false;
  16722. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16723. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16724. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16725. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16726. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16727. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16728. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16729. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  16730. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  16731. builder.Write($"{checkOutStr}");
  16732. builder.EndRow();
  16733. #endregion
  16734. #region 第七行
  16735. builder.InsertCell();
  16736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16738. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16739. builder.ParagraphFormat.Style.Font.Bold = false;
  16740. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16741. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16742. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16743. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16744. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16745. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16746. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16747. builder.Write($"GUEST NAME:");
  16748. builder.InsertCell();
  16749. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16751. builder.ParagraphFormat.Style.Font.Size = 8;
  16752. builder.ParagraphFormat.Style.Font.Bold = false;
  16753. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16754. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16755. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16756. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16757. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16758. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16759. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16760. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16761. builder.Write($"{item.GuestName}");
  16762. builder.InsertCell();
  16763. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16764. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16765. builder.InsertCell();
  16766. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16767. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16768. builder.EndRow();
  16769. #endregion
  16770. #region 第八行
  16771. builder.InsertCell();
  16772. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16773. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16774. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16775. builder.ParagraphFormat.Style.Font.Bold = false;
  16776. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16777. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16778. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16779. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16780. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16781. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16782. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16783. builder.Write($"ROOM TYPE:");
  16784. builder.InsertCell();
  16785. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16786. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16787. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16788. builder.ParagraphFormat.Style.Font.Bold = false;
  16789. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16790. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16791. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16792. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16793. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16794. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16795. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16796. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16797. builder.Write($"{item.RoomExplanation}");
  16798. builder.InsertCell();
  16799. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16800. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16801. builder.InsertCell();
  16802. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16803. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16804. builder.EndRow();
  16805. #endregion
  16806. #region 第九行
  16807. builder.InsertCell();
  16808. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16809. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16810. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16811. builder.ParagraphFormat.Style.Font.Bold = false;
  16812. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16813. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16814. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16815. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16816. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16817. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16818. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16819. builder.Write($"NOTE:");
  16820. builder.InsertCell();
  16821. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16822. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16823. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16824. builder.ParagraphFormat.Style.Font.Bold = false;
  16825. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16826. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16827. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16828. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16829. 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.");
  16830. builder.InsertCell();
  16831. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16832. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16833. builder.InsertCell();
  16834. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16835. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16836. builder.EndRow();
  16837. #endregion
  16838. builder.EndTable();
  16839. //换行
  16840. builder.Writeln("");
  16841. builder.Writeln("");
  16842. }
  16843. #region 获取文档中的所有表格 设置文字自适应
  16844. // 获取文档中的所有表格。
  16845. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  16846. {
  16847. // 遍历表格中的所有行。
  16848. foreach (Aspose.Words.Tables.Row row in table.Rows)
  16849. {
  16850. foreach (Cell cell in row.Cells)
  16851. {
  16852. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  16853. cellFormat.Width = 0;
  16854. }
  16855. }
  16856. }
  16857. #endregion
  16858. #region 设置页眉
  16859. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  16860. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  16861. if (System.IO.File.Exists(voucherHeaderPath))
  16862. {
  16863. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  16864. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  16865. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  16866. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  16867. // 调整图片位置
  16868. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  16869. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  16870. shape.Top = 50; // 将图片距离页眉上边缘的距离
  16871. shape.Left = 0; // 将图片距离页面左边缘的距离
  16872. shape.Width = 81; // 设置图片宽度
  16873. shape.Height = 36; // 设置图片高度
  16874. }
  16875. //靠右
  16876. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16877. //// 设置页脚上下边距
  16878. //builder.PageSetup.HeaderDistance = 42;
  16879. // 添加页眉线
  16880. Aspose.Words.Border borderHeader = null;
  16881. try
  16882. {
  16883. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  16884. }
  16885. catch (Exception e)
  16886. {
  16887. // TODO Auto-generated catch block
  16888. //e.printStackTrace();
  16889. }
  16890. borderHeader.Shadow = true;
  16891. borderHeader.DistanceFromText = 2;
  16892. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  16893. #endregion
  16894. }
  16895. catch (Exception ex)
  16896. {
  16897. }
  16898. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16899. doc.Save(fileDir);
  16900. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16901. return Ok(JsonView(true, "操作成功!", Url));
  16902. }
  16903. /// <summary>
  16904. /// 酒店预订
  16905. /// 生成 预定成本 Excel
  16906. /// </summary>
  16907. /// <param name="_dto"></param>
  16908. /// <returns></returns>
  16909. [HttpPost]
  16910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16911. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  16912. {
  16913. #region 参数验证
  16914. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  16915. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  16916. if (!vadalitorRes.IsValid)
  16917. {
  16918. var errors = new StringBuilder();
  16919. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  16920. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  16921. }
  16922. #region 团组操作权限验证 76 酒店预定模块
  16923. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16924. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16925. #endregion
  16926. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16927. #region 页面操作权限验证
  16928. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16929. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16930. #endregion
  16931. #endregion
  16932. decimal _rate = 1.00M;
  16933. string _currency = string.Empty;
  16934. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  16935. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16936. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  16937. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16938. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  16939. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  16940. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  16941. if (_GroupCostParameter == null)
  16942. {
  16943. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  16944. bool isIntType = int.TryParse(_currency, out int currId);
  16945. if (isIntType)
  16946. {
  16947. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16948. }
  16949. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16950. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16951. if (currInfo == null)
  16952. {
  16953. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16954. }
  16955. else _rate = currInfo.Rate;
  16956. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16957. {
  16958. _rate = _GroupCostParameter.Rate;
  16959. }
  16960. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16961. //string strFileName = "HotelStatement/";
  16962. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16963. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16964. var rateDatas = new List<dynamic>();
  16965. #region 数据处理
  16966. foreach (var item in hrDtas)
  16967. {
  16968. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16969. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16970. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16971. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16972. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16973. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16974. {
  16975. continue;
  16976. }
  16977. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16978. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16979. string singleRoomFeeStr = string.Empty,
  16980. doubleRoomFeeStr = string.Empty,
  16981. suiteRoomFeeStr = string.Empty,
  16982. otherRoomFeeStr = string.Empty,
  16983. payMoneyStr = string.Empty,
  16984. cardPriceStr = string.Empty;
  16985. if (roomCurr.Equals("CNY"))
  16986. {
  16987. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16988. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16989. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16990. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16991. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16992. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16993. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16994. }
  16995. else
  16996. {
  16997. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16998. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16999. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17000. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17001. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17002. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17003. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17004. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17005. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17006. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  17007. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  17008. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  17009. if (ccpPaymentCurrency.Equals("CNY"))
  17010. {
  17011. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  17012. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17013. }
  17014. else
  17015. {
  17016. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  17017. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  17018. }
  17019. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  17020. if (hotelcardPriceCurrency.Equals("CNY"))
  17021. {
  17022. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  17023. }
  17024. else
  17025. {
  17026. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  17027. }
  17028. }
  17029. string breakfastPriceStr = string.Empty,
  17030. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17031. governmentRentStr = string.Empty,
  17032. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17033. cityTaxStr = string.Empty,
  17034. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17035. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  17036. if (!string.IsNullOrEmpty(breakfastCurrency1))
  17037. {
  17038. if (breakfastCurrency1.Equals("CNY"))
  17039. {
  17040. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17041. }
  17042. else
  17043. {
  17044. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  17045. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  17046. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  17047. }
  17048. }
  17049. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  17050. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  17051. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  17052. {
  17053. if (governmentRentCurrency.Equals("CNY"))
  17054. {
  17055. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17056. }
  17057. else
  17058. {
  17059. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  17060. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  17061. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  17062. }
  17063. }
  17064. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  17065. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  17066. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  17067. {
  17068. if (cityTaxStrCurrency1.Equals("CNY"))
  17069. {
  17070. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17071. }
  17072. else
  17073. {
  17074. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  17075. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  17076. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  17077. }
  17078. }
  17079. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  17080. int payDId = roomInfo?.PayDId ?? 0;
  17081. pcfds.Add(new HotelReservations_PCFD_View()
  17082. {
  17083. City = item.City,
  17084. HotelName = item.HotelName,
  17085. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17086. // SingleRoomCount = item.SingleRoomCount,
  17087. SingleRoomPrice = singleRoomFeeStr,
  17088. // DoubleRoomCount = item.DoubleRoomCount,
  17089. DoubleRoomPrice = doubleRoomFeeStr,
  17090. //SuiteRoomCount = item.SuiteRoomCount,
  17091. SuiteRoomPrice = suiteRoomFeeStr,
  17092. OtherRoomPrice = otherRoomFeeStr,
  17093. //OtherRoomCount = item.OtherRoomCount,
  17094. BreakfastPrice = breakfastPriceStr,
  17095. GovernmentRent = governmentRentStr,
  17096. CityTax = cityTaxStr,
  17097. RoomExplanation = item.RoomExplanation,
  17098. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17099. PayTime = roomInfo?.ConsumptionDate,
  17100. BankNo = roomInfo?.BankNo,
  17101. PayMoney = payMoneyStr,
  17102. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17103. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17104. CardPrice = cardPriceStr,
  17105. Remark = ccpInfo.Remark
  17106. });
  17107. }
  17108. #endregion
  17109. //载入模板
  17110. WorkbookDesigner designer = new WorkbookDesigner();
  17111. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17112. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17113. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17114. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17115. var rateDatas1 = rateDatas.Distinct();
  17116. var rateStr = string.Empty;
  17117. foreach (var item in rateDatas1)
  17118. {
  17119. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  17120. }
  17121. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  17122. designer.SetDataSource("Opertor", userInfo.CnName);
  17123. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17124. dt.TableName = "ViewMyHotelReservations";
  17125. designer.SetDataSource(dt);
  17126. designer.Process();
  17127. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17128. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17129. designer.Workbook.Save(serverPath);
  17130. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17131. #region 删除指定行
  17132. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17133. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17134. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17135. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17136. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17137. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17138. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17139. cssIndex = dt.Columns["CityTax"].Ordinal,
  17140. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17141. remarkIndex = dt.Columns["Remark"].Ordinal;
  17142. //删除指定列
  17143. foreach (DataRow item in dt.Rows)
  17144. {
  17145. string singleStr = item["SingleRoomPrice"].ToString();
  17146. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17147. if (containsDigitButNotZero1) singleDel = false;
  17148. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17149. string doubleStr = item["DoubleRoomPrice"].ToString();
  17150. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17151. if (containsDigitButNotZero2) doubleDel = false;
  17152. string suiteStr = item["SuiteRoomPrice"].ToString();
  17153. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17154. if (containsDigitButNotZero3) suiteDel = false;
  17155. string otherStr = item["OtherRoomPrice"].ToString();
  17156. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17157. if (containsDigitButNotZero4) otherDel = false;
  17158. string zcStr = item["BreakfastPrice"].ToString();
  17159. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17160. if (containsDigitButNotZero5) zcDel = false;
  17161. string dsStr = item["GovernmentRent"].ToString();
  17162. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17163. if (containsDigitButNotZero6) dsDel = false;
  17164. string cssStr = item["CityTax"].ToString();
  17165. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17166. if (containsDigitButNotZero7) cssDel = false;
  17167. string cpStr = item["ConsumptionPatterns"].ToString();
  17168. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17169. string remarkStr = item["Remark"].ToString();
  17170. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17171. }
  17172. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17173. DeleteColumn(serverPath, cpIndex, cpDel);
  17174. DeleteColumn(serverPath, dsIndex, dsDel);
  17175. DeleteColumn(serverPath, cssIndex, cssDel);
  17176. DeleteColumn(serverPath, zcIndex, zcDel);
  17177. DeleteColumn(serverPath, otherIndex, otherDel);
  17178. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17179. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17180. DeleteColumn(serverPath, singleIndex, singleDel);
  17181. #endregion
  17182. //只保留第一个表格
  17183. DeleteSheet(serverPath);
  17184. return Ok(JsonView(true, "操作成功", url = rst));
  17185. }
  17186. else
  17187. {
  17188. _currency = _GroupCostParameter.Currency;
  17189. bool isIntType = int.TryParse(_currency, out int currId);
  17190. if (isIntType)
  17191. {
  17192. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  17193. }
  17194. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  17195. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  17196. if (currInfo == null)
  17197. {
  17198. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  17199. }
  17200. if (!_currency.ToUpper().Equals("CNY"))
  17201. {
  17202. _rate = _GroupCostParameter.Rate;
  17203. }
  17204. _rate = currInfo.Rate;
  17205. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17206. //string strFileName = "HotelStatement/";
  17207. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  17208. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  17209. #region 数据处理
  17210. foreach (var item in hrDtas)
  17211. {
  17212. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  17213. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  17214. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  17215. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  17216. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  17217. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  17218. string singleRoomFeeStr = string.Empty,
  17219. doubleRoomFeeStr = string.Empty,
  17220. suiteRoomFeeStr = string.Empty,
  17221. otherRoomFeeStr = string.Empty,
  17222. payMoneyStr = string.Empty,
  17223. cardPriceStr = string.Empty;
  17224. if (roomCurr.Equals(_currency))
  17225. {
  17226. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  17227. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  17228. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  17229. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  17230. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  17231. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  17232. }
  17233. else
  17234. {
  17235. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  17236. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  17237. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  17238. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  17239. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  17240. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  17241. }
  17242. string breakfastPriceStr = string.Empty,
  17243. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  17244. governmentRentStr = string.Empty,
  17245. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  17246. cityTaxStrStr = string.Empty,
  17247. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  17248. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  17249. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  17250. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  17251. int payDId = roomInfo?.PayDId ?? 0;
  17252. pcfds.Add(new HotelReservations_PCFD_View()
  17253. {
  17254. City = item.City,
  17255. HotelName = item.HotelName,
  17256. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  17257. // SingleRoomCount = item.SingleRoomCount,
  17258. SingleRoomPrice = singleRoomFeeStr,
  17259. // DoubleRoomCount = item.DoubleRoomCount,
  17260. DoubleRoomPrice = doubleRoomFeeStr,
  17261. //SuiteRoomCount = item.SuiteRoomCount,
  17262. SuiteRoomPrice = suiteRoomFeeStr,
  17263. OtherRoomPrice = otherRoomFeeStr,
  17264. //OtherRoomCount = item.OtherRoomCount,
  17265. BreakfastPrice = breakfastPriceStr,
  17266. GovernmentRent = governmentRentStr,
  17267. CityTax = cityTaxStrStr,
  17268. RoomExplanation = item.RoomExplanation,
  17269. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  17270. PayTime = roomInfo?.ConsumptionDate,
  17271. BankNo = roomInfo?.BankNo,
  17272. PayMoney = payMoneyStr,
  17273. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  17274. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  17275. CardPrice = cardPriceStr,
  17276. Remark = ccpInfo.Remark
  17277. });
  17278. }
  17279. #endregion
  17280. //载入模板
  17281. WorkbookDesigner designer = new WorkbookDesigner();
  17282. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  17283. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  17284. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  17285. designer.SetDataSource("TourNo", groupInfo.TourCode);
  17286. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  17287. designer.SetDataSource("Opertor", userInfo.CnName);
  17288. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  17289. dt.TableName = "ViewMyHotelReservations";
  17290. designer.SetDataSource(dt);
  17291. designer.Process();
  17292. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  17293. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  17294. designer.Workbook.Save(serverPath);
  17295. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  17296. #region 删除指定行
  17297. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  17298. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  17299. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  17300. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  17301. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  17302. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  17303. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  17304. cssIndex = dt.Columns["CityTax"].Ordinal,
  17305. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  17306. remarkIndex = dt.Columns["Remark"].Ordinal;
  17307. //删除指定列
  17308. foreach (DataRow item in dt.Rows)
  17309. {
  17310. string singleStr = item["SingleRoomPrice"].ToString();
  17311. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  17312. if (containsDigitButNotZero1) singleDel = false;
  17313. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  17314. string doubleStr = item["DoubleRoomPrice"].ToString();
  17315. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17316. if (containsDigitButNotZero2) doubleDel = false;
  17317. string suiteStr = item["SuiteRoomPrice"].ToString();
  17318. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  17319. if (containsDigitButNotZero3) suiteDel = false;
  17320. string otherStr = item["OtherRoomPrice"].ToString();
  17321. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  17322. if (containsDigitButNotZero4) otherDel = false;
  17323. string zcStr = item["BreakfastPrice"].ToString();
  17324. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  17325. if (containsDigitButNotZero5) zcDel = false;
  17326. string dsStr = item["GovernmentRent"].ToString();
  17327. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  17328. if (containsDigitButNotZero6) dsDel = false;
  17329. string cssStr = item["CityTax"].ToString();
  17330. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  17331. if (containsDigitButNotZero7) cssDel = false;
  17332. string cpStr = item["ConsumptionPatterns"].ToString();
  17333. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  17334. string remarkStr = item["Remark"].ToString();
  17335. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  17336. }
  17337. DeleteColumn(serverPath, remarkIndex, remarkDel);
  17338. DeleteColumn(serverPath, cpIndex, cpDel);
  17339. DeleteColumn(serverPath, dsIndex, dsDel);
  17340. DeleteColumn(serverPath, cssIndex, cssDel);
  17341. DeleteColumn(serverPath, zcIndex, zcDel);
  17342. DeleteColumn(serverPath, otherIndex, otherDel);
  17343. DeleteColumn(serverPath, suiteIndex, suiteDel);
  17344. DeleteColumn(serverPath, doubleIndex, doubleDel);
  17345. DeleteColumn(serverPath, singleIndex, singleDel);
  17346. #endregion
  17347. //只保留第一个表格
  17348. DeleteSheet(serverPath);
  17349. return Ok(JsonView(true, "操作成功", url = rst));
  17350. }
  17351. //return Ok(JsonView(false));
  17352. }
  17353. /// <summary>
  17354. /// 删除指定列
  17355. /// </summary>
  17356. /// <param name="file"></param>
  17357. /// <param name="columnIndex"></param>
  17358. /// <param name="isDel"></param>
  17359. private void DeleteColumn(string file, int columnIndex, bool isDel)
  17360. {
  17361. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17362. //wb.Save(file);
  17363. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  17364. if (sheet1 != null)
  17365. {
  17366. if (isDel)
  17367. {
  17368. Cells cells = sheet1.Cells;
  17369. cells.DeleteColumn(columnIndex);
  17370. }
  17371. }
  17372. wb.Save(file);
  17373. }
  17374. /// <summary>
  17375. /// 删除sheet
  17376. /// </summary>
  17377. /// <param name="file"></param>
  17378. /// <param name="sheetName"></param>
  17379. private void DeleteSheet(string file, string sheetName = "")
  17380. {
  17381. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  17382. //wb.Save(file);
  17383. List<string> sheets = new List<string>();
  17384. foreach (var item in wb.Worksheets)
  17385. {
  17386. sheets.Add(item.Name);
  17387. }
  17388. if (sheets.Count > 0)
  17389. {
  17390. sheets.RemoveAt(0);//不删除第一个sheet
  17391. foreach (var item in sheets)
  17392. {
  17393. wb.Worksheets.RemoveAt(item);
  17394. }
  17395. }
  17396. wb.Save(file);
  17397. }
  17398. /// <summary>
  17399. /// 酒店预订
  17400. /// 确认单
  17401. /// </summary>
  17402. /// <param name="_dto"></param>
  17403. /// <returns></returns>
  17404. [HttpPost]
  17405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17406. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  17407. {
  17408. try
  17409. {
  17410. #region 参数验证
  17411. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17412. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17413. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17414. #region 团组操作权限验证 76 酒店预定模块
  17415. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17416. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17417. #endregion
  17418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17419. #region 页面操作权限验证
  17420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17421. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17422. #endregion
  17423. #endregion
  17424. //团组信息
  17425. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  17426. //酒店数据
  17427. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  17428. if (listhoteldata.Count < 0)
  17429. {
  17430. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  17431. }
  17432. //利datatable存储
  17433. DataTable dt = new DataTable();
  17434. dt.Columns.Add("CheckInDate", typeof(string));
  17435. dt.Columns.Add("City", typeof(string));
  17436. dt.Columns.Add("Hotel", typeof(string));
  17437. dt.Columns.Add("Room", typeof(string));
  17438. for (int i = 0; i < listhoteldata.Count; i++)
  17439. {
  17440. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  17441. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  17442. while (dayStart < dayEnd)
  17443. {
  17444. string temp = "";
  17445. DataRow row = dt.NewRow();
  17446. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  17447. row["City"] = listhoteldata[i].City;
  17448. row["Hotel"] = listhoteldata[i].HotelName;
  17449. if (listhoteldata[i].SingleRoomCount > 0)
  17450. {
  17451. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  17452. }
  17453. if (listhoteldata[i].DoubleRoomCount > 0)
  17454. {
  17455. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  17456. }
  17457. if (listhoteldata[i].SuiteRoomCount > 0)
  17458. {
  17459. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  17460. }
  17461. if (listhoteldata[i].OtherRoomCount > 0)
  17462. {
  17463. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  17464. }
  17465. row["Room"] = temp;
  17466. dt.Rows.Add(row);
  17467. dayStart = dayStart.AddDays(1);
  17468. }
  17469. }
  17470. Dictionary<string, string> dic = new Dictionary<string, string>();
  17471. dic.Add("Dele", di.TeamName);
  17472. dic.Add("City", di.VisitCountry);
  17473. //模板路径
  17474. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  17475. //载入模板
  17476. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  17477. DocumentBuilder builder = new DocumentBuilder(doc);
  17478. foreach (var key in dic.Keys)
  17479. {
  17480. builder.MoveToBookmark(key);
  17481. builder.Write(dic[key]);
  17482. }
  17483. //获取word里所有表格
  17484. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17485. //获取所填表格的序数
  17486. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17487. var rowStart = tableOne.Rows[0]; //获取第1行
  17488. //循环赋值
  17489. for (int i = 0; i < dt.Rows.Count; i++)
  17490. {
  17491. builder.MoveToCell(0, i + 1, 0, 0);
  17492. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  17493. builder.MoveToCell(0, i + 1, 1, 0);
  17494. builder.Write(dt.Rows[i]["City"].ToString());
  17495. builder.MoveToCell(0, i + 1, 2, 0);
  17496. builder.Write(dt.Rows[i]["Hotel"].ToString());
  17497. builder.MoveToCell(0, i + 1, 3, 0);
  17498. builder.Write(dt.Rows[i]["Room"].ToString());
  17499. }
  17500. //删除多余行
  17501. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  17502. {
  17503. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  17504. }
  17505. string strFileName = di.TeamName + "酒店确认单.doc";
  17506. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  17507. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  17508. return Ok(JsonView(true, "成功", url));
  17509. }
  17510. catch (Exception ex)
  17511. {
  17512. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  17513. }
  17514. }
  17515. #endregion
  17516. #region 团组状态
  17517. /// <summary>
  17518. /// 团组状态列表 Page
  17519. /// </summary>
  17520. /// <param name="dto">团组列表请求dto</param>
  17521. /// <returns></returns>
  17522. [HttpPost]
  17523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17524. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  17525. {
  17526. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17527. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  17528. {
  17529. string sqlWhere = string.Empty;
  17530. if (dto.IsSure == 0) //未完成
  17531. {
  17532. sqlWhere += string.Format(@" And IsSure = 0");
  17533. }
  17534. else if (dto.IsSure == 1) //已完成
  17535. {
  17536. sqlWhere += string.Format(@" And IsSure = 1");
  17537. }
  17538. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  17539. {
  17540. string tj = dto.SearchCriteria;
  17541. 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}%')",
  17542. tj, tj, tj, tj, tj);
  17543. }
  17544. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  17545. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  17546. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  17547. From (
  17548. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  17549. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  17550. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  17551. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  17552. From Grp_DelegationInfo gdi
  17553. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  17554. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  17555. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  17556. Where gdi.IsDel = 0 {0}
  17557. ) temp ", sqlWhere);
  17558. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  17559. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  17560. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  17561. }
  17562. else
  17563. {
  17564. return Ok(JsonView(false, "查询失败"));
  17565. }
  17566. }
  17567. /// <summary>
  17568. /// 团组状态
  17569. /// 设置操作完成
  17570. /// </summary>
  17571. /// <param name="dto">团组列表请求dto</param>
  17572. /// <returns></returns>
  17573. [HttpPost]
  17574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17575. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  17576. {
  17577. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  17578. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  17579. {
  17580. Id = dto.Id,
  17581. IsSure = 1
  17582. };
  17583. var result = await _sqlSugar.Updateable(_DelegationInfo)
  17584. .UpdateColumns(it => new { it.IsSure })
  17585. .WhereColumns(it => new { it.Id })
  17586. .ExecuteCommandAsync();
  17587. if (result > 0)
  17588. {
  17589. return Ok(JsonView(true, "操作完成!"));
  17590. }
  17591. return Ok(JsonView(false, "操作失败!"));
  17592. }
  17593. #endregion
  17594. #region 保险费用录入
  17595. /// <summary>
  17596. /// 根据团组Id查询保险费用列表
  17597. /// </summary>
  17598. /// <param name="dto"></param>
  17599. /// <returns></returns>
  17600. [HttpPost]
  17601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17602. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  17603. {
  17604. Result groupData = await _customersRep.CustomersByDiId(dto);
  17605. if (groupData.Code != 0)
  17606. {
  17607. return Ok(JsonView(false, groupData.Msg));
  17608. }
  17609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17610. }
  17611. /// <summary>
  17612. /// 根据保险费用Id查询保险费用详细
  17613. /// </summary>
  17614. /// <param name="dto"></param>
  17615. /// <returns></returns>
  17616. [HttpPost]
  17617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17618. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  17619. {
  17620. try
  17621. {
  17622. Result groupData = await _customersRep.CustomersById(dto);
  17623. if (groupData.Code != 0)
  17624. {
  17625. return Ok(JsonView(false, groupData.Msg));
  17626. }
  17627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17628. }
  17629. catch (Exception ex)
  17630. {
  17631. return Ok(JsonView(false, ex.Message));
  17632. }
  17633. }
  17634. /// <summary>
  17635. /// 保险费用录入页面初始化绑定
  17636. /// </summary>
  17637. /// <param name="dto"></param>
  17638. /// <returns></returns>
  17639. [HttpPost]
  17640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17641. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  17642. {
  17643. try
  17644. {
  17645. Result groupData = await _customersRep.CustomersInitialize(dto);
  17646. if (groupData.Code != 0)
  17647. {
  17648. return Ok(JsonView(false, groupData.Msg));
  17649. }
  17650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17651. }
  17652. catch (Exception ex)
  17653. {
  17654. return Ok(JsonView(false, ex.Message));
  17655. }
  17656. }
  17657. /// <summary>
  17658. /// 保险费用操作(Status:1.新增,2.修改)
  17659. /// </summary>
  17660. /// <param name="dto"></param>
  17661. /// <returns></returns>
  17662. [HttpPost]
  17663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17664. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  17665. {
  17666. Result groupData = await _customersRep.OpCustomers(dto);
  17667. if (groupData.Code != 0)
  17668. {
  17669. return Ok(JsonView(false, groupData.Msg));
  17670. }
  17671. #region 应用推送
  17672. try
  17673. {
  17674. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  17675. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  17676. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  17677. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17678. //自动审核
  17679. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  17680. //2024-10-21 新增LZ UID
  17681. var userIds = new List<int>() { 21 };
  17682. string title = $"系统通知";
  17683. var diId = dto.DiId;
  17684. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17685. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17686. string content = "";
  17687. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17688. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17689. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17690. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  17691. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  17692. }
  17693. catch (Exception ex)
  17694. {
  17695. }
  17696. #endregion
  17697. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17698. }
  17699. /// <summary>
  17700. /// 保险文件上传
  17701. /// </summary>
  17702. /// <param name="file"></param>
  17703. /// <returns></returns>
  17704. [HttpPost]
  17705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17706. public async Task<IActionResult> UploadCus(IFormFile file)
  17707. {
  17708. try
  17709. {
  17710. if (file != null)
  17711. {
  17712. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17713. //文件名称
  17714. string projectFileName = file.FileName;
  17715. //上传的文件的路径
  17716. string filePath = "";
  17717. if (!Directory.Exists(fileDir))
  17718. {
  17719. Directory.CreateDirectory(fileDir);
  17720. }
  17721. //上传的文件的路径
  17722. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  17723. using (FileStream fs = System.IO.File.Create(filePath))
  17724. {
  17725. file.CopyTo(fs);
  17726. fs.Flush();
  17727. }
  17728. return Ok(JsonView(true, "上传成功!", projectFileName));
  17729. }
  17730. else
  17731. {
  17732. return Ok(JsonView(false, "上传失败!"));
  17733. }
  17734. }
  17735. catch (Exception ex)
  17736. {
  17737. return Ok(JsonView(false, "程序错误!"));
  17738. throw;
  17739. }
  17740. }
  17741. /// <summary>
  17742. /// 保险删除指定文件
  17743. /// </summary>
  17744. /// <param name="dto"></param>
  17745. /// <returns></returns>
  17746. [HttpPost]
  17747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17748. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  17749. {
  17750. try
  17751. {
  17752. string filePath = "";
  17753. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17754. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  17755. //int id = 0;
  17756. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  17757. // 删除该文件
  17758. try
  17759. {
  17760. System.IO.File.Delete(filePath);
  17761. 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()
  17762. {
  17763. Attachment = "",
  17764. }).ExecuteCommandAsync();
  17765. if (result != 0)
  17766. {
  17767. return Ok(JsonView(true, "成功!"));
  17768. }
  17769. else
  17770. {
  17771. return Ok(JsonView(false, "失败!"));
  17772. }
  17773. }
  17774. catch (Exception)
  17775. {
  17776. 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()
  17777. {
  17778. Attachment = "",
  17779. }).ExecuteCommandAsync();
  17780. if (result != 0)
  17781. {
  17782. return Ok(JsonView(true, "成功!"));
  17783. }
  17784. else
  17785. {
  17786. return Ok(JsonView(false, "失败!"));
  17787. }
  17788. }
  17789. }
  17790. catch (Exception ex)
  17791. {
  17792. return Ok(JsonView(false, "程序错误!"));
  17793. throw;
  17794. }
  17795. }
  17796. /// <summary>
  17797. /// 保险费用操作(删除)
  17798. /// </summary>
  17799. /// <param name="dto"></param>
  17800. /// <returns></returns>
  17801. [HttpPost]
  17802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17803. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  17804. {
  17805. try
  17806. {
  17807. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  17808. if (!res)
  17809. {
  17810. return Ok(JsonView(false, "删除失败"));
  17811. }
  17812. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  17813. {
  17814. IsDel = 1,
  17815. DeleteUserId = dto.DeleteUserId,
  17816. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  17817. }).ExecuteCommandAsync();
  17818. return Ok(JsonView(true, "删除成功!"));
  17819. }
  17820. catch (Exception ex)
  17821. {
  17822. return Ok(JsonView(false, "程序错误!"));
  17823. throw;
  17824. }
  17825. }
  17826. #endregion
  17827. #region 接团客户名单 PageId 104
  17828. /// <summary>
  17829. /// 接团客户名单
  17830. /// 迁移数据(慎用!)
  17831. /// </summary>
  17832. /// <returns></returns>
  17833. [HttpPost]
  17834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17835. public async Task<IActionResult> PostTourClientListChange()
  17836. {
  17837. try
  17838. {
  17839. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  17840. //var groupClinetData1
  17841. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  17842. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  17843. int updateCount = 0;
  17844. if (oldOAClientList.Count > 0)
  17845. {
  17846. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  17847. _sqlSugar.BeginTran();
  17848. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  17849. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  17850. foreach (var item in oldOAClientList)
  17851. {
  17852. int comId = 0;
  17853. string format = "yyyy-MM-dd HH:mm:ss";
  17854. string data11 = "1990-01-01 00:00";
  17855. var data1 = IsValidDate(item.OPdate, format);
  17856. if (data1) data11 = item.OPdate;
  17857. //客户公司验证
  17858. if (!string.IsNullOrEmpty(item.Company))
  17859. {
  17860. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  17861. if (clientComInfo == null) // add
  17862. {
  17863. var addInfo = new Crm_CustomerCompany()
  17864. {
  17865. CompanyAbbreviation = "",
  17866. CompanyFullName = item.Company,
  17867. Address = "",
  17868. PostCodes = "",
  17869. LastedOpUserId = item.OPer,
  17870. LastedOpDt = Convert.ToDateTime(data11),
  17871. CreateUserId = item.OPer,
  17872. CreateTime = Convert.ToDateTime(data11),
  17873. IsDel = 0
  17874. };
  17875. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  17876. if (comId1 > 0) comId = comId1;
  17877. }
  17878. else comId = clientComInfo.Id;
  17879. }
  17880. //客户人员验证
  17881. int clientId = 0;
  17882. string name = item.LastName + item.Name;
  17883. if (!string.IsNullOrEmpty(name))
  17884. {
  17885. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  17886. if (clientInfo == null)
  17887. {
  17888. DateTime? dateTime = null;
  17889. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  17890. if (isDt) dateTime = birthDayDt;
  17891. var addInfo1 = new Crm_DeleClient()
  17892. {
  17893. CrmCompanyId = comId,
  17894. DiId = -1,
  17895. LastName = item.LastName,
  17896. FirstName = item.Name,
  17897. OldName = "",
  17898. Pinyin = item.Pinyin,
  17899. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  17900. Marriage = 0,
  17901. Phone = item.Phone,
  17902. Job = item.Job,
  17903. BirthDay = dateTime
  17904. };
  17905. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  17906. if (clientId1 > 0) clientId = clientId1;
  17907. }
  17908. else clientId = clientInfo.Id;
  17909. }
  17910. if (clientId < 1)
  17911. {
  17912. continue;
  17913. }
  17914. int airType = 0;
  17915. if (item.AirType == "超经舱") airType = 459;
  17916. else if (item.AirType == "公务舱") airType = 458;
  17917. else if (item.AirType == "经济舱") airType = 460;
  17918. else if (item.AirType == "其他") airType = 565;
  17919. else if (item.AirType == "头等舱") airType = 457;
  17920. var _TourClientListEntity = new Grp_TourClientList()
  17921. {
  17922. DiId = item.Diid,
  17923. ClientId = clientId,
  17924. CreateUserId = item.OPer,
  17925. CreateTime = Convert.ToDateTime(data11),
  17926. Remark = item.Remark,
  17927. IsDel = item.Isdel,
  17928. ShippingSpaceTypeId = airType,
  17929. ShippingSpaceSpecialNeeds = item.AirRemark,
  17930. HotelSpecialNeeds = item.RoomType
  17931. };
  17932. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  17933. if (_TourClientList > 0)
  17934. {
  17935. updateCount++;
  17936. }
  17937. }
  17938. _sqlSugar.CommitTran();
  17939. }
  17940. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  17941. }
  17942. catch (Exception ex)
  17943. {
  17944. _sqlSugar.RollbackTran();
  17945. return Ok(JsonView(false, ex.Message));
  17946. }
  17947. //return Ok(JsonView(true));
  17948. }
  17949. private bool IsValidDate(string dateString, string format)
  17950. {
  17951. DateTime dateValue;
  17952. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  17953. return valid;
  17954. }
  17955. /// <summary>
  17956. /// 接团客户名单
  17957. /// 根据团组Id查询List
  17958. /// </summary>
  17959. /// <param name="_dto"></param>
  17960. /// <returns></returns>
  17961. [HttpPost]
  17962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17963. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17964. {
  17965. #region 参数验证
  17966. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17967. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17968. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17969. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17970. #region 页面操作权限验证
  17971. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17972. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17973. #endregion
  17974. #endregion
  17975. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17976. if (viewData.Code != 0)
  17977. {
  17978. return Ok(JsonView(false, viewData.Msg));
  17979. }
  17980. return Ok(JsonView(viewData.Data));
  17981. }
  17982. /// <summary>
  17983. /// 接团客户名单
  17984. /// 基础数据 Init
  17985. /// </summary>
  17986. /// <param name="_dto"></param>
  17987. /// <returns></returns>
  17988. [HttpPost]
  17989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17990. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17991. {
  17992. #region 参数验证
  17993. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17994. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17995. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17996. #region 页面操作权限验证
  17997. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17998. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17999. #endregion
  18000. #endregion
  18001. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  18002. }
  18003. /// <summary>
  18004. /// 接团客户名单
  18005. /// 根据 Id查询 Details
  18006. /// </summary>
  18007. /// <param name="_dto"></param>
  18008. /// <returns></returns>
  18009. [HttpPost]
  18010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18011. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  18012. {
  18013. #region 参数验证
  18014. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18015. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18016. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18017. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18018. #region 页面操作权限验证
  18019. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18020. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18021. #endregion
  18022. #endregion
  18023. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  18024. if (viewData.Code != 0)
  18025. {
  18026. return Ok(JsonView(false, viewData.Msg));
  18027. }
  18028. return Ok(JsonView(viewData.Data));
  18029. }
  18030. /// <summary>
  18031. /// 接团客户名单
  18032. /// Add Or Edit
  18033. /// </summary>
  18034. /// <param name="_dto"></param>
  18035. /// <returns></returns>
  18036. [HttpPost]
  18037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18038. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  18039. {
  18040. #region 参数验证
  18041. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18042. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18043. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  18044. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18045. #region 页面操作权限验证
  18046. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18047. if (_dto.Id == 0) //添加
  18048. {
  18049. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18050. }
  18051. else if (_dto.Id >= 0) //修改
  18052. {
  18053. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18054. }
  18055. #endregion
  18056. #endregion
  18057. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  18058. if (viewData.Code != 0)
  18059. {
  18060. return Ok(JsonView(false, viewData.Msg));
  18061. }
  18062. return Ok(JsonView(true));
  18063. }
  18064. /// <summary>
  18065. /// 接团客户名单
  18066. /// json字符串 AddMultiple(添加多个)
  18067. /// </summary>
  18068. /// <param name="_dto"></param>
  18069. /// <returns></returns>
  18070. [HttpPost]
  18071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18072. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  18073. {
  18074. #region 参数验证
  18075. string jsonLabel = _dto.JsonLabel;
  18076. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18077. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18078. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18079. #region 页面操作权限验证
  18080. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18081. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18082. #endregion
  18083. #endregion
  18084. var request = new TourClientListAddMultipleDto();
  18085. request.DiId = _dto.DiId;
  18086. request.UserId = _dto.UserId;
  18087. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  18088. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  18089. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  18090. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  18091. var infos = new List<TourClientListInfo>();
  18092. foreach (var data in datas)
  18093. {
  18094. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  18095. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  18096. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  18097. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  18098. {
  18099. continue;
  18100. }
  18101. infos.Add(new TourClientListInfo()
  18102. {
  18103. IsAccompany = 1,
  18104. LastName = lastName,
  18105. FirstName = firstName,
  18106. Pinyin = lastNameEn + @"/" + firstNameEn,
  18107. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  18108. CompanyFullName = data.CompanyFullName,
  18109. Job = data.Job
  18110. });
  18111. }
  18112. if (infos.Any())
  18113. {
  18114. var viewData = await _tourClientListRep._AddMultiple(request);
  18115. if (viewData.Code != 0)
  18116. {
  18117. return Ok(JsonView(false, viewData.Msg));
  18118. }
  18119. return Ok(JsonView(true));
  18120. }
  18121. return Ok(JsonView(false));
  18122. }
  18123. /// <summary>
  18124. /// 接团客户名单
  18125. /// AddMultiple(添加多个)
  18126. /// </summary>
  18127. /// <param name="_dto"></param>
  18128. /// <returns></returns>
  18129. [HttpPost]
  18130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18131. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  18132. {
  18133. #region 参数验证
  18134. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18135. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18136. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18137. #region 页面操作权限验证
  18138. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18139. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18140. #endregion
  18141. #endregion
  18142. var viewData = await _tourClientListRep._AddMultiple(_dto);
  18143. if (viewData.Code != 0)
  18144. {
  18145. return Ok(JsonView(false, viewData.Msg));
  18146. }
  18147. return Ok(JsonView(true));
  18148. }
  18149. /// <summary>
  18150. /// 接团客户名单
  18151. /// Del
  18152. /// </summary>
  18153. /// <param name="_dto"></param>
  18154. /// <returns></returns>
  18155. [HttpPost]
  18156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18157. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  18158. {
  18159. #region 参数验证
  18160. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18161. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18162. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18163. #region 页面操作权限验证
  18164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18165. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18166. #endregion
  18167. #endregion
  18168. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  18169. if (viewData.Code != 0)
  18170. {
  18171. return Ok(JsonView(false, viewData.Msg));
  18172. }
  18173. return Ok(JsonView(true));
  18174. }
  18175. /// <summary>
  18176. /// 接团客户名单
  18177. /// 文件下载 客户名单
  18178. /// </summary>
  18179. /// <param name="_dto"></param>
  18180. /// <returns></returns>
  18181. [HttpPost]
  18182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18183. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  18184. {
  18185. #region 参数验证
  18186. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  18187. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  18188. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  18189. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18190. #region 页面操作权限验证
  18191. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18192. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18193. #endregion
  18194. #endregion
  18195. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  18196. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  18197. From Grp_TourClientList tcl
  18198. Left Join
  18199. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  18200. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  18201. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  18202. From Crm_DeleClient dc
  18203. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  18204. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  18205. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  18206. Where dc.IsDel = 0) temp
  18207. On temp.DcId =tcl.ClientId
  18208. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  18209. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  18210. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  18211. //载入模板
  18212. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  18213. if (_dto.Language == 1)
  18214. {
  18215. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  18216. }
  18217. //载入模板
  18218. var doc = new Document(tempPath);
  18219. DocumentBuilder builder = new DocumentBuilder(doc);
  18220. //获取word里所有表格
  18221. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18222. //获取所填表格的序数
  18223. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18224. var rowStart = tableOne.Rows[0]; //获取第1行
  18225. if (_dto.Language == 0)
  18226. {
  18227. //循环赋值
  18228. for (int i = 0; i < DcList.Count; i++)
  18229. {
  18230. EncryptionProcessor.DecryptProperties(DcList[i]);
  18231. builder.MoveToCell(0, i + 1, 0, 0);
  18232. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  18233. builder.MoveToCell(0, i + 1, 1, 0);
  18234. int sex = DcList[i].Sex;
  18235. string sexStr = string.Empty;
  18236. if (sex == 0) sexStr = "男";
  18237. else if (sex == 1) sexStr = "女";
  18238. else sexStr = "未设置";
  18239. builder.Write(sexStr);
  18240. builder.MoveToCell(0, i + 1, 2, 0);
  18241. string birthDay = DcList[i].BirthDay;
  18242. string birthDayStr = string.Empty;
  18243. if (!string.IsNullOrEmpty(birthDay))
  18244. {
  18245. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  18246. }
  18247. builder.Write(birthDayStr);
  18248. builder.MoveToCell(0, i + 1, 3, 0);
  18249. string company = "";
  18250. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18251. {
  18252. company = DcList[i].CompanyFullName.ToString();
  18253. }
  18254. builder.Write(company);
  18255. builder.MoveToCell(0, i + 1, 4, 0);
  18256. builder.Write(DcList[i].Job);
  18257. }
  18258. }
  18259. else if (_dto.Language == 1)
  18260. {
  18261. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  18262. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  18263. List<string> transArrayStr = new List<string>();
  18264. string transStrRes1 = "";
  18265. for (int i = 0; i < DcList.Count; i++)
  18266. {
  18267. var dc = DcList[i];
  18268. EncryptionProcessor.DecryptProperties(dc);
  18269. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  18270. if (dc.Job.Equals("暂无")) dc.Job = "-";
  18271. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  18272. if (DcList.Count - 1 == i) transStrRes1 += str1;
  18273. else transStrRes1 += $"{str1}|";
  18274. }
  18275. //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";
  18276. string transStrRes = "";
  18277. if (transStrRes1.Length > 0)
  18278. {
  18279. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  18280. }
  18281. //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
  18282. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  18283. //List<string> transArray = new List<string> { };
  18284. List<TranslateInfo> transArray = new List<TranslateInfo>();
  18285. if (transStrRes.Contains("|"))
  18286. {
  18287. string[] transArray1 = transStrRes.Split('|');
  18288. if (transArray1.Length > 0)
  18289. {
  18290. foreach (var item in transArray1)
  18291. {
  18292. if (item.Contains("&"))
  18293. {
  18294. string[] transArray2 = item.Split('&');
  18295. int index = 0;
  18296. string companyName = "", job = "";
  18297. if (transArray2.Length > 0)
  18298. {
  18299. bool success = int.TryParse(transArray2[0].Trim(), out index);
  18300. if (1 < transArray2.Length) companyName = transArray2[1];
  18301. if (2 < transArray2.Length) job = transArray2[2];
  18302. }
  18303. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  18304. }
  18305. }
  18306. }
  18307. }
  18308. //循环赋值
  18309. for (int i = 0; i < DcList.Count; i++)
  18310. {
  18311. string PYName = "";
  18312. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  18313. {
  18314. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  18315. string PY_First = DcList[i].Pinyin.Split('/')[1];
  18316. PYName = PY_First + " " + PY_Last;
  18317. }
  18318. else
  18319. {
  18320. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  18321. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  18322. PYName = PY_First + " " + PY_Last;
  18323. }
  18324. builder.MoveToCell(0, i + 1, 0, 0);
  18325. builder.Write(PYName);
  18326. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  18327. builder.MoveToCell(0, i + 1, 1, 0);
  18328. builder.Write(sex);
  18329. DateTime birthDt;
  18330. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  18331. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  18332. builder.MoveToCell(0, i + 1, 2, 0);
  18333. builder.Write(birthday);
  18334. string company = string.Empty, job = string.Empty;
  18335. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  18336. if (dcTransInfo != null)
  18337. {
  18338. company = dcTransInfo.CompanyName;
  18339. job = dcTransInfo.Job;
  18340. }
  18341. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  18342. {
  18343. //查询对照表
  18344. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  18345. if (tempCec != null)
  18346. {
  18347. company = tempCec.enName;
  18348. }
  18349. //翻译
  18350. else
  18351. {
  18352. }
  18353. }
  18354. builder.MoveToCell(0, i + 1, 3, 0);
  18355. builder.Write(company);
  18356. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  18357. {
  18358. //查询对照表
  18359. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  18360. if (tempPec != null)
  18361. {
  18362. job = tempPec.enName;
  18363. }
  18364. //翻译
  18365. else
  18366. {
  18367. }
  18368. }
  18369. builder.MoveToCell(0, i + 1, 4, 0);
  18370. builder.Write(job);
  18371. }
  18372. }
  18373. //删除多余行
  18374. while (tableOne.Rows.Count > DcList.Count + 1)
  18375. {
  18376. tableOne.Rows.RemoveAt(DcList.Count + 1);
  18377. }
  18378. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  18379. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  18380. doc.Save(fileDir);
  18381. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  18382. return Ok(JsonView(true, "操作成功!", Url));
  18383. }
  18384. private class TranslateInfo
  18385. {
  18386. public int Index { get; set; }
  18387. public string CompanyName { get; set; }
  18388. public string Job { get; set; }
  18389. }
  18390. #endregion
  18391. #region 团组倒推表
  18392. /// <summary>
  18393. /// 倒推表基础数据
  18394. /// Init
  18395. /// </summary>
  18396. /// <returns></returns>
  18397. [HttpPost]
  18398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18399. public async Task<IActionResult> PostInvertedListInit()
  18400. {
  18401. var viewData = await _invertedListRep._Init();
  18402. if (viewData.Code != 0)
  18403. {
  18404. return Ok(JsonView(false, viewData.Msg));
  18405. }
  18406. return Ok(JsonView(viewData.Data));
  18407. }
  18408. /// <summary>
  18409. /// 倒推表
  18410. /// Info
  18411. /// </summary>
  18412. /// <param name="dto"></param>
  18413. /// <returns></returns>
  18414. [HttpPost]
  18415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18416. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  18417. {
  18418. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  18419. if (viewData.Code != 0)
  18420. {
  18421. return Ok(JsonView(false, viewData.Msg));
  18422. }
  18423. return Ok(JsonView(viewData.Data));
  18424. }
  18425. /// <summary>
  18426. /// 倒推表
  18427. /// Create
  18428. /// </summary>
  18429. /// <param name="dto"></param>
  18430. /// <returns></returns>
  18431. [HttpPost]
  18432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18433. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  18434. {
  18435. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  18436. if (viewData.Code != 0)
  18437. {
  18438. return Ok(JsonView(false, viewData.Msg));
  18439. }
  18440. return Ok(JsonView(viewData.Data));
  18441. }
  18442. /// <summary>
  18443. /// 倒推表
  18444. /// Update
  18445. /// </summary>
  18446. /// <param name="dto"></param>
  18447. /// <returns></returns>
  18448. [HttpPost]
  18449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18450. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  18451. {
  18452. var viewData = await _invertedListRep._Update(dto);
  18453. if (viewData.Code != 0)
  18454. {
  18455. return Ok(JsonView(false, viewData.Msg));
  18456. }
  18457. return Ok(JsonView(viewData.Data));
  18458. }
  18459. /// <summary>
  18460. /// 倒推表
  18461. /// File Download
  18462. /// </summary>
  18463. /// <param name="dto"></param>
  18464. /// <returns></returns>
  18465. [HttpPost]
  18466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18467. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  18468. {
  18469. var info2 = await _invertedListRep._Info(1, dto.DiId);
  18470. if (info2.Code != 0)
  18471. {
  18472. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  18473. }
  18474. var info1 = info2.Data as InvertedListInfoView;
  18475. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  18476. string teamName = "";
  18477. if (info != null) teamName = info.TeamName;
  18478. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  18479. var doc = new Document();
  18480. var builder = new DocumentBuilder(doc);
  18481. #region old insert
  18482. ////载入模板
  18483. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  18484. //Document doc = new Document(tempPath);
  18485. //DocumentBuilder builder = new DocumentBuilder(doc);
  18486. //利用键值对存放数据
  18487. //Dictionary<string, string> dic = new Dictionary<string, string>();
  18488. //dic.Add("TeamName", teamName);
  18489. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  18490. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  18491. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  18492. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  18493. //dic.Add("SQRemark", info1.ApprovalRemark);
  18494. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  18495. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  18496. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  18497. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  18498. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  18499. //dic.Add("QZRemark", info1.VisaInformationRemark);
  18500. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  18501. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  18502. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  18503. //dic.Add("CQRemark", info1.IssueVisaRemark);
  18504. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  18505. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  18506. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  18507. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  18508. //#region 填充word模板书签内容
  18509. //foreach (var key in dic.Keys)
  18510. //{
  18511. // builder.MoveToBookmark(key);
  18512. // builder.Write(dic[key]);
  18513. //}
  18514. //#endregion
  18515. #endregion
  18516. #region New Insert
  18517. string titleFont = $"仿宋",
  18518. contentFont = $"仿宋";
  18519. var fontColor = Color.FromArgb(64, 64, 64);
  18520. //设置标题 团组名称
  18521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18522. builder.Font.Name = titleFont;
  18523. builder.Font.Color = fontColor;
  18524. builder.Font.Size = 12;
  18525. builder.Font.Bold = true;
  18526. builder.Writeln(teamName);
  18527. //设置副标题 团组出访时间
  18528. builder.Font.Size = 12;
  18529. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  18530. builder.Writeln();
  18531. var backgroundColor = Color.FromArgb(199, 199, 199);
  18532. var table = builder.StartTable();
  18533. builder.InsertCell();
  18534. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  18535. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  18536. builder.CellFormat.Borders.LineWidth = 1;
  18537. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  18538. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  18539. builder.RowFormat.Height = 40;
  18540. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18541. builder.Font.Name = contentFont;
  18542. builder.Font.Size = 12;
  18543. builder.Font.Bold = true;
  18544. builder.Font.Color = fontColor;
  18545. builder.Write("时间");
  18546. builder.InsertCell();
  18547. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  18548. builder.Write("流程");
  18549. builder.InsertCell();
  18550. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  18551. builder.Write("说明");
  18552. builder.EndRow();
  18553. //报批资料准备
  18554. if (info1.IsSelectedAirportd)
  18555. {
  18556. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  18557. }
  18558. //报批/提供送签资料
  18559. if (info1.IsSelectedApprovalData)
  18560. {
  18561. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  18562. }
  18563. //出批件护照办理
  18564. if (info1.IsSelectedIssueApproval)
  18565. {
  18566. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  18567. }
  18568. //签证资料准备
  18569. if (info1.IsSelectedVisaInfo)
  18570. {
  18571. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  18572. }
  18573. //送签
  18574. if (info1.IsSelectedSendVisa)
  18575. {
  18576. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  18577. }
  18578. //出签
  18579. if (info1.IsSelectedIssueVisa)
  18580. {
  18581. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  18582. }
  18583. //机票
  18584. if (info1.IsSelectedAirTicket)
  18585. {
  18586. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  18587. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  18588. }
  18589. //酒店
  18590. if (info1.IsSelectedHotel)
  18591. {
  18592. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  18593. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  18594. }
  18595. //开行前会
  18596. if (info1.IsSelectedPreTripMeeting)
  18597. {
  18598. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  18599. }
  18600. //送机
  18601. if (info1.IsSelectedAirportdDropOff)
  18602. {
  18603. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  18604. }
  18605. builder.EndTable();
  18606. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  18607. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  18608. for (int i = 0; i < table.Rows.Count; i++)
  18609. {
  18610. var row = table.Rows[i];
  18611. //设置宽度
  18612. row.Cells[0].CellFormat.Width = 20.00;
  18613. row.Cells[1].CellFormat.Width = 30.00;
  18614. row.Cells[2].CellFormat.Width = 50.00;
  18615. if (i != 0)
  18616. {
  18617. //边框设置
  18618. InvertedListFileDownloadSetBorders(row.Cells, 0);
  18619. InvertedListFileDownloadSetBorders(row.Cells, 1);
  18620. InvertedListFileDownloadSetBorders(row.Cells, 2);
  18621. }
  18622. }
  18623. #region 页脚插入图片
  18624. // 创建页脚
  18625. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  18626. doc.FirstSection.HeadersFooters.Add(footer);
  18627. Paragraph para = new Paragraph(doc);
  18628. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  18629. footer.AppendChild(para);
  18630. builder.MoveTo(para);
  18631. string imagePath = "./Images/FMGJ_Log.png";
  18632. builder.InsertImage(imagePath);
  18633. #endregion
  18634. #endregion
  18635. var fileDir = AppSettingsHelper.Get("WordBasePath");
  18636. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  18637. string filePath = fileDir + $@"InvertedList/{fileName}";
  18638. doc.Save(filePath);
  18639. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  18640. return Ok(JsonView(true, "操作成功!", Url));
  18641. }
  18642. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  18643. {
  18644. var fontColor = Color.FromArgb(64, 64, 64);
  18645. builder.InsertCell();
  18646. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  18647. builder.RowFormat.Height = 40;
  18648. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18650. builder.Font.Name = fontName;
  18651. builder.Font.Size = 8;
  18652. builder.Font.Bold = true;
  18653. builder.Font.Color = fontColor;
  18654. builder.Write(dateTime);
  18655. builder.InsertCell();
  18656. builder.Font.Size = 9;
  18657. builder.Font.Bold = true;
  18658. builder.Font.Color = fontColor;
  18659. builder.Write(content);
  18660. builder.InsertCell();
  18661. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18663. builder.Font.Size = 9;
  18664. builder.Font.Bold = false;
  18665. builder.Font.Color = fontColor;
  18666. builder.Write(reamrk);
  18667. builder.EndRow();
  18668. }
  18669. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  18670. {
  18671. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  18672. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  18673. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  18674. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  18675. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  18676. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  18677. }
  18678. #endregion
  18679. #region 会务倒推表
  18680. /// <summary>
  18681. /// 会务倒推表
  18682. /// Init
  18683. /// </summary>
  18684. /// <returns></returns>
  18685. [HttpPost]
  18686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18687. public async Task<IActionResult> InforRetrogressTableInit()
  18688. {
  18689. var groupData = await _groupRepository.PostShareGroupInfos(1);
  18690. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  18691. return Ok(JsonView(false, groupData.Msg));
  18692. }
  18693. /// <summary>
  18694. /// 会务倒推表
  18695. /// ExcelDownload
  18696. /// </summary>
  18697. /// <param name="dto"></param>
  18698. /// <returns></returns>
  18699. [HttpPost]
  18700. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  18701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18702. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  18703. {
  18704. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  18705. var validatorRes = await validator.ValidateAsync(dto);
  18706. if (!validatorRes.IsValid)
  18707. {
  18708. StringBuilder sb = new StringBuilder();
  18709. foreach (var item in validatorRes.Errors)
  18710. {
  18711. sb.AppendLine(item.ErrorMessage);
  18712. }
  18713. return Ok(JsonView(false, sb.ToString()));
  18714. }
  18715. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  18716. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  18717. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  18718. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  18719. #region Excel
  18720. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  18721. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  18722. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  18723. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  18724. var fileNamePrefix = string.Empty;
  18725. if (days >= 30)
  18726. {
  18727. tempPath += $"会务工作倒推进度表(30天).xlsx";
  18728. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  18729. }
  18730. else if (days < 30 && days > 7)
  18731. {
  18732. tempPath += $"会务工作倒推进度表(15天).xlsx";
  18733. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  18734. }
  18735. else if (days <= 7)
  18736. {
  18737. tempPath += $"会务工作倒推进度表(7天).xlsx";
  18738. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  18739. }
  18740. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  18741. fileName = CommonFun.ValidFileName(fileName);
  18742. //载入模板
  18743. WorkbookDesigner designer = new WorkbookDesigner();
  18744. designer.Workbook = new Workbook(tempPath);
  18745. designer.Process();
  18746. if (!Directory.Exists(savePath))
  18747. {
  18748. Directory.CreateDirectory(savePath);
  18749. }
  18750. string serverPath = $"{savePath}{fileName}";
  18751. designer.Workbook.Save(serverPath);
  18752. string rst = $"{servicePath}{ftpPath}{fileName}";
  18753. #endregion
  18754. return Ok(JsonView(new { url = rst }));
  18755. }
  18756. #endregion
  18757. #region 三公签证费用(签证费、代办费)
  18758. /// <summary>
  18759. /// 三公签证费用(签证费、代办费)
  18760. /// List
  18761. /// </summary>
  18762. /// <returns></returns>
  18763. [HttpPost]
  18764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18765. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  18766. {
  18767. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  18768. if (_view.Code != 0)
  18769. {
  18770. return Ok(JsonView(false, _view.Msg));
  18771. }
  18772. return Ok(JsonView(true, "操作成功!", _view.Data));
  18773. }
  18774. /// <summary>
  18775. /// 三公签证费用(签证费、代办费)
  18776. /// Add Or Update
  18777. /// </summary>
  18778. /// <returns></returns>
  18779. [HttpPost]
  18780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18781. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  18782. {
  18783. var _view = await _visaFeeInfoRep._Update(_dto);
  18784. if (_view.Code != 0)
  18785. {
  18786. return Ok(JsonView(false, _view.Msg));
  18787. }
  18788. return Ok(JsonView(true, _view.Msg));
  18789. }
  18790. #endregion
  18791. #region 酒店询价
  18792. /// <summary>
  18793. /// 酒店询价
  18794. /// Init
  18795. /// </summary>
  18796. /// <returns></returns>
  18797. [HttpPost]
  18798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18799. public async Task<IActionResult> PostHotelInquiryInit()
  18800. {
  18801. var res = await _hotelInquiryRep._Init();
  18802. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18803. return Ok(JsonView(true, res.Msg, res.Data));
  18804. }
  18805. /// <summary>
  18806. /// 酒店询价
  18807. /// page Item
  18808. /// </summary>
  18809. /// <param name="_dto"></param>
  18810. /// <returns></returns>
  18811. [HttpPost]
  18812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18813. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  18814. {
  18815. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  18816. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18817. var view = res.Data as PageDataViewBase;
  18818. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  18819. }
  18820. /// <summary>
  18821. /// 酒店询价
  18822. /// info
  18823. /// </summary>
  18824. /// <param name="_dto"></param>
  18825. /// <returns></returns>
  18826. [HttpPost]
  18827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18828. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  18829. {
  18830. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  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. /// Add Or Edit
  18837. /// </summary>
  18838. /// <param name="_dto"></param>
  18839. /// <returns></returns>
  18840. [HttpPost]
  18841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18842. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  18843. {
  18844. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  18845. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18846. return Ok(JsonView(true, res.Msg, res.Data));
  18847. }
  18848. /// <summary>
  18849. /// 酒店询价
  18850. /// Del
  18851. /// </summary>
  18852. /// <param name="_dto"></param>
  18853. /// <returns></returns>
  18854. [HttpPost]
  18855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18856. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  18857. {
  18858. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  18859. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18860. return Ok(JsonView(true, res.Msg, res.Data));
  18861. }
  18862. #endregion
  18863. #region 下载匹配op行程单
  18864. /// <summary>
  18865. /// 匹配op行程单
  18866. /// Init
  18867. /// </summary>
  18868. /// <param name="dto">团组列表请求dto</param>
  18869. /// <returns></returns>
  18870. [HttpPost]
  18871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18872. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  18873. {
  18874. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18875. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18876. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  18877. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  18878. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  18879. .Where(it => it.IsDel == 0)
  18880. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  18881. .OrderByDescending(it => it.VisitStartDate)
  18882. .ToList();
  18883. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  18884. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18885. var diids = groupInfos.Select(it => it.Id).ToList();
  18886. List<string> countrys = new List<string>();
  18887. foreach (var item in country)
  18888. {
  18889. var data = _groupRepository.FormartTeamName(item);
  18890. var dataArray = _groupRepository.GroupSplitCountry(data);
  18891. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18892. }
  18893. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  18894. List<string> areaArray = new List<string>(); //GetGroupCityLine
  18895. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  18896. foreach (var item in areaItem)
  18897. {
  18898. string areaStr = item.Value;
  18899. if (!string.IsNullOrEmpty(areaStr))
  18900. {
  18901. string[] str1 = areaStr.Split("-");
  18902. if (str1.Length > 0)
  18903. {
  18904. areaArray.AddRange(str1);
  18905. }
  18906. }
  18907. }
  18908. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  18909. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  18910. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  18911. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  18912. .ToList();
  18913. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  18914. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  18915. .Where(it => countriesIds.Contains(it.Id))
  18916. .Select(it => new { it.Id, Name = it.Name_CN })
  18917. .ToList();
  18918. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  18919. .Select(it => it.TeamName).ToList();
  18920. stopwatch.Stop();
  18921. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  18922. }
  18923. ///// <summary>
  18924. ///// 匹配op行程单
  18925. ///// Init 查询区域数据
  18926. ///// </summary>
  18927. ///// <param name="dto">团组列表请求dto</param>
  18928. ///// <returns></returns>
  18929. //[HttpPost]
  18930. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18931. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  18932. //{
  18933. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18934. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  18935. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  18936. // if (string.IsNullOrEmpty(countriesDataStr))
  18937. // {
  18938. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  18939. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  18940. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  18941. // }
  18942. // else
  18943. // {
  18944. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  18945. // }
  18946. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  18947. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  18948. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  18949. // List<dynamic> childList = new List<dynamic>();
  18950. // int parentId = dto.CountriesId;
  18951. // if (provinceData.Count > 1)
  18952. // {
  18953. // foreach (var item1 in provinceData)
  18954. // {
  18955. // List<dynamic> childList1 = new List<dynamic>();
  18956. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  18957. // foreach (var item2 in citiesData1)
  18958. // {
  18959. // List<dynamic> childList2 = new List<dynamic>();
  18960. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18961. // foreach (var item3 in countiesData1)
  18962. // {
  18963. // childList2.Add(new
  18964. // {
  18965. // id = item3.Id,
  18966. // parentId = item2.Id,
  18967. // level = "district",
  18968. // name = item3.Name_CN,
  18969. // });
  18970. // }
  18971. // childList1.Add(new
  18972. // {
  18973. // id = item2.Id,
  18974. // parentId = item1.Id,
  18975. // level = "city",
  18976. // name = item2.Name_CN,
  18977. // childList = childList2
  18978. // });
  18979. // }
  18980. // childList.Add(new
  18981. // {
  18982. // id = item1.Id,
  18983. // parentId = parentId,
  18984. // level = "province",
  18985. // name = item1.Name_CN,
  18986. // childList = childList1
  18987. // });
  18988. // }
  18989. // //城市
  18990. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18991. // foreach (var item2 in citiesData2)
  18992. // {
  18993. // List<dynamic> childList22 = new List<dynamic>();
  18994. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18995. // foreach (var item3 in countiesData1)
  18996. // {
  18997. // childList22.Add(new
  18998. // {
  18999. // id = item3.Id,
  19000. // parentId = item2.Id,
  19001. // level = "district",
  19002. // name = item3.Name_CN,
  19003. // });
  19004. // }
  19005. // childList.Add(new
  19006. // {
  19007. // id = item2.Id,
  19008. // parentId = parentId,
  19009. // level = "city",
  19010. // name = item2.Name_CN,
  19011. // childList = childList22
  19012. // });
  19013. // }
  19014. // }
  19015. // else
  19016. // {
  19017. // foreach (var item2 in citiesData)
  19018. // {
  19019. // string cname = item2.Name_CN;
  19020. // List<dynamic> childList1 = new List<dynamic>();
  19021. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  19022. // foreach (var item3 in countiesData1)
  19023. // {
  19024. // childList1.Add(new
  19025. // {
  19026. // Id = item3.Id,
  19027. // parentId = item2.Id,
  19028. // level = "district",
  19029. // name = item3.Name_CN
  19030. // });
  19031. // }
  19032. // childList.Add(new
  19033. // {
  19034. // id = item2.Id,
  19035. // parentId = parentId,
  19036. // level = "city",
  19037. // name = item2.Name_CN,
  19038. // childList = childList1
  19039. // });
  19040. // }
  19041. // }
  19042. // stopwatch.Stop();
  19043. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  19044. //}
  19045. /// <summary>
  19046. /// 匹配op行程单
  19047. /// 接团信息列表 Page
  19048. /// </summary>
  19049. /// <param name="dto">团组列表请求dto</param>
  19050. /// <returns></returns>
  19051. [HttpPost]
  19052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19053. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  19054. {
  19055. var swatch = new Stopwatch();
  19056. swatch.Start();
  19057. #region 参数验证
  19058. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19059. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19060. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19061. #region 页面操作权限验证
  19062. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19063. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  19064. #endregion
  19065. #endregion
  19066. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19067. {
  19068. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  19069. //string sqlWhere = "";
  19070. if (!string.IsNullOrEmpty(dto.Country))
  19071. {
  19072. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  19073. }
  19074. if (!string.IsNullOrEmpty(dto.Area))
  19075. {
  19076. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  19077. }
  19078. if (!string.IsNullOrEmpty(dto.TeamName))
  19079. {
  19080. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  19081. }
  19082. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  19083. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  19084. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  19085. swatch.Stop();
  19086. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  19087. }
  19088. else
  19089. {
  19090. return Ok(JsonView(false, "查询失败"));
  19091. }
  19092. }
  19093. /// <summary>
  19094. /// 匹配op行程单
  19095. /// 行程单下载
  19096. /// </summary>
  19097. /// <param name="dto">团组列表请求dto</param>
  19098. /// <returns></returns>
  19099. [HttpPost]
  19100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19101. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  19102. {
  19103. #region 参数验证
  19104. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  19105. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  19106. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19107. #region 页面操作权限验证
  19108. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  19109. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  19110. #endregion
  19111. #endregion
  19112. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  19113. {
  19114. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  19115. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  19116. }
  19117. else
  19118. {
  19119. return Ok(JsonView(false, "下载失败!"));
  19120. }
  19121. }
  19122. #endregion
  19123. #region 国家信息 数据 注释
  19124. //[HttpPost]
  19125. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  19126. //{
  19127. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  19128. // foreach (var item in dto)
  19129. // {
  19130. // infos.Add(new Grp_GroupsTaskAssignment()
  19131. // {
  19132. // DIId = item,
  19133. // CTId = 82,
  19134. // UId = 248,
  19135. // IsEnable = 1,
  19136. // CreateUserId = 233,
  19137. // CreateTime = DateTime.Now,
  19138. // IsDel = 0
  19139. // });
  19140. // infos.Add(new Grp_GroupsTaskAssignment()
  19141. // {
  19142. // DIId = item,
  19143. // CTId = 82,
  19144. // UId = 286,
  19145. // IsEnable = 1,
  19146. // CreateUserId = 233,
  19147. // CreateTime = DateTime.Now,
  19148. // IsDel = 0
  19149. // });
  19150. // }
  19151. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  19152. // return Ok("操作成功");
  19153. //}
  19154. //public class paramJsonDto
  19155. //{
  19156. // public List<CountriesInfo> str { get; set; }
  19157. //}
  19158. //[HttpPost]
  19159. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  19160. //{
  19161. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  19162. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  19163. // List<Sys_Cities> cities = new List<Sys_Cities>();
  19164. // List<Sys_Cities> districts = new List<Sys_Cities>();
  19165. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19166. // _sqlSugar.BeginTran();
  19167. // int countitiesIndex = 0;
  19168. // foreach (var item in dto.str)
  19169. // {
  19170. // dynamic data = item.c;
  19171. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  19172. // if (data != null)
  19173. // {
  19174. // countitiesIndex++;
  19175. // foreach (var item1 in data)
  19176. // {
  19177. // string cnname = item1.cn;
  19178. // string enname = item1.en;
  19179. // Sys_Cities provinceInfo = new Sys_Cities()
  19180. // {
  19181. // CountriesId = countriesId,
  19182. // Name_CN = cnname,
  19183. // Name_EN = enname,
  19184. // ParentId = 0,
  19185. // IsCapital = 1,
  19186. // CreateUserId = 208,
  19187. // CreateTime = DateTime.Now,
  19188. // IsDel = 0
  19189. // };
  19190. // if (item1.lv == "province") //省份
  19191. // {
  19192. // provinceInfo.Level = 1;
  19193. // int provinceId = 0;
  19194. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  19195. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  19196. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19197. // var data1 = item1.c;
  19198. // foreach (var item2 in data1)
  19199. // {
  19200. // if (item2.lv == "city")
  19201. // {
  19202. // string citycnname = item2.cn;
  19203. // string cityenname = item2.en;
  19204. // Sys_Cities cityInfo = new Sys_Cities()
  19205. // {
  19206. // CountriesId = countriesId,
  19207. // ParentId = provinceId,
  19208. // Level = 2,
  19209. // Name_CN = citycnname,
  19210. // Name_EN = cityenname,
  19211. // IsCapital = 1,
  19212. // CreateUserId = 208,
  19213. // CreateTime = DateTime.Now,
  19214. // IsDel = 0
  19215. // };
  19216. // if (item2.c != null)
  19217. // {
  19218. // int cityId = 0;
  19219. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  19220. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19221. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  19222. // foreach (var item3 in item2.c)
  19223. // {
  19224. // if (item3.lv == "district")
  19225. // {
  19226. // var districtInfo = new Sys_Cities()
  19227. // {
  19228. // CountriesId = countriesId,
  19229. // Name_CN = item3.cn,
  19230. // Name_EN = item3.en,
  19231. // Level = 3,
  19232. // ParentId = cityId,
  19233. // IsCapital = 1,
  19234. // CreateUserId = 208,
  19235. // CreateTime = DateTime.Now,
  19236. // IsDel = 0
  19237. // };
  19238. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19239. // //{
  19240. // districts.Add(districtInfo);
  19241. // //}
  19242. // }
  19243. // }
  19244. // }
  19245. // else
  19246. // {
  19247. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  19248. // //{
  19249. // cities.Add(cityInfo);
  19250. // //}
  19251. // }
  19252. // }
  19253. // }
  19254. // }
  19255. // else if (item1.lv == "city")//城市
  19256. // {
  19257. // provinceInfo.Level = 2;
  19258. // if (item1.c != null)
  19259. // {
  19260. // int cityId = 0;
  19261. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  19262. // if (citiesInfo != null) cityId = citiesInfo.Id;
  19263. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  19264. // foreach (var item3 in item1.c)
  19265. // {
  19266. // if (item3.lv == "district")
  19267. // {
  19268. // var districtInfo = new Sys_Cities()
  19269. // {
  19270. // CountriesId = countriesId,
  19271. // Name_CN = item3.cn,
  19272. // Name_EN = item3.en,
  19273. // Level = 3,
  19274. // ParentId = cityId,
  19275. // IsCapital = 1,
  19276. // CreateUserId = 208,
  19277. // CreateTime = DateTime.Now,
  19278. // IsDel = 0
  19279. // };
  19280. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  19281. // //{
  19282. // districts.Add(districtInfo);
  19283. // //}
  19284. // }
  19285. // }
  19286. // }
  19287. // else
  19288. // {
  19289. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  19290. // //{
  19291. // cities.Add(provinceInfo);
  19292. // //}
  19293. // }
  19294. // }
  19295. // }
  19296. // }
  19297. // }
  19298. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  19299. // cities = cities.Distinct().ToList();
  19300. // districts = districts.Distinct().ToList();
  19301. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  19302. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  19303. // cities.AddRange(districts);
  19304. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  19305. // //_sqlSugar.RollbackTran();
  19306. // _sqlSugar.CommitTran();
  19307. // return Ok(JsonView(false, "操作成功!"));
  19308. //}
  19309. //[HttpPost]
  19310. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  19311. //{
  19312. // List<CountitiesInfo> infos = dto.MyProperty;
  19313. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  19314. // _sqlSugar.BeginTran();
  19315. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  19316. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  19317. // foreach (var item in infos)
  19318. // {
  19319. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  19320. // if (countryInfo != null)
  19321. // {
  19322. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  19323. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  19324. // if (cityInfo1 != null)
  19325. // {
  19326. // cityInfo1.IsCapital = 0;
  19327. // cityInfos.Add(cityInfo1);
  19328. // }
  19329. // }
  19330. // }
  19331. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  19332. // .UpdateColumns(it => it.IsCapital)
  19333. // .WhereColumns(it => it.Id)
  19334. // .ExecuteCommand();
  19335. // //_sqlSugar.RollbackTran();
  19336. // _sqlSugar.CommitTran();
  19337. // return Ok(JsonView(false, "操作成功!"));
  19338. //}
  19339. //public class CounrtiesDto
  19340. //{
  19341. // public List<CountitiesInfo> MyProperty { get; set; }
  19342. //}
  19343. //public class CountitiesInfo
  19344. //{
  19345. // /// <summary>
  19346. // /// 圣约翰
  19347. // /// </summary>
  19348. // public string capital_name_chinese { get; set; }
  19349. // /// <summary>
  19350. // ///
  19351. // /// </summary>
  19352. // public string capital_name { get; set; }
  19353. // /// <summary>
  19354. // ///
  19355. // /// </summary>
  19356. // public string country_type { get; set; }
  19357. // /// <summary>
  19358. // /// 安提瓜和巴布达
  19359. // /// </summary>
  19360. // public string country_name_chinese { get; set; }
  19361. // /// <summary>
  19362. // /// 安提瓜和巴布达
  19363. // /// </summary>
  19364. // public string country_name_chinese_short { get; set; }
  19365. // /// <summary>
  19366. // /// 安提瓜和巴布达
  19367. // /// </summary>
  19368. // public string country_name_chinese_UN { get; set; }
  19369. // /// <summary>
  19370. // ///
  19371. // /// </summary>
  19372. // public string country_name_english_abbreviation { get; set; }
  19373. // /// <summary>
  19374. // ///
  19375. // /// </summary>
  19376. // public string country_name_english_formal { get; set; }
  19377. // /// <summary>
  19378. // ///
  19379. // /// </summary>
  19380. // public string country_name_english_UN { get; set; }
  19381. // /// <summary>
  19382. // ///
  19383. // /// </summary>
  19384. // public string continent_name { get; set; }
  19385. // /// <summary>
  19386. // ///
  19387. // /// </summary>
  19388. // public string subregion_name { get; set; }
  19389. // /// <summary>
  19390. // ///
  19391. // /// </summary>
  19392. // public string country_code2 { get; set; }
  19393. // /// <summary>
  19394. // ///
  19395. // /// </summary>
  19396. // public string country_code3 { get; set; }
  19397. // /// <summary>
  19398. // ///
  19399. // /// </summary>
  19400. // public string phone_code { get; set; }
  19401. //}
  19402. //public class CountriesInfo : BasicInfo
  19403. //{
  19404. // public List<CitiesInfo> c { get; set; }
  19405. //}
  19406. //public class CitiesInfo : BasicInfo
  19407. //{
  19408. // public List<AreaInfo> c { get; set; }
  19409. //}
  19410. //public class AreaInfo : BasicInfo
  19411. //{
  19412. // public List<AreaInfo> c { get; set; }
  19413. //}
  19414. //public class BasicInfo
  19415. //{
  19416. // public string code { get; set; }
  19417. // public string cn { get; set; }
  19418. // public string lv { get; set; }
  19419. // public string en { get; set; }
  19420. //}
  19421. #endregion
  19422. #region 查看邀请方
  19423. /// <summary>
  19424. /// 查看邀请方
  19425. /// 邀请方信息 Init
  19426. /// </summary>
  19427. /// <param name="dto"></param>
  19428. /// <returns></returns>
  19429. [HttpPost]
  19430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19431. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  19432. {
  19433. string sqlWhere = string.Empty;
  19434. if (!string.IsNullOrEmpty(dto.Search))
  19435. {
  19436. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  19437. }
  19438. string sql = string.Format($@"Select
  19439. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  19440. Id,
  19441. UnitName
  19442. From Res_InvitationOfficialActivityData
  19443. Where IsDel = 0
  19444. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  19445. RefAsync<int> total = 0;
  19446. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19447. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  19448. }
  19449. /// <summary>
  19450. /// 查看邀请方
  19451. /// 国家信息 Init
  19452. /// </summary>
  19453. /// <param name="dto"></param>
  19454. /// <returns></returns>
  19455. [HttpPost]
  19456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19457. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  19458. {
  19459. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  19460. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  19461. var diids = groupInfos.Select(it => it.Id).ToList();
  19462. List<string> countrys = new List<string>();
  19463. foreach (var item in country)
  19464. {
  19465. var data = _groupRepository.FormartTeamName(item);
  19466. var dataArray = _groupRepository.GroupSplitCountry(data);
  19467. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  19468. }
  19469. countrys = countrys.Distinct().ToList();
  19470. for (int i = 0; i < countrys.Count; i++)
  19471. {
  19472. string item = countrys[i];
  19473. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  19474. {
  19475. countrys.Remove(item);
  19476. i--;
  19477. }
  19478. }
  19479. RefAsync<int> total = 0;
  19480. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  19481. .Where(it => countrys.Contains(it.Name_CN))
  19482. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19483. .Select(it => new { id = it.Id, name = it.Name_CN })
  19484. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19485. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19486. }
  19487. /// <summary>
  19488. /// 查看邀请方
  19489. /// 城市信息 Init
  19490. /// </summary>
  19491. /// <param name="dto"></param>
  19492. /// <returns></returns>
  19493. [HttpPost]
  19494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19495. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  19496. {
  19497. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  19498. RefAsync<int> total = 0;
  19499. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  19500. .Where(it => it.CountriesId == dto.CountiesId)
  19501. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  19502. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  19503. .Select(it => new { id = it.Id, name = it.Name_CN })
  19504. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19505. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  19506. }
  19507. /// <summary>
  19508. /// 查看邀请方
  19509. /// 团组名称 Init
  19510. /// </summary>
  19511. /// <param name="dto"></param>
  19512. /// <returns></returns>
  19513. [HttpPost]
  19514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19515. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  19516. {
  19517. var watch = new Stopwatch();
  19518. watch.Start();
  19519. RefAsync<int> total = 0;
  19520. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  19521. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  19522. .Where((oa, di) => oa.IsDel == 0)
  19523. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  19524. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  19525. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  19526. .Distinct()
  19527. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19528. watch.Stop();
  19529. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  19530. }
  19531. /// <summary>
  19532. /// 查看邀请方
  19533. /// 团组 & 邀请方信息
  19534. /// </summary>
  19535. /// <param name="dto"></param>
  19536. /// <returns></returns>
  19537. [HttpPost]
  19538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19539. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  19540. {
  19541. var watch = new Stopwatch();
  19542. watch.Start();
  19543. RefAsync<int> total = 0;
  19544. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  19545. .AS("Grp_DelegationInfo")
  19546. .Includes(x => x.InvitingInfos)
  19547. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  19548. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  19549. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  19550. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  19551. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  19552. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  19553. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  19554. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  19555. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  19556. infos.ForEach(x =>
  19557. {
  19558. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  19559. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  19560. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  19561. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  19562. });
  19563. watch.Stop();
  19564. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  19565. }
  19566. #endregion
  19567. #region 报批行程
  19568. /// <summary>
  19569. /// 报批行程初始化
  19570. /// </summary>
  19571. /// <param name="dto"></param>
  19572. /// <returns></returns>
  19573. [HttpPost]
  19574. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  19575. {
  19576. const int chiNumber = 5;
  19577. var jw = JsonView(false);
  19578. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  19579. var group = groupList.First();
  19580. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  19581. group = groupList.First(x => x.Id == diid);
  19582. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19583. .Where(x => x.DiId == diid && x.IsDel == 0)
  19584. .ToArray();
  19585. var count = 1;
  19586. foreach (var item in blackCodeList)
  19587. {
  19588. if (string.IsNullOrWhiteSpace(item.Title))
  19589. {
  19590. item.Title = "未设置名称数据" + count;
  19591. }
  19592. count++;
  19593. };
  19594. if (group == null)
  19595. {
  19596. jw.Msg = "暂无团组!";
  19597. return Ok(jw);
  19598. }
  19599. var data = new
  19600. {
  19601. groupList = groupList.Select(x => new
  19602. {
  19603. x.TeamName,
  19604. x.Id
  19605. }),
  19606. content = new ArrayList(),
  19607. groupInfo = new
  19608. {
  19609. group.VisitDays,
  19610. group.TourCode,
  19611. group.VisitPNumber,
  19612. group.TeamName,
  19613. group.Id,
  19614. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  19615. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  19616. },
  19617. blackCodeList = blackCodeList.Select(x => new
  19618. {
  19619. x.Title,
  19620. x.Id
  19621. }),
  19622. FileTempList = new ArrayList()
  19623. {
  19624. new { Index = 1,FileName = "旧模板" },
  19625. new { Index = 2,FileName = "省外办" },
  19626. new { Index = 3,FileName = "市外办" },
  19627. }
  19628. };
  19629. var resultArr = new ArrayList();
  19630. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  19631. #region 默认不生成行程
  19632. //if (content.Count == 0)
  19633. //{
  19634. // var stay = "-";
  19635. // var cityPath = "-";
  19636. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19637. // .Where(x => x.DiId == diid && x.IsDel == 0)
  19638. // .ToList();
  19639. // //添加城市路径以及住宿地
  19640. // //黑屏代码数据
  19641. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  19642. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19643. // {
  19644. // jw = JsonView(true, "黑屏代码有误!", data);
  19645. // return Ok(jw);
  19646. // }
  19647. // data = data with
  19648. // {
  19649. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  19650. // {
  19651. // x.Title,
  19652. // x.Id,
  19653. // }).ToArray())
  19654. // };
  19655. // foreach (DataRow row in dtBlack.Rows)
  19656. // {
  19657. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19658. // {
  19659. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  19660. // return Ok(jw);
  19661. // }
  19662. // }
  19663. // //黑屏代码获取时间区间
  19664. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19665. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19666. // _sqlSugar.BeginTran();
  19667. // for (int i = 0; i < timeArr.Count; i++)
  19668. // {
  19669. // stay = "-";
  19670. // cityPath = "-";
  19671. // DateTime NewData = DateTime.Parse(timeArr[i]);
  19672. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19673. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19674. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19675. // if (tbSelect.Length > 0)
  19676. // {
  19677. // List<string> threeCodeStr = new List<string>();
  19678. // foreach (var item in tbSelect)
  19679. // {
  19680. // var threeCode = item["Three"].ToString() ?? "";
  19681. // if (threeCode.Length == 6)
  19682. // {
  19683. // var start = threeCode.Substring(0, 3);
  19684. // var end = threeCode.Substring(3, 3);
  19685. // if (threeCodeStr.Count == 0)
  19686. // {
  19687. // threeCodeStr.Add(start);
  19688. // threeCodeStr.Add(end);
  19689. // }
  19690. // else
  19691. // {
  19692. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19693. // {
  19694. // threeCodeStr.Add(end);
  19695. // }
  19696. // else
  19697. // {
  19698. // threeCodeStr.Add(start);
  19699. // threeCodeStr.Add(end);
  19700. // }
  19701. // }
  19702. // }
  19703. // }
  19704. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19705. // var last = threeCodeStr.Last();
  19706. // foreach (var item in threeCodeStr)
  19707. // {
  19708. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19709. // if (item.Equals(last))
  19710. // {
  19711. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19712. // }
  19713. // }
  19714. // cityPath = cityPath.Trim('-');
  19715. // }
  19716. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  19717. // appro.Diid = diid ?? -1;
  19718. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19719. // appro.Id = thisId;
  19720. // appro.CreateUserId = dto.UserId;
  19721. // appro.CreateTime = DateTime.Now;
  19722. // content.Add(appro);
  19723. // }
  19724. // _sqlSugar.CommitTran();
  19725. //}
  19726. #endregion
  19727. foreach (var x in content)
  19728. {
  19729. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  19730. if (chiList.Count < chiNumber)
  19731. {
  19732. for (int i = chiList.Count; i < chiNumber; i++)
  19733. {
  19734. chiList.Add(new Grp_ApprovalTravelDetails());
  19735. }
  19736. }
  19737. resultArr.Add(new
  19738. {
  19739. x.Id,
  19740. x.Date,
  19741. x.Diid,
  19742. chiList = chiList.Select(x1 => new
  19743. {
  19744. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19745. x1.Details,
  19746. x1.ParentId,
  19747. x1.Id
  19748. })
  19749. });
  19750. }
  19751. data = data with
  19752. {
  19753. content = resultArr,
  19754. };
  19755. jw = JsonView(true, "获取成功!", data);
  19756. return Ok(jw);
  19757. }
  19758. /// <summary>
  19759. /// 报批行程删除
  19760. /// </summary>
  19761. /// <param name="dto"></param>
  19762. /// <returns></returns>
  19763. [HttpPost]
  19764. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  19765. {
  19766. var jw = JsonView(false);
  19767. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19768. if (group == null)
  19769. {
  19770. jw.Msg = "团组参数有误!";
  19771. return Ok(jw);
  19772. }
  19773. try
  19774. {
  19775. _sqlSugar.BeginTran();
  19776. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  19777. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  19778. {
  19779. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19780. DeleteUserId = dto.uesrId,
  19781. IsDel = 1
  19782. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  19783. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  19784. {
  19785. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19786. DeleteUserId = dto.uesrId,
  19787. IsDel = 1
  19788. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  19789. _sqlSugar.CommitTran();
  19790. jw = JsonView(true, "删除成功");
  19791. }
  19792. catch (Exception ex)
  19793. {
  19794. jw = JsonView(false, ex.Message);
  19795. }
  19796. return Ok(jw);
  19797. }
  19798. /// <summary>
  19799. /// 报批行程保存
  19800. /// </summary>
  19801. /// <param name="dto"></param>
  19802. /// <returns></returns>
  19803. [HttpPost]
  19804. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  19805. {
  19806. var jw = JsonView(false);
  19807. var Find = dto.Arr.Find(x => x.id == 0);
  19808. if (Find != null)
  19809. {
  19810. jw.Msg = "生成的ID为0!";
  19811. return Ok(jw);
  19812. }
  19813. foreach (var item in dto.Arr)
  19814. {
  19815. foreach (var chi in item.chiList)
  19816. {
  19817. if (chi.parentId == 0)
  19818. {
  19819. chi.parentId = item.id;
  19820. }
  19821. }
  19822. }
  19823. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  19824. _sqlSugar.BeginTran();
  19825. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  19826. {
  19827. var parentIds = dto.Arr.Select(x => x.id).ToList();
  19828. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  19829. {
  19830. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19831. DeleteUserId = dto.UserId,
  19832. IsDel = 1
  19833. }).ExecuteCommand();
  19834. }
  19835. try
  19836. {
  19837. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  19838. {
  19839. CreateTime = DateTime.Now,
  19840. CreateUserId = dto.UserId,
  19841. Details = x.details,
  19842. ParentId = x.parentId,
  19843. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19844. Remark = "",
  19845. IsDel = 0
  19846. }).ToList()).ExecuteCommand();
  19847. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  19848. {
  19849. Id = x.id,
  19850. Details = x.details,
  19851. ParentId = x.parentId,
  19852. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19853. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  19854. {
  19855. Details = x.Details,
  19856. ParentId = x.ParentId,
  19857. Time = x.Time
  19858. }).ExecuteCommand();
  19859. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  19860. {
  19861. Id = x.id,
  19862. Date = x.date,
  19863. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  19864. {
  19865. Date = x.Date
  19866. }).ExecuteCommand();
  19867. _sqlSugar.CommitTran();
  19868. jw = JsonView(true, "保存成功!");
  19869. }
  19870. catch (Exception ex)
  19871. {
  19872. _sqlSugar.RollbackTran();
  19873. jw = JsonView(false, "保存失败!" + ex.Message);
  19874. }
  19875. return Ok(jw);
  19876. }
  19877. /// <summary>
  19878. /// 报批行程生成
  19879. /// </summary>
  19880. /// <param name="dto"></param>
  19881. /// <returns></returns>
  19882. [HttpPost]
  19883. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  19884. {
  19885. var jw = JsonView(false);
  19886. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19887. if (group == null)
  19888. {
  19889. jw.Msg = "暂无该团组!";
  19890. return Ok(jw);
  19891. }
  19892. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  19893. //黑屏代码数据
  19894. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  19895. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19896. {
  19897. jw.Msg = "黑屏代码有误!";
  19898. return Ok(jw);
  19899. }
  19900. foreach (DataRow row in dtBlack.Rows)
  19901. {
  19902. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19903. {
  19904. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  19905. return Ok(jw);
  19906. }
  19907. }
  19908. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  19909. var resultArr = new ArrayList();
  19910. //if (officialActivitiesArr.Count == 0)
  19911. //{
  19912. // jw.Msg = "暂无公务出访信息!";
  19913. // return Ok(jw);
  19914. //}
  19915. try
  19916. {
  19917. _sqlSugar.BeginTran();
  19918. DeleteApprovalJourney(new
  19919. Domain.Dtos.Groups.DeleteApprovalJourney
  19920. {
  19921. Diid = dto.Diid,
  19922. uesrId = dto.Userid
  19923. });
  19924. var stay = "-";
  19925. var cityPath = "-";
  19926. var arriveCountry = string.Empty;
  19927. //添加城市路径以及住宿地
  19928. //黑屏代码获取时间区间
  19929. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19930. var empty = "【未收入该三字码!请机票同事录入】";
  19931. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19932. #region 配置公务活动时间
  19933. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  19934. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  19935. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  19936. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  19937. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  19938. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19939. {
  19940. 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" }),
  19941. 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"}),
  19942. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19943. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  19944. };
  19945. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19946. {
  19947. 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" }),
  19948. 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"}),
  19949. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19950. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  19951. };
  19952. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  19953. {
  19954. 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" }),
  19955. 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"}),
  19956. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  19957. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  19958. };
  19959. #endregion
  19960. var nextDayNum = 0;
  19961. for (int i = 0; i < timeArr.Count; i++)
  19962. {
  19963. stay = "-";
  19964. cityPath = "-";
  19965. var chiarr = new List<Grp_ApprovalTravelDetails>();
  19966. DateTime NewData = DateTime.Parse(timeArr[i]);
  19967. //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();
  19968. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19969. if (nextDayNum > 0)
  19970. {
  19971. nextDayNum--;
  19972. }
  19973. if (tbSelect.Length > 0)
  19974. {
  19975. List<string> threeCodeStr = new List<string>();
  19976. bool isTrade = false;
  19977. string trip = string.Empty;
  19978. foreach (var item in tbSelect)
  19979. {
  19980. if (nextDayNum == 0)
  19981. {
  19982. nextDayNum = Convert.ToInt32(item["Sign"]);
  19983. }
  19984. var airStartTime = item["StartTime"].ToString() ?? "0000";
  19985. var airEndTime = item["EndTime"].ToString() ?? "0000";
  19986. var takeOffTime = DateTime.Parse(timeArr[i]);
  19987. var fallToTime = DateTime.Parse(timeArr[i]);
  19988. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  19989. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  19990. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  19991. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  19992. if (nextDayNum > 0)
  19993. {
  19994. fallToTime = fallToTime.AddDays(nextDayNum);
  19995. }
  19996. trip = string.Empty;
  19997. var start = string.Empty;
  19998. var end = string.Empty;
  19999. var threeCode = item["Three"].ToString() ?? "";
  20000. if (threeCode.Length == 6)
  20001. {
  20002. start = threeCode.Substring(0, 3);
  20003. end = threeCode.Substring(3, 3);
  20004. if (threeCodeStr.Count == 0)
  20005. {
  20006. threeCodeStr.Add(start);
  20007. threeCodeStr.Add(end);
  20008. }
  20009. else
  20010. {
  20011. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20012. {
  20013. threeCodeStr.Add(end);
  20014. }
  20015. else
  20016. {
  20017. threeCodeStr.Add(start);
  20018. threeCodeStr.Add(end);
  20019. }
  20020. }
  20021. }
  20022. //处理机票信息
  20023. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  20024. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  20025. if (start_Object == null)
  20026. {
  20027. start_Object = new Res_ThreeCode()
  20028. {
  20029. AirPort = empty,
  20030. AirPort_En = empty,
  20031. City = empty,
  20032. Country = empty,
  20033. Four = empty,
  20034. Three = empty,
  20035. };
  20036. }
  20037. if (end_Object == null)
  20038. {
  20039. end_Object = new Res_ThreeCode()
  20040. {
  20041. AirPort = empty,
  20042. AirPort_En = empty,
  20043. City = empty,
  20044. Country = empty,
  20045. Four = empty,
  20046. Three = empty,
  20047. };
  20048. }
  20049. //机型判断
  20050. string airModel = item["AirModel"].ToString();
  20051. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  20052. string flightTime = item["FlightTime"].ToString();
  20053. flightTime = ParseBlackTime(flightTime);
  20054. //航班号
  20055. string flightcode = item["Fliagtcode"].ToString();
  20056. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  20057. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  20058. if (aircompany == null)
  20059. {
  20060. aircompany = new Res_AirCompany
  20061. {
  20062. CnName = hsEmpty,
  20063. EnName = hsEmpty,
  20064. ShortCode = hsEmpty,
  20065. };
  20066. }
  20067. //航班前公务安排
  20068. if (tbSelect.First().Equals(item) && i != 0)
  20069. {
  20070. foreach (var takeoff in takeoffTimes)
  20071. {
  20072. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  20073. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  20074. {
  20075. foreach (var addTime in takeoff.Item2)
  20076. {
  20077. chiarr.Add(new Grp_ApprovalTravelDetails
  20078. {
  20079. Time = addTime,
  20080. CreateTime = DateTime.Now,
  20081. CreateUserId = dto.Userid,
  20082. ParentId = 0,
  20083. Details = "公务活动"
  20084. });
  20085. }
  20086. break;
  20087. }
  20088. }
  20089. }
  20090. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  20091. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  20092. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  20093. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  20094. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  20095. if (isTrade)
  20096. {
  20097. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  20098. trip += "(转机不出机场)。";
  20099. }
  20100. //else
  20101. //{
  20102. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  20103. //}
  20104. chiarr.Add(new Grp_ApprovalTravelDetails
  20105. {
  20106. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  20107. CreateTime = DateTime.Now,
  20108. CreateUserId = dto.Userid,
  20109. ParentId = 0,
  20110. Details = trip
  20111. });
  20112. //最后一条到达的时间安排公务
  20113. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  20114. {
  20115. bool isCheckCountry = false;
  20116. if (end_Object.Country != arriveCountry)
  20117. {
  20118. arriveCountry = end_Object.Country;
  20119. isCheckCountry = true;
  20120. }
  20121. if (nextDayNum == 0)
  20122. {
  20123. //需要入境的情况
  20124. if (isCheckCountry)
  20125. {
  20126. foreach (var fallTime in fallTimesCheckCountry)
  20127. {
  20128. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20129. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20130. {
  20131. foreach (var addTime in fallTime.Item2)
  20132. {
  20133. chiarr.Add(new Grp_ApprovalTravelDetails
  20134. {
  20135. Time = addTime,
  20136. CreateTime = DateTime.Now,
  20137. CreateUserId = dto.Userid,
  20138. ParentId = 0,
  20139. Details = "公务活动"
  20140. });
  20141. }
  20142. break;
  20143. }
  20144. }
  20145. }
  20146. else
  20147. {
  20148. foreach (var fallTime in fallTimesNotCheckCountry)
  20149. {
  20150. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  20151. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  20152. {
  20153. foreach (var addTime in fallTime.Item2)
  20154. {
  20155. chiarr.Add(new Grp_ApprovalTravelDetails
  20156. {
  20157. Time = addTime,
  20158. CreateTime = DateTime.Now,
  20159. CreateUserId = dto.Userid,
  20160. ParentId = 0,
  20161. Details = "公务活动"
  20162. });
  20163. }
  20164. break;
  20165. }
  20166. }
  20167. }
  20168. }
  20169. }
  20170. }
  20171. //添加乘车语句
  20172. //chiarr.Add(new Grp_ApprovalTravelDetails
  20173. //{
  20174. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  20175. // CreateTime = DateTime.Now,
  20176. // CreateUserId = dto.Userid,
  20177. // ParentId = 0,
  20178. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  20179. //});
  20180. //if (i != timeArr.Count - 1)
  20181. //{
  20182. // fallToTime = fallToTime.AddHours(2.5);
  20183. // foreach (var item in Times)
  20184. // {
  20185. // //排列公务时间
  20186. // if (fallToTime.Hour < item.Item1)
  20187. // {
  20188. // chiarr.Add(new Grp_ApprovalTravelDetails
  20189. // {
  20190. // Time = $"{item.Item2} - {item.Item3}",
  20191. // CreateTime = DateTime.Now,
  20192. // CreateUserId = dto.Userid,
  20193. // ParentId = 0,
  20194. // Details = "公务活动"
  20195. // });
  20196. // }
  20197. // }
  20198. //}
  20199. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20200. var last = threeCodeStr.Last();
  20201. foreach (var item in threeCodeStr)
  20202. {
  20203. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20204. if (item.Equals(last))
  20205. {
  20206. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20207. }
  20208. }
  20209. cityPath = cityPath.Trim('-');
  20210. }
  20211. else
  20212. {
  20213. foreach (var item in Times)
  20214. {
  20215. chiarr.Add(new Grp_ApprovalTravelDetails
  20216. {
  20217. Time = $"{item.Item2} - {item.Item3}",
  20218. CreateTime = DateTime.Now,
  20219. CreateUserId = dto.Userid,
  20220. ParentId = 0,
  20221. Details = "公务活动"
  20222. });
  20223. }
  20224. }
  20225. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20226. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20227. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  20228. appro.Diid = dto.Diid;
  20229. appro.CreateUserId = dto.Userid;
  20230. appro.CreateTime = DateTime.Now;
  20231. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20232. appro.Id = thisId;
  20233. //foreach (var item in gwinfo)
  20234. //{
  20235. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  20236. // chi.Details = "拜访" + item.Client;
  20237. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  20238. // {
  20239. // chi.Details += "," + item.ReqSample;
  20240. // }
  20241. // chi.ParentId = thisId;
  20242. // chi.Time = item.Time;
  20243. // chiarr.Add(chi);
  20244. //}
  20245. if (chiarr.Count < 6)
  20246. {
  20247. for (int j = chiarr.Count; j < 6; j++)
  20248. {
  20249. chiarr.Add(new
  20250. Grp_ApprovalTravelDetails());
  20251. }
  20252. }
  20253. resultArr.Add(new
  20254. {
  20255. appro.Id,
  20256. appro.Date,
  20257. appro.Diid,
  20258. chiList = chiarr.Select(x1 => new
  20259. {
  20260. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20261. x1.Details,
  20262. x1.ParentId,
  20263. x1.Id
  20264. })
  20265. });
  20266. }
  20267. _sqlSugar.CommitTran();
  20268. jw = JsonView(true, "生成成功!", resultArr);
  20269. }
  20270. catch (Exception ex)
  20271. {
  20272. jw.Code = 400;
  20273. jw.Msg = "生成失败!" + ex.Message;
  20274. }
  20275. return Ok(jw);
  20276. }
  20277. /// <summary>
  20278. /// 报批行程word导出
  20279. /// </summary>
  20280. /// <param name="dto"></param>
  20281. /// <returns></returns>
  20282. [HttpPost]
  20283. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  20284. {
  20285. var jw = JsonView(false);
  20286. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  20287. if (group == null)
  20288. {
  20289. jw.Msg = "暂无该团组!";
  20290. return Ok(jw);
  20291. }
  20292. //模板路径
  20293. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  20294. var fileName = string.Empty;
  20295. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  20296. bool bold = false;
  20297. if (dto.FileIndex == 1)
  20298. {
  20299. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  20300. }
  20301. else if (dto.FileIndex == 2)
  20302. {
  20303. fileName = "省外办-报批.docx";
  20304. bold = false;
  20305. titleFont = "方正黑体简体";
  20306. timeFont = "Times New Roman";
  20307. contentFont = "方正仿宋_GBK";
  20308. }
  20309. else if (dto.FileIndex == 3)
  20310. {
  20311. fileName = "市外办-报批.docx";
  20312. titleFont = "方正黑体简体";
  20313. timeFont = "Times New Roman";
  20314. contentFont = "方正仿宋简体";
  20315. }
  20316. tempPath = tempPath + fileName;
  20317. //载入模板
  20318. Document doc = new Document(tempPath);
  20319. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20320. //获取所填表格的序数
  20321. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20322. Aspose.Words.Tables.Row titleRowClone = null;
  20323. Aspose.Words.Tables.Row CenterRowClone = null;
  20324. int index = 0;
  20325. int indexChi = 0;
  20326. int SetIndex = 0;
  20327. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  20328. //获取数据,放到datatable
  20329. foreach (var item in ApprovalTravelArr)
  20330. {
  20331. if (index > 0)
  20332. {
  20333. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  20334. tableOne.AppendChild(titleRowClone);
  20335. }
  20336. var textTime = item.Date;
  20337. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  20338. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  20339. SetIndex++;
  20340. if (ChiRep.Count > 0)
  20341. {
  20342. foreach (var itemChi in ChiRep)
  20343. {
  20344. var txtTime = itemChi.Time;
  20345. var txtDetail = itemChi.Details;
  20346. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  20347. {
  20348. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  20349. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20350. //indexChi++;
  20351. //SetIndex++;
  20352. break;
  20353. }
  20354. if (indexChi > 0)
  20355. {
  20356. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20357. tableOne.AppendChild(CenterRowClone);
  20358. }
  20359. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  20360. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  20361. indexChi++;
  20362. SetIndex++;
  20363. }
  20364. }
  20365. //else
  20366. //{
  20367. // if (indexChi > 0)
  20368. // {
  20369. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  20370. // tableOne.AppendChild(CenterRowClone);
  20371. // }
  20372. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  20373. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  20374. // indexChi++;
  20375. // SetIndex++;
  20376. //}
  20377. index++;
  20378. }
  20379. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  20380. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20381. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  20382. jw.Code = 200;
  20383. jw.Msg = "";
  20384. return Ok(jw);
  20385. }
  20386. private string ParseBlackTime(string time)
  20387. {
  20388. // 匹配可能只有分钟的情况
  20389. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  20390. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  20391. if (match.Success)
  20392. {
  20393. string hours = match.Groups[1].Value;
  20394. string minutes = match.Groups[2].Value;
  20395. // 如果小时部分为空,则只显示分钟
  20396. if (string.IsNullOrEmpty(hours))
  20397. {
  20398. return $"{minutes}分钟";
  20399. }
  20400. // 如果分钟部分为空,则只显示小时
  20401. else if (string.IsNullOrEmpty(minutes))
  20402. {
  20403. return $"{hours}小时";
  20404. }
  20405. // 否则显示完整格式
  20406. else
  20407. {
  20408. return $"{hours}小时{minutes}分钟";
  20409. }
  20410. }
  20411. else
  20412. {
  20413. return "未知时长";
  20414. }
  20415. }
  20416. private string intToString(int numberVal)
  20417. {
  20418. string numberval = numberVal.ToString();
  20419. Dictionary<char, string> Number = new Dictionary<char, string>();
  20420. Number.Add('1', "一");
  20421. Number.Add('2', "二");
  20422. Number.Add('3', "三");
  20423. Number.Add('4', "四");
  20424. Number.Add('5', "五");
  20425. Number.Add('6', "六");
  20426. Number.Add('7', "七");
  20427. Number.Add('8', "八");
  20428. Number.Add('9', "九");
  20429. string stringNumberVal = string.Empty;
  20430. for (int i = 0; i < numberval.Length; i++)
  20431. {
  20432. if (i == 0)
  20433. {
  20434. stringNumberVal += Number[numberval[i]];
  20435. }
  20436. else if (i >= 1)
  20437. {
  20438. if (numberval[i] == '0')
  20439. {
  20440. stringNumberVal = "十";
  20441. }
  20442. else
  20443. {
  20444. stringNumberVal += "十" + Number[numberval[i]];
  20445. }
  20446. }
  20447. }
  20448. return stringNumberVal;
  20449. }
  20450. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  20451. {
  20452. //获取table中的某个单元格,从0开始
  20453. Cell lshCell = table.Rows[rows].Cells[cells];
  20454. //将单元格中段落移除
  20455. foreach (Paragraph item in lshCell.Paragraphs)
  20456. {
  20457. lshCell.Paragraphs.Remove(item);
  20458. }
  20459. if (val.Contains("\r\n"))
  20460. {
  20461. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  20462. foreach (var item in spArr)
  20463. {
  20464. //新建一个段落
  20465. Paragraph p = new Paragraph(doc);
  20466. var r = new Run(doc, item);
  20467. //设置字体
  20468. if (!string.IsNullOrEmpty(font))
  20469. {
  20470. r.Font.Name = font;
  20471. }
  20472. r.Font.Bold = bold;
  20473. //把设置的值赋给之前新建的段落
  20474. p.AppendChild(r);
  20475. //将此段落加到单元格内
  20476. lshCell.AppendChild(p);
  20477. }
  20478. }
  20479. else
  20480. {
  20481. //新建一个段落
  20482. Paragraph p = new Paragraph(doc);
  20483. var r = new Run(doc, val);
  20484. //设置字体
  20485. if (!string.IsNullOrEmpty(font))
  20486. {
  20487. r.Font.Name = font;
  20488. }
  20489. r.Font.Bold = bold;
  20490. //把设置的值赋给之前新建的段落
  20491. p.AppendChild(r);
  20492. //将此段落加到单元格内
  20493. lshCell.AppendChild(p);
  20494. }
  20495. }
  20496. //[HttpPost]
  20497. //public async Task<IActionResult> ServerHttp(string paramStr)
  20498. //{
  20499. // paramStr = paramStr.TrimEnd('\'');
  20500. // paramStr = paramStr.TrimStart('\'');
  20501. // JsonView jw = JsonView(false);
  20502. // JObject param = JObject.Parse(paramStr);
  20503. // if (!param.ContainsKey("url"))
  20504. // {
  20505. // jw.Msg = "url null";
  20506. // return Ok(jw);
  20507. // }
  20508. // string url = param["url"]!.ToString();
  20509. // var methon = "get";
  20510. // Dictionary<string, string> headValues = null;
  20511. // string bodyStr = string.Empty;
  20512. // if (param.ContainsKey("methon"))
  20513. // {
  20514. // methon = param["methon"]!.ToString().ToLower();
  20515. // }
  20516. // if (param.ContainsKey("header"))
  20517. // {
  20518. // var header = param["header"]!.ToString();
  20519. // JObject headerJobject = JObject.Parse(header);
  20520. // headValues = new Dictionary<string, string>();
  20521. // foreach (JProperty item in headerJobject.Properties())
  20522. // {
  20523. // var value = item.Value.ToString();
  20524. // var head = item.Path;
  20525. // headValues.Add(head, value);
  20526. // }
  20527. // }
  20528. // HttpClient client = new HttpClient();
  20529. // string responseString = string.Empty;
  20530. // StringContent content = null;
  20531. // if (headValues != null)
  20532. // {
  20533. // foreach (var item in headValues.Keys)
  20534. // {
  20535. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  20536. // {
  20537. // if (param.ContainsKey("body"))
  20538. // {
  20539. // bodyStr = param["body"]!.ToString();
  20540. // }
  20541. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  20542. // }
  20543. // else
  20544. // {
  20545. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  20546. // }
  20547. // }
  20548. // }
  20549. // try
  20550. // {
  20551. // if (methon == "get")
  20552. // {
  20553. // responseString = await client.GetStringAsync(url);
  20554. // }
  20555. // else if (methon == "post")
  20556. // {
  20557. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  20558. // {
  20559. // Content = content
  20560. // };
  20561. // var response = await client.SendAsync(request);
  20562. // try
  20563. // {
  20564. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  20565. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  20566. // {
  20567. // using (StreamReader reader = new StreamReader(gzipStream))
  20568. // {
  20569. // responseString = await reader.ReadToEndAsync();
  20570. // }
  20571. // }
  20572. // }
  20573. // catch (Exception)
  20574. // {
  20575. // responseString = await response.Content.ReadAsStringAsync();
  20576. // }
  20577. // }
  20578. // else
  20579. // {
  20580. // responseString = "methon error";
  20581. // }
  20582. // jw = JsonView(true, "success", responseString);
  20583. // }
  20584. // catch (Exception ex)
  20585. // {
  20586. // jw.Msg = "error " + ex.Message;
  20587. // jw.Data = ex.StackTrace;
  20588. // }
  20589. // finally
  20590. // {
  20591. // client.Dispose();
  20592. // }
  20593. // return Ok(jw);
  20594. //}
  20595. #endregion
  20596. #region 团组接待意见调查
  20597. /// <summary>
  20598. /// 团组接待意见调查 - 信息管理
  20599. /// 基础数据(团组)
  20600. /// </summary>
  20601. /// <returns></returns>
  20602. [HttpGet]
  20603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20604. public async Task<IActionResult> OpinionaireInit()
  20605. {
  20606. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  20607. .Select(x => new
  20608. {
  20609. x.Id,
  20610. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  20611. })
  20612. .OrderByDescending(x => x.Id)
  20613. .ToListAsync();
  20614. return Ok(JsonView(groupData, groupData.Count));
  20615. }
  20616. /// <summary>
  20617. /// 团组接待意见调查 - 信息管理
  20618. /// 列表
  20619. /// </summary>
  20620. /// <param name="groupId"></param>
  20621. /// <returns></returns>
  20622. [HttpGet("{groupId}")]
  20623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20624. public async Task<IActionResult> OpinionaireManageList(int groupId)
  20625. {
  20626. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20627. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  20628. .Select(x => new
  20629. {
  20630. x.Id,
  20631. x.TourGuideName,
  20632. x.CityName,
  20633. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  20634. x.CreateTime
  20635. })
  20636. .OrderBy(x => x.Id)
  20637. .ToListAsync();
  20638. return Ok(JsonView(data));
  20639. }
  20640. /// <summary>
  20641. /// 团组接待意见调查 - 信息管理
  20642. /// 保存
  20643. /// </summary>
  20644. /// <param name="dto"></param>
  20645. /// <returns></returns>
  20646. [HttpPost]
  20647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20648. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  20649. {
  20650. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20651. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20652. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20653. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  20654. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  20655. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  20656. _opinionaireRep.BeginTran();
  20657. if (addData != null && addData.Count > 0)
  20658. {
  20659. foreach (var item in addData)
  20660. {
  20661. item.CreateUserId = currUserInfo.UserId;
  20662. item.DiId = dto.DiId;
  20663. }
  20664. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  20665. }
  20666. if (updData != null && updData.Count > 0)
  20667. {
  20668. var upd = await _opinionaireRep._sqlSugar
  20669. .Updateable(updData)
  20670. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  20671. .WhereColumns(x => new { x.Id })
  20672. .ExecuteCommandAsync();
  20673. }
  20674. _opinionaireRep.CommitTran();
  20675. return Ok(JsonView("操作成功!"));
  20676. }
  20677. /// <summary>
  20678. /// 团组接待意见调查 - 信息管理
  20679. /// 删除
  20680. /// </summary>
  20681. /// <param name="id"></param>
  20682. /// <returns></returns>
  20683. [HttpDelete("{id}")]
  20684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20685. public async Task<IActionResult> OpinionaireManageDel(int id)
  20686. {
  20687. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20688. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20689. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  20690. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  20691. if (!del) return Ok(JsonView("操作失败!"));
  20692. return Ok(JsonView("操作成功!"));
  20693. }
  20694. /// <summary>
  20695. /// 团组接待意见调查 - 用户
  20696. /// 列表
  20697. /// </summary>
  20698. /// <param name="diId"></param>
  20699. /// <returns></returns>
  20700. [HttpGet("{diId}")]
  20701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20702. public async Task<IActionResult> OpinionaireUserList(int diId)
  20703. {
  20704. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20705. var sql = string.Format(@"
  20706. SELECT
  20707. o.Id,
  20708. o.DiId,
  20709. di.TeamName AS 'GroupName',
  20710. di.VisitPNumber AS 'PeopleNumber',
  20711. di.ClientName AS 'LeadGroup',
  20712. di.VisitCountry AS 'Travel',
  20713. di.VisitDays AS 'Days',
  20714. o.CityName,
  20715. o.TourGuideName,
  20716. o.Catering,
  20717. o.CateringReason,
  20718. o.Stay,
  20719. o.StayReason,
  20720. o.[Route],
  20721. o.RouteReason,
  20722. o.OfficialActivity,
  20723. o.OfficialActivityReason,
  20724. o.TourGuide,
  20725. o.TourGuideReason,
  20726. o.[Translate],
  20727. o.TranslateReason,
  20728. o.Trip,
  20729. o.TripReason,
  20730. o.ESFileName,
  20731. o.SignatureDate,
  20732. o.Remark
  20733. FROM
  20734. Grp_Opinionaire o
  20735. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  20736. WHERE
  20737. o.IsDel = 0
  20738. AND o.DiId = {0}
  20739. ORDER BY
  20740. o.Id ASC", diId);
  20741. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  20742. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  20743. return Ok(JsonView(data));
  20744. }
  20745. /// <summary>
  20746. /// 团组接待意见调查 - 用户
  20747. /// 保存
  20748. /// </summary>
  20749. /// <param name="dto"></param>
  20750. /// <returns></returns>
  20751. [HttpPost]
  20752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20753. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  20754. {
  20755. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  20756. foreach (var item in dto)
  20757. {
  20758. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  20759. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  20760. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  20761. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  20762. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  20763. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  20764. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  20765. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  20766. }
  20767. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  20768. if (!Directory.Exists(filePathBase))
  20769. {
  20770. Directory.CreateDirectory(filePathBase);
  20771. }
  20772. #region 上传文件
  20773. var filePaths = new List<string>();
  20774. foreach (var item in dto)
  20775. {
  20776. var file = item.File;
  20777. // 将文件保存到指定位置
  20778. var filePath = Path.Combine(filePathBase, file.FileName);
  20779. using (var stream = new FileStream(filePath, FileMode.Create))
  20780. {
  20781. await file.CopyToAsync(stream);
  20782. }
  20783. //验证文件是否上传成功
  20784. if (!System.IO.File.Exists(filePath))
  20785. {
  20786. foreach (var filePathStr in filePaths)
  20787. {
  20788. System.IO.File.Delete(filePathStr);
  20789. }
  20790. return Ok(JsonView(false, "文件上传失败!"));
  20791. }
  20792. item.ESFileName = file.FileName;
  20793. }
  20794. #endregion
  20795. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  20796. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  20797. .UpdateColumns(x => new
  20798. {
  20799. x.Catering,
  20800. x.CateringReason,
  20801. x.Stay,
  20802. x.StayReason,
  20803. x.Route,
  20804. x.RouteReason,
  20805. x.OfficialActivity,
  20806. x.OfficialActivityReason,
  20807. x.TourGuide,
  20808. x.TourGuideReason,
  20809. x.Translate,
  20810. x.TranslateReason,
  20811. x.Trip,
  20812. x.TripReason,
  20813. x.ESFileName,
  20814. x.SignatureDate,
  20815. x.Remark
  20816. })
  20817. .WhereColumns(x => new { x.Id })
  20818. .ExecuteCommandAsync();
  20819. if (upd < 1)
  20820. {
  20821. foreach (var filePathStr in filePaths)
  20822. {
  20823. System.IO.File.Delete(filePathStr);
  20824. }
  20825. return Ok(JsonView(false));
  20826. }
  20827. return Ok(JsonView(true));
  20828. }
  20829. #endregion
  20830. #region 团组餐厅相关信息
  20831. /// <summary>
  20832. /// 团组相关餐厅信息
  20833. /// 基础数据(团组)
  20834. /// </summary>
  20835. /// <returns></returns>
  20836. [HttpGet]
  20837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20838. public async Task<IActionResult> RestaurantInit()
  20839. {
  20840. return Ok(await _restaurantRep.InitAsync());
  20841. }
  20842. /// <summary>
  20843. /// 团组相关餐厅信息
  20844. /// Item
  20845. /// </summary>
  20846. /// <param name="dto"></param>
  20847. /// <returns></returns>
  20848. [HttpPost]
  20849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20850. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  20851. {
  20852. int portType = dto.PortType,
  20853. groupId = dto.GroupId;
  20854. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20855. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20856. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  20857. }
  20858. /// <summary>
  20859. /// 团组相关餐厅信息
  20860. /// List
  20861. /// </summary>
  20862. /// <param name="dto"></param>
  20863. /// <returns></returns>
  20864. [HttpPost]
  20865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20866. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  20867. {
  20868. int portType = dto.PortType,
  20869. groupId = dto.GroupId;
  20870. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20871. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20872. var sql = string.Format(@" SELECT
  20873. ri.Id,
  20874. ri.GroupId,
  20875. ri.Date,
  20876. ri.StartTime,
  20877. ri.EndTime,
  20878. CASE WHEN ri.Type = 1 THEN '早餐'
  20879. WHEN ri.Type = 2 THEN '午餐'
  20880. WHEN ri.Type = 3 THEN '晚餐'
  20881. ELSE '其他'
  20882. END AS 'Type',
  20883. ri.Name,
  20884. ri.Address,
  20885. ri.Tel,
  20886. ri.Remark,
  20887. ri.CreateTime,
  20888. u.CnName AS CreateUserName
  20889. FROM
  20890. Grp_RestaurantInfo ri
  20891. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  20892. WHERE
  20893. ri.IsDel = 0
  20894. AND ri.GroupId = {0}
  20895. ORDER BY
  20896. ri.Date ASC
  20897. ", groupId);
  20898. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  20899. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  20900. return Ok(JsonView(infos));
  20901. }
  20902. /// <summary>
  20903. /// 团组相关餐厅信息
  20904. /// Info
  20905. /// </summary>
  20906. /// <param name="dto"></param>
  20907. /// <returns></returns>
  20908. [HttpPost]
  20909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20910. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  20911. {
  20912. int portType = dto.PortType,
  20913. id = dto.Id;
  20914. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20915. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20916. return Ok(await _restaurantRep.InfoAsync(portType, id));
  20917. }
  20918. /// <summary>
  20919. /// 团组相关餐厅信息
  20920. /// Op
  20921. /// </summary>
  20922. /// <param name="dto"></param>
  20923. /// <returns></returns>
  20924. [HttpPost]
  20925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20926. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  20927. {
  20928. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20929. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20930. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  20931. return Ok(await _restaurantRep.OpAsync(dto));
  20932. }
  20933. /// <summary>
  20934. /// 团组相关餐厅信息
  20935. /// Del
  20936. /// </summary>
  20937. /// <param name="dto"></param>
  20938. /// <returns></returns>
  20939. [HttpPost]
  20940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20941. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  20942. {
  20943. int userId = dto.DeleteUserId;
  20944. var id = dto.Id;
  20945. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20946. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20947. return Ok(await _restaurantRep.DelAsync(dto));
  20948. }
  20949. #endregion
  20950. // /// <summary>
  20951. // ///
  20952. // /// </summary>
  20953. // /// <param name="_dto"></param>
  20954. // /// <returns></returns>
  20955. // [HttpPost]
  20956. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20957. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20958. // {
  20959. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20960. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  20961. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  20962. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20963. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  20964. // dic_psg.Add("客人", 974);
  20965. // dic_psg.Add("司机", 975);
  20966. // dic_psg.Add("导游", 976);
  20967. // dic_psg.Add("公司内部人员", 977);
  20968. // dic_psg.Add("司机/导游/公司内部人员", 978);
  20969. // foreach (var item in list_visa)
  20970. // {
  20971. // Grp_VisaInfo temp = new Grp_VisaInfo();
  20972. // temp.Id = item.Id;
  20973. // temp.DIId = item.DIId;
  20974. // temp.VisaClient = item.VisaClient;
  20975. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  20976. // temp.VisaCurrency = item.VisaCurrency;
  20977. // temp.IsThird = item.IsThird;
  20978. // if (dic_psg.ContainsKey(item.PassengerType))
  20979. // {
  20980. // temp.PassengerType = dic_psg[item.PassengerType];
  20981. // }
  20982. // else {
  20983. // temp.PassengerType = -1;
  20984. // }
  20985. // temp.VisaNumber = item.VisaNumber;
  20986. // temp.VisaFreeNumber = item.VisaFreeNumber;
  20987. // temp.CreateUserId = item.Operators;
  20988. // DateTime dt_ct;
  20989. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  20990. // if (b_ct)
  20991. // {
  20992. // temp.CreateTime = dt_ct;
  20993. // }
  20994. // else
  20995. // {
  20996. // temp.CreateTime = DateTime.Now;
  20997. // }
  20998. // temp.DeleteTime = "";
  20999. // temp.DeleteUserId = 0;
  21000. // temp.Remark = item.Remark;
  21001. // if (string.IsNullOrEmpty(temp.Remark)) {
  21002. // temp.Remark = "";
  21003. // }
  21004. // temp.IsDel = item.IsDel;
  21005. // temp.VisaDescription = item.VisaAttachment;
  21006. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  21007. //([Id]
  21008. // ,[DIId]
  21009. // ,[VisaClient]
  21010. // ,[VisaPrice]
  21011. // ,[VisaCurrency]
  21012. // ,[IsThird]
  21013. // ,[PassengerType]
  21014. // ,[VisaNumber]
  21015. // ,[VisaFreeNumber]
  21016. // ,[CreateUserId]
  21017. // ,[CreateTime]
  21018. // ,[DeleteTime]
  21019. // ,[DeleteUserId]
  21020. // ,[Remark]
  21021. // ,[IsDel]
  21022. // ,[visaDescription])
  21023. // VALUES
  21024. // ({0},{1},'{2}',{3},{4}
  21025. //,{5},{6},{7},{8},{9}
  21026. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  21027. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  21028. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  21029. //);
  21030. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  21031. // }
  21032. // return Ok(JsonView(true, "操作成功!"));
  21033. // }
  21034. /// <summary>
  21035. /// 123132123
  21036. /// </summary>
  21037. /// <param name="_dto"></param>
  21038. /// <returns></returns>
  21039. [HttpPost]
  21040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21041. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  21042. {
  21043. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  21044. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  21045. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  21046. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  21047. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  21048. dicDetail.Add(789, 1034);
  21049. dicDetail.Add(790, 1035);
  21050. dicDetail.Add(791, 1036);
  21051. dicDetail.Add(792, 1037);
  21052. dicDetail.Add(793, 1038);
  21053. dicDetail.Add(794, 1039);
  21054. dicDetail.Add(795, 1040);
  21055. dicDetail.Add(796, 1041);
  21056. dicDetail.Add(797, 1042);
  21057. dicDetail.Add(798, 1043);
  21058. dicDetail.Add(801, 1044);
  21059. dicDetail.Add(802, 1045);
  21060. dicDetail.Add(803, 1046);
  21061. Dictionary<int, int> dic = new Dictionary<int, int>();
  21062. dic.Add(806, 1027);
  21063. dic.Add(807, 1028);
  21064. dic.Add(808, 1029);
  21065. dic.Add(809, 1030);
  21066. dic.Add(810, 1031);
  21067. dic.Add(811, 1032);
  21068. dic.Add(812, 1033);
  21069. foreach (var item in list_visa)
  21070. {
  21071. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  21072. temp.Coefficient = item.coefficient;
  21073. DateTime dtCrt;
  21074. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  21075. if (b1)
  21076. {
  21077. temp.CreateTime = dtCrt;
  21078. }
  21079. else
  21080. {
  21081. temp.CreateTime = DateTime.Now;
  21082. }
  21083. temp.CreateUserId = item.Operators;
  21084. temp.DeleteTime = "";
  21085. temp.DeleteUserId = 0;
  21086. temp.DiId = int.Parse(item.DIID);
  21087. temp.FilePath = item.FilePath;
  21088. temp.IsDel = item.IsDel;
  21089. temp.Price = item.Price;
  21090. temp.PriceCount = 1;
  21091. temp.PriceCurrency = item.Currency;
  21092. int detailId = 0;
  21093. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  21094. {
  21095. detailId = dicDetail[item.PriceTypeDetail];
  21096. }
  21097. temp.PriceDetailType = detailId;
  21098. temp.PriceDt = DateTime.Now;
  21099. temp.PriceName = item.PriceName;
  21100. temp.PriceSum = item.Price;
  21101. int tid = 0;
  21102. if (dic.ContainsKey(item.PriceType))
  21103. {
  21104. tid = dic[item.PriceType];
  21105. }
  21106. temp.PriceType = tid;
  21107. temp.Remark = item.Remark;
  21108. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  21109. }
  21110. return Ok(JsonView(true, "操作成功!"));
  21111. }
  21112. [HttpPost]
  21113. public IActionResult TimeTest()
  21114. {
  21115. var jw = JsonView(false, "error");
  21116. _sqlSugar.BeginTran();
  21117. try
  21118. {
  21119. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  21120. .Select(x => new Crm_NewClientData
  21121. {
  21122. Id = x.Id,
  21123. Client = x.Client,
  21124. Contact = x.Contact,
  21125. Location = x.Location,
  21126. })
  21127. .ToList();
  21128. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  21129. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  21130. Stopwatch stopwatch = new Stopwatch();
  21131. // 开始计时
  21132. stopwatch.Start();
  21133. foreach (var item in clientList)
  21134. {
  21135. EncryptionProcessor.DecryptProperties(item);
  21136. }
  21137. stopwatch.Stop();
  21138. jw.Code = 200;
  21139. jw.Data = stopwatch.ElapsedMilliseconds;
  21140. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  21141. }
  21142. catch (Exception ex)
  21143. {
  21144. jw.Code = 400;
  21145. jw.Msg = ex.Message;
  21146. }
  21147. return Ok(jw);
  21148. }
  21149. }
  21150. }